SQL 語句創建表 添加、刪除、修改字段 表是否存在 是否存在數據

--創建表

create table studentInfo
(
id int identity primary key,
name nvarchar(50),
xueke nvarchar(50),
score int
)

--添加字段

alter table studentInfo add xueke nvarchar(50)

 

--修改字段
alter table studentInfo alter column xueke nvarchar(100)

 

--刪除字段
alter table studentInfo drop column xueke

--判斷表是否存在

select * from sysobjects wherename=表名

 

--判斷表中是否存在行數據

if exists(select * from studentInfo)

發佈了88 篇原創文章 · 獲贊 16 · 訪問量 30萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章