总结了几个常用的sql server系统表的使用
2011-06-02 10:21
441 查看
--查看表的属性
select * from sysObjects where [Name] = 'section'
--用法
if exists ( select * from sysObjects where [Name] = 'section' and xtype='U' )
Drop Table table1
go
Create table1 ( )
--获取所有用户表
select Name from sysobjects where xtype='u' and status>=0
--查看表的字段
select * from sysColumns c where c.id=object_id('section')
select name from syscolumns where id=object_id('表名')
--查看用户
select * From sysusers where status<>0
--查看谁引用了bbs_hits表(包括视图、存储过程、函数)
Select distinct object_name(d.id) as 'program',
o.xtype
from sysdepends d inner join sysobjects o on d.id=o.id
where object_name(depid)='bbs_hits'
--查看与某一个表相关的视图、存储过程、函数
select a.* from sysobjects a, syscomments b where a.id = b.id and b.text like '%表名%'
--查看当前数据库中所有存储过程
select name as 存储过程名称 from sysobjects where xtype='P'
--查询某一个表的字段和数据类型
select column_name,data_type from information_schema.columns
where table_name = '表名'
.[标题]:
Select * From TableName Order By CustomerName
其中xtype分别对应:
C = CHECK 约束
D = 默认值或 DEFAULT 约束
F = FOREIGN KEY 约束
FN = 标量函数
IF = 内嵌表函数
K = PRIMARY KEY 或 UNIQUE 约束
L = 日志
P = 存储过程
R = 规则
RF = 复制筛选存储过程
S = 系统表
TF = 表函数
TR = 触发器
U = 用户表
V = 视图
X = 扩展存储过程
select * from sysObjects where [Name] = 'section'
--用法
if exists ( select * from sysObjects where [Name] = 'section' and xtype='U' )
Drop Table table1
go
Create table1 ( )
--获取所有用户表
select Name from sysobjects where xtype='u' and status>=0
--查看表的字段
select * from sysColumns c where c.id=object_id('section')
select name from syscolumns where id=object_id('表名')
--查看用户
select * From sysusers where status<>0
--查看谁引用了bbs_hits表(包括视图、存储过程、函数)
Select distinct object_name(d.id) as 'program',
o.xtype
from sysdepends d inner join sysobjects o on d.id=o.id
where object_name(depid)='bbs_hits'
--查看与某一个表相关的视图、存储过程、函数
select a.* from sysobjects a, syscomments b where a.id = b.id and b.text like '%表名%'
--查看当前数据库中所有存储过程
select name as 存储过程名称 from sysobjects where xtype='P'
--查询某一个表的字段和数据类型
select column_name,data_type from information_schema.columns
where table_name = '表名'
.[标题]:
Select * From TableName Order By CustomerName
其中xtype分别对应:
C = CHECK 约束
D = 默认值或 DEFAULT 约束
F = FOREIGN KEY 约束
FN = 标量函数
IF = 内嵌表函数
K = PRIMARY KEY 或 UNIQUE 约束
L = 日志
P = 存储过程
R = 规则
RF = 复制筛选存储过程
S = 系统表
TF = 表函数
TR = 触发器
U = 用户表
V = 视图
X = 扩展存储过程
相关文章推荐
- 总结了几个常用的sql server系统表的使用
- 总结了几个常用的sql server系统表的使用[转]
- 总结了几个常用的sql server系统表的使用
- 几个常用的sql server系统表的使用
- 几个常用的sql server系统表的使用
- [学习总结]SQL SERVER 2005常用系统函数
- 常用代码托管系统使用经验总结
- 在SQL Server 的使用过程中,发现几个很有用,但不太常用
- 苹果OS X系统常用键盘快捷键和触控板使用技巧总结
- linux学习使用总结-linux系统的安装和与windows双系统共享,linux常用的基本命令,今天贴在这里和大家分享
- 总结几个常用的系统安全设置(含DenyHosts)
- 使用Java获取系统信息的常用代码整理总结
- SQL Server 几个常用函数的使用
- Sql Server 2008 常用系统存储过程
- Unity3D中uGUI事件系统简述及使用方法总结
- SQL Server大数据量统计系统的经验总结
- Google Map API使用详解(九)——Google Map坐标系统总结(下)
- Unity3D中uGUI事件系统简述及使用方法总结
- Android中几个常用的工具类总结
- 总结:常用的Linux系统监控命令(转)