Home  >  Article  >  Database  >  oracle&&Sqlserver获取表名列名主键及数据类型

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

WBOY
WBOYOriginal
2016-06-07 15:44:321202browse

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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn