Rumah  >  Artikel  >  pangkalan data  >  oracle&&Sqlserver获取表名列名主键及数据类型

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

WBOY
WBOYasal
2016-06-07 15:44:321196semak imbas

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_%'

Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn