1.看两条sql对比
1:手敲的:
ALTER TABLE 'test_date' MODIFY COLUMN 'test_date' TIMESTAMP NOT NULL DEFAULT now() COMMENT '月-月-月' AFTER 'id';
2.navicate自动生成的
ALTER TABLE `test_date` MODIFY COLUMN `test_date` TIMESTAMP NOT NULL DEFAULT now() COMMENT '年-月-日' AFTER `id`;
运行手敲的1:报错,运行2没有问题
[SQL]ALTER TABLE 'test_date' MODIFY COLUMN 'test_date' TIMESTAMP NOT NULL DEFAULT now() COMMENT '月-月-月' AFTER 'id';
[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''test_date' MODIFY COLUMN 'test_date' TIMESTAMP NOT NULL DEFAULT now() COMMENT '' at line 1
2。问题navacite生成sql会自动给一些特有名词带一些它不识别的‘’,自己写sql时直接去掉’'就可以
在使用navicate时它会自动加上‘’;但是运行就报错如:
输入 SELECT CURR 它会自动弹出:SELECT `CURRENT_TIME`();
但是运行就会报错 修改成:SELECT CURRENT_TIME(); 运行
成功:16:13:41
修改后代码
1.手敲:
ALTER TABLE test_date MODIFY COLUMN test_date TIMESTAMP NOT NULL DEFAULT now() COMMENT '月-月-月' AFTER id;
2.生成:
ALTER TABLE `test_date` MODIFY COLUMN `test_date` TIMESTAMP NOT NULL DEFAULT now() COMMENT '年-月-日' AFTER `id`;
运行正常