sql表結構

來源:魅力女性吧 3.27W
sql表結構

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 表名

熱門標籤