显示表结构的SQL
2006-04-19 16:32
197 查看
select
表名=case when a.colorder=1 then d.name else '' end,
表说明=case when a.colorder=1 then isnull(f.value,'') else '' end,
字段序号=a.colorder, 字段名=a.name,
标识=case when columnproperty( a.id,a.name,'isidentity')=1 then '√'else '' end,
主键=case when exists(select 1
from sysobjects
where xtype='pk' and name in ( select name
from sysindexes
where indid in( select indid
from sysindexkeys
where id = a.id and colid=a.colid )
)
) then '√' else '' end,
类型=b.name,
占用字节数=a.length,
长度=columnproperty(a.id,a.name,'precision'),
小数位数=isnull(columnproperty(a.id,a.name,'scale'),0),
允许空=case when a.isnullable=1 then '√'else '' end,
默认值=isnull(e.text,''),
字段说明=isnull(g.[value],'')
from syscolumns a
left join systypes b on a.xusertype=b.xusertype
inner join sysobjects d on a.id=d.id and d.xtype='u' and d.name<>'dtproperties'
left join syscomments e on a.cdefault=e.id
left join sysproperties g on a.id=g.id and a.colid=g.smallid
left join sysproperties f on d.id=f.id and f.smallid=0
--where d.name='要查询的表' --如果只查询指定表,加上此条件
order by a.id,a.colorder
表名=case when a.colorder=1 then d.name else '' end,
表说明=case when a.colorder=1 then isnull(f.value,'') else '' end,
字段序号=a.colorder, 字段名=a.name,
标识=case when columnproperty( a.id,a.name,'isidentity')=1 then '√'else '' end,
主键=case when exists(select 1
from sysobjects
where xtype='pk' and name in ( select name
from sysindexes
where indid in( select indid
from sysindexkeys
where id = a.id and colid=a.colid )
)
) then '√' else '' end,
类型=b.name,
占用字节数=a.length,
长度=columnproperty(a.id,a.name,'precision'),
小数位数=isnull(columnproperty(a.id,a.name,'scale'),0),
允许空=case when a.isnullable=1 then '√'else '' end,
默认值=isnull(e.text,''),
字段说明=isnull(g.[value],'')
from syscolumns a
left join systypes b on a.xusertype=b.xusertype
inner join sysobjects d on a.id=d.id and d.xtype='u' and d.name<>'dtproperties'
left join syscomments e on a.cdefault=e.id
left join sysproperties g on a.id=g.id and a.colid=g.smallid
left join sysproperties f on d.id=f.id and f.smallid=0
--where d.name='要查询的表' --如果只查询指定表,加上此条件
order by a.id,a.colorder
相关文章推荐
- sqlplus登录方式,列出所有表,列出表结构,sqlplus行和列显示设置,别名,空值问题,连接符,DISTINCT
- 显示表结构的SQL
- 不修改SQL表结构,改变列显示次序(非Select语句)
- 显示表结构sql语句
- 树型结构数据的客户部门SQL显示语句(纯sql语句)
- SQL语句显示表结构
- 显示SQL的表结构
- sqlplus登录信息,列出所有表,列在表结构,sqlplus行和列显示设置,别名,Null值问题,细木工,DISTINCT
- MS SQL Server树型结构数据显示的SQL语句(纯SQL语句,不用函数)
- 显示数据库中表结构的SQL语句
- SQL学习笔记之显示用户表和用户表的结构
- 显示SQL的表结构
- MS SQL Server树型结构数据显示的SQL语句(纯SQL语句,不用函数)
- SQL 基础之去重和显示表结构(四)
- 显示表结构的sql语句
- 显示表结构描述的Sql语句
- ASP.NET中显示Linq To SQL输出的SQL语句
- c# winform下sql图片二进制存储/读取/显示/写入XML/读取XML显示
- 用于分页显示的SQL文
- MyBatis中显示SQL语句