日期:2014-05-16  浏览次数:20433 次

获得数据库中的所有表及某个表的所有字段
oracle实现:
得到指定库的所有表
select table_name from all_tables where trim(owner)='库名';
得到指定表的所有字段
select column_name from USER_TAB_COLUMNS where TABLE_NAME='表名';
ms sqlserver实现:
得到制定库的所有表
select name from sysobjects where type = 'u' order by name;
注:在哪一个库执行,便得到那个库的所有表。
得到指定表的所有字段
select name from syscolumns where id in (select id from sysobjects where type = 'u' and name = '表名')
db2实现:
得到指定用户的所有表
SELECT NAME FROM SYSIBM.SYSTABLES WHERE CREATOR = '用户名'
得到指定表的所有字段
SELECT NAME FROM SYSIBM.SYSCOLUMNS WHERE TBNAME = '表名'