sp_tables_ex (Transact-SQL)

返回有关指定链接服务器中表的信息。

主题链接图标Transact-SQL 语法约定

语法

sp_tables_ex [ @table_server = ] 'table_server' 
     [ , [ @table_name = ] 'table_name' ] 
     [ , [ @table_schema = ] 'table_schema' ]
     [ , [ @table_catalog = ] 'table_catalog' ] 
     [ , [ @table_type = ] 'table_type' ] 
     [ , [@fUsePattern = ] 'fUsePattern' ]

参数

  • [ @table_server= ] 'table_server'
    要为其返回表信息的链接服务器的名称。table_server 的数据类型为 sysname,无默认值。

  • [ , [ @table_name= ] 'table_name']
    要为其返回数据类型信息的表的名称。table_name的数据类型为 sysname,默认值为 NULL。

  • [ @table_schema= ] 'table_schema']
    表架构。table_schema的数据类型为 sysname,默认值为 NULL。

  • [ @table_catalog= ] 'table_catalog'
    指定的 table_name 所在数据库的名称。table_catalog 的数据类型为 sysname,默认值为 NULL。

  • [ @table_type= ] 'table_type'
    要返回的表的类型。table_type 的数据类型为 sysname,默认值为 NULL,可以是下列值之一。

    说明

    ALIAS

    别名。

    GLOBAL TEMPORARY

    系统范围内可用的临时表的名称。

    LOCAL TEMPORARY

    只限当前任务可用的临时表的名称。

    SYNONYM

    同义词的名称。

    SYSTEM TABLE

    系统表的名称。

    SYSTEM VIEW

    系统视图的名称。

    TABLE

    用户表的名称。

    VIEW

    视图的名称。

  • [ @fUsePattern= ] 'fUsePattern'
    确定字符 _%[] 是否解释为通配符。有效值为 0(模式匹配为关闭状态)和 1(模式匹配为打开状态)。fUsePattern 的数据类型为 bit,默认值为 1。

返回代码值

结果集

列名

数据类型

说明

TABLE_CAT

sysname

表限定符名称。多种 DBMS 产品支持表的三部分命名方式 (qualifier.owner.name)。在 SQL Server 2008 中,此列表示数据库名称。在某些其他产品中,该列表示表的数据库环境的服务器名。此字段可以为 NULL。

TABLE_SCHEM

sysname

表所有者名称。在 SQL Server 中,此列表示创建该表的数据库用户的名称。此字段始终返回值。

TABLE_NAME

sysname

表名。此字段始终返回值。

TABLE_TYPE

varchar(32)

表、系统表或视图。

REMARKS

varchar(254)

SQL Server 不为此列返回值。

注释

通过查询与 table_server 对应的 OLE DB 访问接口的 IDBSchemaRowset 接口的 TABLES 行集,执行 sp_tables_ex。table_name、table_schema、table_catalog 和 column 等参数传递到该接口以限制返回的行。

如果指定的链接服务器的 OLE DB 访问接口不支持 IDBSchemaRowset 接口的 TABLES 行集,则 sp_tables_ex 返回一个空的结果集。

权限

需要对架构的 SELECT 权限。

示例

以下示例返回有关 LONDON2 链接服务器上 AdventureWorks 数据库中 HumanResources 架构包含的有关表的信息。

EXEC sp_tables_ex @table_server = 'LONDON2', 
@table_catalog = 'AdventureWorks', 
@table_schema = 'HumanResources', 
@table_type = 'TABLE'