Sql Server版:
列出当前DB中所有表:
select name from dbo.sysobjects where xtype='u' and (not name LIKE 'dtproperties')
列出表中所有字段:
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'))
Oracle版:
列出当前DB中所有表:
select table_name from user_all_tables
列出表中所有字段:
SELECT column_name from user_tab_columns where table_name='EDL_TM_User')
本文提供了在SqlServer和Oracle数据库中查询所有表名及指定表的所有字段的方法。对于SqlServer, 使用sysobjects和syscolumns系统表进行查询;对于Oracle, 则使用user_all_tables和user_tab_columns视图。
1745

被折叠的 条评论
为什么被折叠?



