`
圣诞王子
  • 浏览: 83024 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

SQL查询表结构(转)

 
阅读更多

网上搜集的查询表结构的SQL,适用于SQL SERVER

-- 查询非系统数据库  
    Select name FROM Master.. SysDatabases where dbid>4  
      
    -- 选择water数据库下的所有表  
    use [water] SELECT name FROM sysobjects WHERE xtype = 'U' Or xtype = 'S'  
      
    -- 选择water数据库下的所有用户表  
    use [water] SELECT name FROM sysobjects WHERE xtype = 'U' AND OBJECTPROPERTY (id, 'IsMSShipped') = 0  
      
    -- 查询water数据库下的admin表的字段名,长度,类型,字段说明  
    use [water] SELECT a.[name] as '字段名',a.length '长度',c.[name] '类型',e.value as '字段说明' FROM syscolumns  a   
    left   join    systypes    b   on      a.xusertype=b.xusertype   
    left    join    systypes    c   on      a.xtype = c.xusertype   
    inner   join   sysobjects  d   on      a.id=d.id     and   d.xtype='U'   
    left join sys.extended_properties e on a.id = e.major_id and a.colid = e.minor_id and e.name='MS_Description'  
    where d.name='admin'

 

select * from information_schema.columns where table_name ='colocal' 

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics