zoukankan      html  css  js  c++  java
  • 查看库中表的主键,标识列,计算列,字段类型,允许空,默认值等属性

    查看库中表的主键,标识列,计算列,字段类型,允许空,默认值等属性

                SELECT
                [表名]=CASE WHEN T.column_id = 1 THEN OBJECT_NAME(T.object_id) ELSE '' END ,
                [字段编号]=T.column_id,
                [字段名]=T.name,
                [主键]=case when exists(SELECT 1 FROM sys.key_constraints  where type='PK' and object_id=T.OBJECT_ID) THEN '' ELSE '' END,
                [标识列]=CASE T.is_identity  WHEN 1 THEN '' ELSE '' END,
                [计算列]=CASE T.is_computed WHEN 1 THEN '' ELSE '' END,
                [字段类型]=(SELECT name FROM sys.types WHERE user_type_id = T.user_type_id),
                [字段长度]= T.PRECISION,
                [小数位] = T.Scale,
                [允许空] = CASE T.is_nullable  WHEN 1 THEN '' ELSE '' END,
                [默认值]= ISNULL((SELECT definition from sys.default_constraints where object_id = T.default_object_id),''),
                [字段说明]=(SELECT VALUE FROM sys.extended_properties WHERE major_id = T.OBJECT_ID AND minor_id  =T.column_id)
                FROM sys.COLUMNS T
                INNER JOIN sys.objects O ON T.object_id = O.object_id AND O.type = 'U'
                WHERE RIGHT(OBJECT_NAME(T.object_id),3) <> 'Log' AND OBJECT_NAME(T.object_id) <>'AuditDDLEvents' AND OBJECT_NAME(T.object_id) <>'dtproperties'
                ORDER BY OBJECT_NAME(T.object_id),T.column_id
  • 相关阅读:
    捷微商城小程序上线啦~
    JEECG 新版在线文档WIKI正式发布
    https 详解
    css 3 新特性
    js 基础(一)
    BFC
    .Net、C# 汉字转拼音,简体繁体转换方法
    丰富“WinForms” 的一个别样"项目"(学生管理)
    学生管理系统1
    学生管理系统
  • 原文地址:https://www.cnblogs.com/davidhou/p/5580310.html
Copyright © 2011-2022 走看看