表删表
drop table [if not exist] students;表修改
ALTER语句
使用 ALTER TABLE 语句追加, 修改, 或删除列的语法
add
增加字段:
alter table students add [column] dateT date;设置默认值:
alter table students add dateT date DEFAULT "2025-12-12";modify
注意:MODIFY后必须明确指定「字段类型」(哪怕只是修改注释,也要重新声明类型)
修改字段类型,属性:
alter table students modify dataT datetime; alter table students modify dateT date comment "日期";修改字段默认不为空:
alter table students modify stu_id int not null;修改字段默认可以为空:
alter table students modify stu_id int default null;drop
删除字段:
alter table students drop length;其他写法:
drop table table_namechange
修改字段名称:
alter table students character set utf8;character set
修改表的字符集:
alter table students character set utf8;rename to
修改表名
alter table students rename to student;其他写法:
rename table students to student;