在 SQL Server 2012 中,我正在使用
USE myDatabase;
GO
SELECT *
FROM sys.objects
WHERE type = 'U';
在 Sybase 中是否可以实现相同的操作?
要获取当前数据库中所有表的列表,您可以按类型 = 'U' 过滤sysobjects表,例如:
select convert(varchar(30),o.name) AS table_name
from sysobjects o
where type = 'U'
order by table_name
更多参考资料
以下是获取 MSSQL
或 SQL Server 数据库
中所有表名称的示例:
USE test; //SELECT DATABASE
SELECT table_name FROM information_schema.tables WHERE table_type = 'base table'
或者你可以使用sys.tables从所选数据库中获取所有表名,如下所示的SQL查询:
或者您可以使用sys.tables从所选的数据库中获取所有表名,如下所示的SQL查询
USE test; //SELECT DATABASE
SELECT * FROM sys.tables
这就是如何在 SQL Server 中查找所有表名的全部内容。
select * from sys.SYSTABLE
select convert(varchar(30),o.name) AS table_name,
row_count(db_id(), o.id) AS row_count
from sysobjects o
where type = 'U'
order by table_name
table_name
需要替换为您所需的名称。select convert(varchar(30),o.name) AS table_name,
row_count(db_id(), o.id) AS row_count
from sysobjects o
where type = 'U' and o.name like '%table_name%'
order by table_name