创建表:
create table stu_info(
id int identity(1,1) not null primary key clustered,
name char(10) not null,
score numeric not null
)
新建主键:
create table stu_info(
id int identity(1,1) not null,
name char(10) not null
)
alter table stu_info add constraint pk_id primary key cluster (id)
新建表字段
alter table stu_info add sex char(10) not null
删除表字段
alter table stu_infor drop column score
插入数据
insert into stu_info1 (name,score) values('a1',10)
更新数据
update stu_info1 set name='a2' where id =1
删除数据
delete stu_info1 where name='a1'
查询数据
select * from stu_info1
创建索引以及删除
create index stu_index on stu_info(id)
create unique stu_index on stu_info(id)
drop index stu_index on stu_info
修改表名
exec sp_name 'old_name','new_name'
修改列名称
exec sp_name 'test.old_column_name','new_column_name','column'
修改列类型
alter table test alter column test1 numeric(4,2)