时间:2021-07-01 10:21:17 帮助过:38人阅读
CREATE DATABASE IF NOT EXISTS database_name;CREATE TABLE IF NOT EXISTS table_name;
AITER TABLE table_old_name RENAME [TO] table_new_name; RENAME TABLE table_old_name TO table_new_name;
ALTER TABLE table_name ADD column_name data_type NOT NULL DEFAULT xxx [AFTER/BEFORE] column_name;ALTER TABLE person ADD age tinyint NOT NULL DEFAULT 16 AFTER name;
ALTER TABLE table_name DROP [COLUMN] column_name;ALTER TABLE person DROP COLUMN age;
ALTER TABLE table_name CHANGE [COLUMN] column_old_name column_new_name 列声明
ALTER TABLE table_name MODIFY [COLUMN] column_name data_type;ALTER TABLE person MODIFY COLUMN age int NOT NULL DEFAULT 16;
ALTER TABLE table_name ADD index/unique/fulltext [索引名](列名); 不加索引名,则直接以列名命名 ALTER TABLE table_name ADD primary key (列名);
ALTER TABLE table_name DROP index 索引名; ALTER TABLE table_name DROP primary key;
show index from table_name; show index from table_name/G;