sp_tables

Description

Returns a list of objects stored in the database.

Syntax

sp_tables [table_name] [, table_owner]
 [, table_qualifier] [, table_type]

Parameters

table_name

is the name of the table. Use the wildcard character to request information about more than one table.

table_owner

is the owner of the table. Use the wildcard character to request information about tables owned by more than one user.

table_qualifier

is ignored. Leave empty or set to NULL.

table_type

is a list of values, separated by commas, requesting information about all objects of a specific type(s) as follows:

“‘TABLE’, ‘SYSTEM TABLE', ‘VIEW’, ‘ALIAS’, ‘SYNONYM’”

NoteYou must enclose each table type with single quotation marks, and enclose the entire parameter with double quotation marks. Enter table types in uppercase.

Usage


Results

sp_tables returns a list of database objects. Results are ordered by the following columns:

The lengths for varchar columns shown in the result set tables are maximums; the actual lengths depend on the target database.

Table 4-19 shows the result set for sp_tables:

Table 4-19: Result set for sp_tables

Column

Datatype

Description

TABLE_QUALIFIER

varchar(128)

Always NULL

TABLE_OWNER

varchar(128)

Table owner

TABLE_NAME

varchar(128)

Name of the object about which information is returned

TABLE_TYPE

varchar(128)

NOT NULL

One of the following:

  • ‘ALIAS’

  • ‘SYNONYM’

  • ‘SYSTEM TABLE’

  • ‘TABLE’

  • ‘VIEW’

REMARKS

varchar(254)

A description of the table or NULL