下面是用sql语句显示数据库中所有的用户表。
select [id], [name] from [sysobjects] where [type] = 'u' and status>0
查询所有用户表的结构,这个语句在编写数据字典时很有用哦。如果想只显示一个表的话就在条件后面直接写上表名就可以了。
SELECT table_name as '表名',column_name as '列名',data_type as '类型',
character_maximum_length as '长度',column_default as '默认值',is_nullable as '是否为空'
FROM INFORMATION_SCHEMA.COLUMNS
where table_name in(select name from sysobjects where xtype='u' and status>0)
order by table_name