MySQL 脚本格式
-- t_XXX ??? DROP TABLE IF EXISTS t_XXX; CREATE TABLE t_XXX ( id INT NOT NULL AUTO_INCREMENT, ????????? VARCHAR(11) NOT NULL, ????????? VARCHAR(50) NOT NULL, ????????? VARCHAR(16) NOT NULL, ????????? VARCHAR(1) NOT NULL, create_time DATETIME COMMENT '创建时间', update_time DATETIME COMMENT '更新时间', PRIMARY KEY (id) ) DEFAULT CHARSET=utf8; -- CREATE INDEX CREATE INDEX idx_XXX ON t_XXX(TTT); -- TRIGGER1 INSERT DROP TRIGGER IF EXISTS tg_XXX_insert; CREATE TRIGGER tg_XXX_insert BEFORE INSERT ON t_XXX FOR EACH ROW BEGIN SET new.create_time = NOW(), new.update_time = NOW(); END; -- TRIGGER2 UPDATE DROP TRIGGER IF EXISTS tg_XXX_update; CREATE TRIGGER tg_XXX_update BEFORE UPDATE ON t_XXX FOR EACH ROW BEGIN SET new.update_time = NOW(); END; -- unique key ALTER TABLE t_XXX ADD UNIQUE KEY t_XXX_unique (???);