sql sever基本命令

 

创建表:
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)

 

转载于:https://www.cnblogs.com/Dai-py/p/10728091.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值