- 问题描述:现在在last_update后面新增加一列名字为create_date, 类型为datetime, NOT NULL,默认值为'2020-10-01 00:00:00'
语法:
ALTER TABLE tbl_name [alter_option [, alter_option] ...] [partition_options] alter_option: { table_options | ADD [COLUMN] col_name column_definition [FIRST | AFTER col_name] | ADD [COLUMN] (col_name column_definition,...)
本题代码:
ALTER TABLE actor ADD COLUMN (create_date DATETIME NOT NULL DEFAULT'2020-10-01 00:00:00');
或
ALTER TABLE actor ADD (create_date DATETIME NOT NULL DEFAULT'2020-10-01 00:00:00');
参考文文献:mysql官方文档13.1.9 ALTER TABLE Statementhttps://dev.mysql.com/doc/refman/8.0/en/alter-table.html