欢迎投稿

今日深度:

sql查询查数据库中所有表名(table),

sql查询查数据库中所有表名(table),


(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')

www.htsjk.Com true http://www.htsjk.com/teradata/32899.html NewsArticle sql查询查数据库中所有表名(table), (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.n...
相关文章
    暂无相关文章
评论暂时关闭