DESCRIBE statement [Interactive SQL]

The DESCRIBE statement returns information about a given database object.

Syntax 1 - Describing database objects
DESCRIBE [ [ INDEX FOR ] TABLE | PROCEDURE ] [ owner.]object-name
 object-name: table, view, materialized view, procedure, or function
Syntax 2 - Describing the current connection
DESCRIBE CONNECTION
Parameters
  • INDEX FOR clause   Indicates that you want to see the indexes for the specified object-name.

  • TABLE clause   Indicates that object-name to be described is a table or a view.

  • PROCEDURE clause   Indicates that object-name is a procedure or a function.

Remarks

Use DESCRIBE TABLE to list all of the columns in the specified table or view. The DESCRIBE TABLE statement returns one row per table column, containing:

  • Column   The name of the column.

  • Type   The type of data in the column.

  • Nullable   Whether nulls are allowed (1=yes, 0=no).

  • Primary Key   Whether the column is in the primary key (1=yes, 0=no).

Use DESCRIBE INDEX FOR TABLE to list all of the indexes for the specified table. The DESCRIBE TABLE statement returns one row per index, containing:

  • Index Name   The name of the index.

  • Columns   The columns in the index.

  • Unique   Whether the index is unique (1=yes, 0=no).

  • Type   The type of index. Possible values are: Clustered, Statistic, Hashed, and Other.

Use DESCRIBE PROCEDURE to list all of the parameters used by the specified procedure or function. The DESCRIBE PROCEDURE statement returns one row for each parameter, containing:

  • Parameter   The name of the parameter.

  • Type   The data type of the parameter.

  • In/Out   Information about what is passed to, or returned from, the parameter. Possible values are:

    • In   The parameter is passed to the procedure, but is not modified.

    • Out   The procedure ignores the parameter's initial value and sets its value when the procedure returns.

    • In/Out   The parameter is passed to the procedure and the procedure sets the parameter's value when the procedure returns.

    • Result   The parameter returns a result set.

    • Return   The parameter returns a declared return value.

If you do not specify either TABLE or PROCEDURE (for example, DESCRIBE object-name), Interactive SQL assumes the object is a table. However, if no such table exists, Interactive SQL attempts to describe the object as either a procedure or a function.

Use Syntax 2 to list information about the database or database server that Interactive SQL is connected to. The following properties are returned:

  • Database Product   The name and version number of the database product Interactive SQL is connected to (for example, SQL Anywhere 11.0.0.83).

  • Host Name   The network name of the computer the database server is running on.

  • Host TCP/IP Address   The IP address of the computer the database server is running on.

  • Host Operating System   The name and version number of the operating system used by the computer the database server is running on.

  • Server Name   The name of the database server.

  • Server TCP/IP Port   The port number used by the database server for the current connection.

  • Database Name   The name of the database that Interactive SQL is connected to.

  • Database Character Set   The character set used for CHAR columns in the database.

  • Connection String   The connection string that was used to connect to the database or database server. Three asterisks replace passwords.

Properties that do not apply to the current connection are omitted. For example, if you connect to a database server using shared memory, then the TCP/IP port is omitted.

Permissions

None

Side effects

None

See also
Standards and compatibility
  • SQL/2003   Vendor extension.

Examples

Describe the columns in the Departments table:

DESCRIBE TABLE Departments;

Here is an example of the result set for this statement:

Column Type Nullable Primary key
DepartmentID integer 0 1
DepartmentName char(40) 0 0
DepartmentHeadID integer 0 0

List the indexes for the Customers table:

DESCRIBE INDEX FOR TABLE Customers;

Here is an example of the results for this statement:

Index Name Columns Unique Type
IX_customer_name Surname,GivenName 0 Clustered