注:本随笔只是mysql知识的积累,如果您看到此随笔,有错误请指正,谢谢!
# 标准建表语句
DROP TABLE IF EXISTS temp_whc_ceshi2 ;
CREATE TABLE IF NOT EXISTS temp_whc_ceshi2
(
s_no int(20) NOT NULL auto_increment COMMENT "自增主键|学号"
,s_name varchar(25) default "未获取" COMMENT "学生姓名"
,s_cno int(30) default 10 COMMENT "班级号"
,create_time datetime not null default current_timestamp comment'创建时间'
,updatetime datetime not null default current_timestamp on update current_timestamp comment '更新时间'
,PRIMARY KEY (s_no)
)
ENGINE InnoDB DEFAULT CHARSET = UTF8 COMMENT "测试表"
;
# 查看表结构
desc temp_whc_ceshi2;
# 查看建表语句
show create table temp_whc_ceshi2;
# 修改表名
alter table temp_whc_ceshi2 rename to temp_whc_ceshi;
# 修改字段类型
alter table temp_