SQL·高级查询

来源:互联网 发布:mac mini更新 编辑:程序博客网 时间:2024/04/30 21:56

--查看所有的数据库信息;
select * from master..sysdatabases
exec sp_helpdb

--查看某数据库中的所有用户表;
select name from northwind..sysobjects where xtype='u'


--查询某表中所有列名;
select name from syscolumns where id=object_id('news')

--查看某触发器SQL脚本代码;

select text from syscomments where id=object_id('NS')

exec sp_helptext 'NS'

--查看某数据库的具体情况;
select * from sysfiles
exec sp_spaceused
exec sp_helpdb 'NewsSystem'

--查看某表的完整结构;
exec sp_help 'news'

exec sp_msforeachtable

原创粉丝点击