返回有关指定链接服务器中表的表信息。
[@table_server =] 'table_server'
[ , [ @table_name = ] 'table_name' ]
[ , [ @table_schema = ] 'table_schema' ]
[ , [ @table_catalog = ] 'table_catalog' ]
[ , [ @table_type = ] 'table_type' ]
[@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 | 系统表名。 |
TABLE | 用户表名。 |
VIEW | 视图名。 |
无
列名 | 数据类型 | 描述 |
---|---|---|
TABLE_CAT | sysname | 表限定符名称。多种 DBMS 产品支持表的三部分命名方式 (qualifier.owner.name)。在 SQL Server 中,该列表示数据库名。在某些产品中,该列表示表所在数据库环境的服务器名。该字段可以为 NULL。 |
TABLE_SCHEM | sysname | 表所有者名称。在 SQL Server 中,该列表示创建表的数据库用户的姓名。该字段始终返回值。 |
TABLE_NAME | sysname | 表名。该字段始终返回值。 |
TABLE_TYPE | varchar(32) | 表、系统表或视图。 |
REMARKS | varchar(254) | SQL Server 不为该列返回值。 |
执行 sp_tables_ex 时,将查询与 table_server 对应的 OLE DB 提供程序的 IDBSchemaRowset 接口的 TABLES 行集。table_name、table_schema、table_catalog 和 column 参数传递到此接口,用以限制返回的行。
如果指定的链接服务器的 OLE DB 提供程序不支持 IDBSchemaRowset 接口的 TABLES 行集,则 sp_tables_ex 返回一个空的结果集。
执行权限默认授予 public 角色。
下例返回链接服务器 LONDON2 上 pubs 数据库中的 titles 表的表信息。
USE master
EXEC sp_tables_ex 'LONDON2', 'titles', 'dbo', 'pubs', NULL