Many DDL operations on tables and indexes (表和索引上的许多DDL操作(CREATE
, ALTER
, and DROP
statements) can be performed online. CREATE
、ALTER
和DROP
语句)都可以在线执行。See Section 15.12, “InnoDB and Online DDL” for details.详见第15.12节,“InnoDB
和在线DDL”。
Online DDL support for adding secondary indexes means that you can generally speed up the process of creating and loading a table and associated indexes by creating the table without secondary indexes, then adding secondary indexes after the data is loaded.对添加辅助索引的在线DDL支持意味着您通常可以通过创建不带辅助索引的表,然后在加载数据后添加辅助索引来加快创建和加载表及其关联索引的过程。
Use TRUNCATE TABLE
to empty a table, not DELETE FROM
. Foreign key constraints can make a tbl_name
TRUNCATE
statement work like a regular DELETE
statement, in which case a sequence of commands like DROP TABLE
and CREATE TABLE
might be fastest.
Because the primary key is integral to the storage layout of each InnoDB
table, and changing the definition of the primary key involves reorganizing the whole table, always set up the primary key as part of the CREATE TABLE
statement, and plan ahead so that you do not need to ALTER
or DROP
the primary key afterward.