修改列名需要在最后加上类型
ALTER TABLE book CHANGE COLUMN publishdate pubDate DATETIME;
修改列的约束和类型
ALTER TABLE book MODIFY COLUMN pubdate TIMESTAMP;
添加新列,要加上类型
ALTER TABLE book ADD COLUMN annual DOUBLE;
删除列
ALTER TABLE author DROP COLUMN annual;
ALTER TABLE author DROP COLUMN IF EXISTS annual;
修改表名
ALTER TABLE author RENAME TO book_author;
表的删除
DROP TABLE book_author;
查看当前库的所以表
SHOW TABLES;
原文地址:https://blog.51cto.com/14437184/2440122
时间: 2024-10-12 06:33:32