当前位置:Gxlcms > mysql > oracle&&Sqlserver获取表名列名主键及数据类型

oracle&&Sqlserver获取表名列名主键及数据类型

时间:2021-07-01 10:21:17 帮助过:11人阅读

SQlserver获得列名,列类型,列类型长度,scale,prec等数据类型(syscolumns,systypes,sysobjects均为视图) select a.name as colname, b.name as typename,a.length as length,a.scale as scale,a.prec as prec from syscolumns a,systypes b ,sysobjec

SQlserver获得列名,列类型,列类型长度,scale,prec等数据类型(syscolumns,systypes,sysobjects均为视图)

select a.name as colname, b.name as typename,a.length as length,a.scale as scale,a.prec as prec from syscolumns a,systypes b ,sysobjects c where a.xusertype=b.xusertype and a.id=c.id and c.name ='TableName' order by c.id

Oracle获得列名,列类型,列类型长度,scale,prec等数据类型

select column_name,data_type ,data_length,data_precision,data_scale from user_tab_columns where table_name='TableName'

SQLserver获得所有表名

Select Name FROM SysObjects Where XType='U'

Oracle获取所有表名

select tname from tab where tabtype='TABLE'

获得表中主键的列,列类型,列类型长度

select a.name as colname, b.name as typename,a.length as length,a.scale as scale,a.prec as prec from syscolumns a,systypes b ,sysobjects c , INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE d where a.xusertype=b.xusertype and a.id=c.id and c.name ='TableName' and b.name<>'DATE' and a.name =d.COLUMN_NAME and d.CONSTRAINT_NAME like 'PK_%'

人气教程排行