Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 17 » SQL Anywhere Server - SQL Reference » SQL statements » Alphabetical list of SQL statements

DESCRIBE statement [Interactive SQL]

Returns information about a given database object.

Syntax
  • Describe database objects
    DESCRIBE [ [ INDEX FOR ] TABLE | PROCEDURE ] [ owner.]object-name
     object-name : 
    table
    | view
    | materialized view
    | procedure
    | function
  • Describe 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 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 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 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.

When using DESCRIBE PROCEDURE, the returned parameter list is retrieved from the SYSPROCPARM system view.

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 the DESCRIBE statement 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 17.0.4.1691).

  • 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.

Privileges

None

Side effects

None

Standards
  • ANSI/ISO SQL Standard

    Not in the standard.

Example

Describe the columns in the Departments table:

DESCRIBE TABLE GROUPO.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 1 0

List the indexes for the Customers table:

DESCRIBE INDEX FOR TABLE GROUPO.Customers;

Here is an example of the results for this statement:

Index Name Columns Unique Type
IX_customer_name Surname,GivenName 0 Clustered