欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

sql查询查所有表名(table) SQLOracle 

程序员文章站 2022-07-12 23:38:12
...

(1)
select * from information_schema.tables
(2)
select name from dbo.sysobjects where xtype='u' and (not name LIKE 'dtproperties')
(3)
SELECT dbo.sysobjects.name as Table_name, dbo.syscolumns.name AS Column_name
FROM dbo.syscolumns INNER JOIN
      dbo.sysobjects ON dbo.syscolumns.id = dbo.sysobjects.id
WHERE dbo.sysobjects.name='TM_User'and (dbo.sysobjects.xtype = 'u') AND (NOT (dbo.sysobjects.name LIKE 'dtproperties'))
(4)
declare @str varchar(100)
set @str='1'  --要搜索的字符串
declare @s varchar(8000)
declare tb cursor local for
select s='if exists(select 1 from ['+b.name+'] where convert(varchar,['+a.name+']) like ''%'+@str+'%'')
print ''select top 5 ['+a.name+'],* from ['+b.name+']'''
from syscolumns a join sysobjects b on a.id=b.id
where b.xtype='U' and a.status>=0
--所查列的字段类型
and a.xusertype in(175,239,231,167,56,60,108,106)
open tb
fetch next from tb into @s
while @@fetch_status=0
begin
exec(@s)
fetch next from tb into @s
end
close tb
deallocate tb
(5)
Oracle版:
列出当前DB中所有表:
select table_name from user_all_tables
列出表中所有字段:
SELECT column_name from user_tab_columns where table_name='EDL_TM_User')

相关标签: SQL Oracle