如何避免 MySQL 中的"使用 keycache 修复"?
mysqlmysqli database更新于 2025/9/15 15:08:17
要避免 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) ); Query OK, 0 rows affected (0.24 sec)
使用 insert 命令在表中插入一些记录 −
mysql> insert into DemoTable(StudentFirstName,StudentLastName) values('John','Doe');
Query OK, 1 row affected (0.05 sec)
mysql> insert into DemoTable(StudentFirstName,StudentLastName) values('David','Miller');
Query OK, 1 row affected (0.05 sec)
使用 select 语句显示表中的所有记录 −
mysql> select *from DemoTable;
这将产生以下输出 −
+-----------+------------------+-----------------+ | StudentId | StudentFirstName | StudentLastName | +-----------+------------------+-----------------+ | 1 | John | Doe | | 2 | David | Miller | +-----------+------------------+-----------------+ 2 rows in set (0.00 sec)
步骤 1 − 以下是在 MySQL 中避免“使用 keycache 修复”的查询。
mysql> create table DemoTable as (select *from DemoTable); Query OK, 2 rows affected (0.34 sec) Records: 2 Duplicates: 0 Warnings: 0
步骤 2 − 现在,使用 alter table
mysql> alter table DemoTable add index(StudentFirstName); Query OK, 2 rows affected (0.57 sec) Records: 2 Duplicates: 0 Warnings: 0
相关文章
有用资源
mysql 参考教程 - 该教程包含有关 mysql 的更多信息:https://www.cainiaomax.com/mysql/

