SQL表结构语句

  新建表:

create table t3(
    id int not null primary key, # id为主键,且不能为空
    name char(20) not null
    ); 
语法:语法 create table 表名称( 字段名 字段名类型 字段描述符,字段名 字段类型 字段描述符);

  删除表:

drop table t3;
语法:drop table 表名称;

  修改表:

alter table t2 add(score int not null);  #新增列(字段,且不能为空)
语法:alter table 表明称 add(字段名 类型 描述符);
alter table t2 drop column score;    #删除列
语法:alter table 表名 drop colunm 字段名,drop colunm 字段名;
alter table t2 change name score int(22) not null; #修改列
语法:alter table 表名 change 旧字段名 新字段名 新字段描述符

  清除表数据(可使表自增id从1开始):

truncate table scheduling_plan_week;
语法:truncate table 表名
posted @ 2021-10-20 14:01  *球球*  阅读(147)  评论(0编辑  收藏  举报