在SQL Server上获得特定数据库中所有表的名称的最佳方法是什么?


当前回答

使用SELECT * FROM INFORMATION_SCHEMA。COLUMNS还显示所有表和相关列。

其他回答

--for oracle
select tablespace_name, table_name from all_tables;

这个链接可以提供更多的信息 主题

select * from sysobjects where xtype='U'

SELECT sobjects.name
FROM sysobjects sobjects
WHERE sobjects.xtype = 'U' 
exec sp_msforeachtable 'print ''?'''

你可以用sys。对象来获取所有数据库对象。

 GO
 select * from sys.objects where type_desc='USER_TABLE' order by name
 GO

OR

--  For all tables
select * from INFORMATION_SCHEMA.TABLES 
GO 

  --- For user defined tables
select * from INFORMATION_SCHEMA.TABLES where TABLE_TYPE='BASE TABLE'
GO

  --- For Views
select * from INFORMATION_SCHEMA.TABLES where TABLE_TYPE='VIEW'
GO