码迷,mamicode.com
首页 > 数据库 > 详细

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

时间:2014-08-14 19:39:49      阅读:294      评论:0      收藏:0      [点我收藏+]

标签:io   数据   for   amp   sql   type   on   oracle   

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

oracle&&Sqlserver获取表名列名主键及数据类型,布布扣,bubuko.com

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

标签:io   数据   for   amp   sql   type   on   oracle   

原文地址:http://www.cnblogs.com/zlqblog/p/3912805.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!