如何在Sql2008中获取表字段属性和注释? select b.[value] from sys.columns a left join sys.extended_properties b on a.object_id=b.major_id and a.column_id=b.minor_id inner join sysobjects c on a.column_id=c.id and a.[name]='列名' and c.[name]='表名' SELECT 表名=case when a.…
一.获取表字段: select * from user_tab_columns where Table_Name='用户表' user_tab_columns 为当前用户的columns,除此之外还有all_tab_columns和dba_tab_columns,这两个多了owner列 select * from all_tab_columns where Table_Name='用户表' and owner = 'admin' 二.获取表注释: select * from user_tab_c…
select b.COMMENTS,a.COLUMN_NAME,a.DATA_TYPE,a.DATA_LENGTH, a.DATA_PRECISION,a.DATA_SCALE,a.NULLABLE,COLUMN_ID from user_tab_columns a inner join user_col_comments b on b.COLUMN_NAME=a.column_name and b.table_name=a.TABLE_NAME where a.table_name =UPPE…
SELECT TableName = OBJECT_NAME(c.object_id), ColumnsName = c.name, Description = ex.value, ColumnType=st.name, Length=c.max_length FROM sys.columns c LEFT JOIN sys.extended_properties ex ON ex.major_id = c.object_id AND ex.minor_id = c.column_id AND…
SELECT * FROM ( select a.name TABLENAME,b.name FIELDNAME,c.name FIELDTYPE,c.length FIELDLENGTH from sysobjects a,syscolumns b,systypes c where a.id=b.id and a.name='SYS_EXCEL' and a.xtype='U' and b.xtype=c.xtype) TAB WHERE FIELDNAME='ImportFIELDNAME'…
select b.[value] from sys.columns a left join sys.extended_properties b on a.object_id=b.major_id and a.column_id=b.minor_id inner join sysobjects c on a.column_id=c.id and a.[name]='列名' and c.[name]='表名' SELECT 表名=case …
SELECTTABLE_NAME as '表名', column_name AS '列名', data_type AS '数据类型', character_maximum_length AS '字符长度', numeric_precision AS '数字长度', numeric_scale AS '小数位数', is_nullable AS '是否允许非空', CASE WHEN extra = 'auto_increment' THEN 1 ELSE 0 END AS '是否自增', col…