SQL Server数据使用 二
insert into student(sno,sname,ssex,sage,sdept)values /*增加元素*/
('201215125','明治','男','90','bn');
select*from student /*查询表格*/
delete from student where sno=201215125 /*删除行数据*/
update student set sno=201215125,sname='黎明',ssex='男',sdept='mn',sage=19.where sno=201215121 /*修改行数据*/
exec sp_columns student /*列的·查询*/
alter table student drop column sage /*删除列*/
exec sp_rename 'student.sage','nianling','column' /*修改列名*/
exec sp_rename 'student.nianling','sage','column' /*修改列名*/
alter table student add sage smallint /*增加列*/
update student set sage=20 where sno=201215121
update student set sage=19 where sno=201215122
update student set sage=18 where sno=201215123
update student set sage=19 where sno=201215124 /*更新数据*/
alter table student alter column sage int /*修改数据类型*/
drop table student (cascade/ restrict) /*删除表 当表中建有视图时:cascade,视图与表皆被删除。*/
create unique index scno on sc(sno ASC,cno DESC); /*新建索引[unique][cluster] 表示唯一索引与聚集索引*/
exec sp_rename 'sc.scno','scsno','index' /*修改索引*/
drop index scno on sc /*删除索引*/
execute sp_helpindex sc /*查询是否有索引*/
execute sp_helpconstraint sc /*查询是否有约束*/