获取Oracle、SqlServer表名、主键值、属性名

发布时间:2021-06-06

//获取表名,列名
SELECT TOP 100 PERCENT AS e_table_name, AS e_column_name,
AS e_column_type
FROM dbo.sysobjects INNER JOIN
dbo.syscolumns ON dbo.sysobjects.id = dbo.syscolumns.id INNER JOIN
dbo.systypes ON dbo.syscolumns.xtype = dbo.systypes.xtype
where = 'info_bridge'
ORDER BY


/**
*获取主键
*/
select COLUMN_NAME = convert(sysname,)
from
sysindexes i, syscolumns c, sysobjects o
where o.id = object_id('[YourTableName]')
and o.id = c.id
and o.id = i.id
and (i.status & 0x800) = 0x800
and ( = index_col ('[YourTableName]', i.indid, 1) or
= index_col ('[YourTableName]', i.indid, 2) or
= index_col ('[YourTableName]', i.indid, 3) or
= index_col ('[YourTableName]', i.indid, 4) or
= index_col ('[YourTableName]', i.indid, 5) or
= index_col ('[YourTableName]', i.indid, 6) or
= index_col ('[YourTableName]', i.indid, 7) or
= index_col ('[YourTableName]', i.indid, 8) or
= index_col ('[YourTableName]', i.indid, 9) or
= index_col ('[YourTableName]', i.indid, 10) or
= index_col ('[YourTableName]', i.indid, 11) or
= index_col ('[YourTableName]', i.indid, 12) or
= index_col ('[YourTableName]', i.indid, 13) or
= index_col ('[YourTableName]', i.indid, 14) or
= index_col ('[YourTableName]', i.indid, 15) or
= index_col ('[YourTableName]', i.indid, 16)
)


declare @table_name as varchar(max)
set @table_name = '你的表名'
select , , sys.columns.max_length, sys.columns.is_nullable,
(select count(*) from sys.identity_columns where sys.identity_columns.object_id = sys.columns.object_id and sys.columns.column_id = sys.identity_columns.column_id) as is_identity ,
(select value from sys.extended_properties where sys.extended_properties.major_id = sys.columns.object_id and sys.extended_properties.minor_id = sys.columns.column_id) as description
from sys.columns, sys.tables, sys.types where sys.columns.object_id = sys.tables.object_id and sys.columns.system_type_id=sys.types.system_type_id and http://doc.guand
ang.net=@table_name order by sys.columns.column_id






一、oracle

1、获取当前oracle数据库中的所有表

select table_name from user_tables

2、查询某

获取Oracle、SqlServer表名、主键值、属性名.doc 将本文的Word文档下载到电脑

精彩图片

热门精选

大家正在看

× 游客快捷下载通道(下载后可以自由复制和排版)

限时特价:7 元/份 原价:20元

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219