--建表
if OBJECT_ID('tb') is not null drop table tb
go
create table tb (id int)
go
--增加一个自增列
alter TABLE dbo.tb ADD id1 int identity(1,1)
GO
--删除原来的列
alter TABLE dbo.tb drop column id
GO
--查看
exec sp_help tb
go
--修改列名
exec sp_rename 'tb.id1','id', 'column'
go
if OBJECT_ID('tb') is not null drop table tb
go
create table tb (id int)
go
--增加一个自增列
alter TABLE dbo.tb ADD id1 int identity(1,1)
GO
--删除原来的列
alter TABLE dbo.tb drop column id
GO
--查看
exec sp_help tb
go
--修改列名
exec sp_rename 'tb.id1','id', 'column'
go
本文演示了如何使用SQL语句调整表结构,包括创建表、添加自增列、删除原有列及修改列名等操作。
5106

被折叠的 条评论
为什么被折叠?



