首頁  >  文章  >  資料庫  >  oracle&&Sqlserver获取表名列名主键及数据类型

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

WBOY
WBOY原創
2016-06-07 15:44:321194瀏覽

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

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn