zoukankan      html  css  js  c++  java
  • sql server 查询表信息

     1 SELECT 
     2         '表名'        = e.[name],
     3         '表说明'      = f.[value],
     4         '字段序号'    = a.colorder,
     5         '字段名'      = a.[name],
     6         '字段类型'    = b.[name],
     7         '字段长度'    = COLUMNPROPERTY(a.id,a.name,'PRECISION'),
     8         '占用字节数'  = a.length,
     9         '字段注释'    = c.[value],
    10         '小数位数'    = isnull(COLUMNPROPERTY(a.id,a.name,'Scale'),0),
    11         '是否允许空'  = case when a.isnullable=1 then ''else '' end,
    12         '默认值'      = d.[text],
    13         '是否是主键'        = case when exists(SELECT 1 FROM sysobjects where xtype='PK' and parent_obj=a.id and name in (
    14                            SELECT name FROM sysindexes WHERE indid in( SELECT indid FROM sysindexkeys WHERE id = a.id AND colid=a.colid))) then '' else '' end
    15 FROM syscolumns a
    16 LEFT JOIN systypes b ON a.xusertype = b.xusertype
    17 LEFT JOIN sys.extended_properties c ON a.id=c.major_id AND a.colid=c.minor_id
    18 left join syscomments d on a.cdefault=d.id
    19 left join sysobjects e on a.id=e.id  and e.xtype='U' and  e.[name]<>'dtproperties'
    20 left JOIN sys.extended_properties f on e.id=f.major_id and f.minor_id=0 --AND f.[name]='MS_Description'--f.name为属性名字,一个表可以有多个属性,表的属性名字右键新建
    21 WHERE a.id=OBJECT_ID('dbo.Member')

    结果为:

  • 相关阅读:
    跨域请求
    django数据模型中关于on_delete, db_constraint的使用
    rest-framework之分页器
    跨域请求
    相对路径与绝对路径
    html常用标签
    ES6中字符串扩展
    javascript中startswith和endsWidth 与 es6中的 startswith 和 endsWidth
    Angular6 组件树结构优化
    docker限制容器内存使用上限
  • 原文地址:https://www.cnblogs.com/malianyong/p/3831470.html
Copyright © 2011-2022 走看看