标签:结果 ima 语句 type alt src select nullable 软实力
目标数据库为微软实力数据库:AdventureWorks2012
1、Sql 语句:
SELECT DISTINCT c.TABLE_SCHEMA , c.TABLE_NAME , c.COLUMN_NAME , c.DATA_TYPE , c.IS_NULLABLE , tc.CONSTRAINT_TYPE , CONVERT(INT, c.NUMERIC_PRECISION) NUMERIC_PRECISION , c.NUMERIC_SCALE , c.CHARACTER_MAXIMUM_LENGTH , c.ORDINAL_POSITION , tc.CONSTRAINT_NAME , COLUMNPROPERTY(OBJECT_ID(c.TABLE_SCHEMA + ‘.‘ + c.TABLE_NAME), c.COLUMN_NAME, ‘IsIdentity‘) ISIDENTITY , ( SELECT CASE WHEN COUNT(1) = 0 THEN 0 ELSE 1 END FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS x INNER JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccux ON c.TABLE_NAME = ccux.TABLE_NAME AND c.COLUMN_NAME = ccux.COLUMN_NAME AND c.TABLE_SCHEMA = ccux.TABLE_SCHEMA WHERE x.CONSTRAINT_TYPE = ‘UNIQUE‘ AND x.TABLE_SCHEMA = ccux.TABLE_SCHEMA AND x.CONSTRAINT_NAME = ccux.CONSTRAINT_NAME ) ISUNIQUE FROM INFORMATION_SCHEMA.COLUMNS c LEFT OUTER JOIN ( INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc ON ( tc.TABLE_SCHEMA = ccu.TABLE_SCHEMA AND tc.CONSTRAINT_NAME = ccu.CONSTRAINT_NAME AND NOT tc.CONSTRAINT_TYPE IN ( ‘CHECK‘, ‘UNIQUE‘ ) ) ) ON ( c.TABLE_SCHEMA = ccu.TABLE_SCHEMA AND c.TABLE_NAME = ccu.TABLE_NAME AND c.COLUMN_NAME = ccu.COLUMN_NAME ) ORDER BY c.TABLE_SCHEMA , c.TABLE_NAME , c.COLUMN_NAME;
2、结果:
标签:结果 ima 语句 type alt src select nullable 软实力
原文地址:http://www.cnblogs.com/jeffrey-net/p/7622974.html