必須會的SQL語句(二) 創(chuàng)建表、修改表結(jié)構(gòu)、刪除表
發(fā)布日期:2021-12-26 02:41 | 文章來源:站長之家
1.創(chuàng)建數(shù)據(jù)庫表
--使用哪個數(shù)據(jù)庫,如果不寫這一句是默認(rèn)的數(shù)據(jù)庫,也可以用鼠標(biāo)選當(dāng)前數(shù)據(jù)庫 use testDB --創(chuàng)建表 Create Table tablename ( --id表示字段名 --int 數(shù)據(jù)類型 --primary key 主鍵 --not null 非空 --identity(1,1)初始值是1 每次自增長1 id int primary key not null identity(1,1), --unique 唯一 name varchar(20) not null unique )
2.刪除表
Drop table 表名
3.修改表結(jié)構(gòu)
--增加列
Alter table 表名
Add 列名 類型
--刪除列
Alter table 表名
drop cloumn 列名
--修改列,修改列類型
Alter table 表名
Alter column 列名 type
版權(quán)聲明:本站文章來源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學(xué)習(xí)參考,不代表本站立場,如有內(nèi)容涉嫌侵權(quán),請聯(lián)系alex-e#qq.com處理。
相關(guān)文章