T-SQL 对表结构进行增,删,改

来源:互联网 发布:网游之武知我道下载 编辑:程序博客网 时间:2024/04/29 21:58
create database test1use test1create table admin(   id int primary key ,   name varchar(50),   pwd  varchar(50),)insert into admin values(1,'aa','aa')alter  table   admin   add...
create database test1
use test1
create table admin
(
   id int primary key ,
   name varchar(50),
   pwd  varchar(50),
)
insert into admin values(1,'aa','aa')
alter  table   admin   add   tel  varchar(50)   NULL
select * from admin

select * from admin
if   exists   (select   *   from   syscolumns   where   id=object_id('admin')   and   name='mms')   print   '已经存在该字段'
alter  table   admin   add   tel  varchar(50)   NULL


alter table admin alter column name set bbs varchar(50) null
alter table tablename  drop column oldfield

EXEC sp_rename 'admin.sss', 'tel', 'COLUMN'
原创粉丝点击