数据库sql语言总结由刀豆文库小编整理,希望给你工作、学习、生活带来方便,猜你可能喜欢“sql数据库语句总结”。
插入句型:
insertinto [各属性名]values(,……)
删除元组或者二维表:
delete from[ where ]
删除属性:
altertabledropcolumn
增加某表的属性:
altertableadd 类型
修改句型:
updateset =[where]
修改某表当中的属性类型:
altertablealtercolumn;
显示表的一些基本情况
EXEC sp_help''
更改当前数据库中用户创建对象(如表、列或用户定义数据类型)的名称 sp_rename ‘’, ‘’
修改表的列名 sp_rename'.', 'newname ', 'COLUMN '
小注:上面的语句最后不需要加分号
判断表中是否存在某列的语句
if exists(select * from syscolumns where id = object_id('stu')and name='Sno')
print 'stu exists'
else print 'stu not exists'
将表中的某列设置为主码:
alter table stu addSno char primary key;
判断表是否存在if exists(select count(*)from sysobjects where type='U' and name='stu')
查询某个表中字段的列名和数据类型
select column_name,data_type from information_schema.columns where table_name = '表名';