如何避免MySQL中的“与keycache一起修复”?
为了避免在MySQL中使用keycache进行修复,您需要遵循以下语法-
create table yourNewTableName as (select *from yourOldTableName); alter table yourNewTableName add index(yourCoumnName);
让我们首先创建一个表-
mysql> create table DemoTable ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentFirstName varchar(20), StudentLastName varchar(20) );
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable(StudentFirstName,StudentLastName) values('John','Doe'); mysql> insert into DemoTable(StudentFirstName,StudentLastName) values('David','Miller');
使用select语句显示表中的所有记录-
mysql> select *from DemoTable;
这将产生以下输出-
+-----------+------------------+-----------------+ | StudentId | StudentFirstName | StudentLastName | +-----------+------------------+-----------------+ | 1 | John | Doe | | 2 | David | Miller | +-----------+------------------+-----------------+ 2 rows in set (0.00 sec)
步骤1-以下是查询以避免在MySQL中“与密钥缓存一起修复”。
mysql> create table DemoTable as (select *from DemoTable); Records: 2 Duplicates: 0 Warnings: 0
第2步-现在,使用altertable
mysql> alter table DemoTable add index(StudentFirstName); Records: 2 Duplicates: 0 Warnings: 0