odbc_tables

Get the list of table names stored in a specific data source

&reftitle.description; ``resource``false```odbc_tables` `resource` `odbc` ``string``null```catalog`&null; ``string``null```schema`&null; ``string``null```table`&null; ``string``null```types`&null;

Lists all tables in the requested range.

To support enumeration of qualifiers, owners, and table types, the following special semantics for the `catalog`, `schema`, `table`, and `table_type` are available:

- If `catalog` is a single percent character (%) and `schema` and `table` are empty strings, then the result set contains a list of valid qualifiers for the data source. (All columns except the TABLE_QUALIFIER column contain NULLs.)

- If `schema` is a single percent character (%) and `catalog` and `table` are empty strings, then the result set contains a list of valid owners for the data source. (All columns except the TABLE_OWNER column contain NULLs.)

- If `table_type` is a single percent character (%) and `catalog`, `schema` and `table` are empty strings, then the result set contains a list of valid table types for the data source. (All columns except the TABLE_TYPE column contain NULLs.)

&reftitle.parameters;

`odbc`

- &odbc.connection.id;

`catalog`

- &odbc.parameter.catalog;

`schema`

- &odbc.parameter.schema; &odbc.parameter.search;

`table`

- The name. &odbc.parameter.search;

`types`

- If `table_type` is not an empty string, it must contain a list of comma-separated values for the types of interest; each value may be enclosed in single quotes (`'`) or unquoted. For example, `'TABLE','VIEW'` or `TABLE, VIEW`. If the data source does not support a specified table type, `odbc_tables` does not return any results for that type.

&reftitle.returnvalues;

Returns an ODBC result identifier containing the information &return.falseforfailure;.

The result set has the following columns:

- `TABLE_CAT`

- `TABLE_SCHEM`

- `TABLE_NAME`

- `TABLE_TYPE`

- `REMARKS`

&odbc.result.driver-specific;

The result set is ordered by `TABLE_TYPE`, `TABLE_CAT`, `TABLE_SCHEM` and `TABLE_NAME`.

&reftitle.changelog;

&Version; | &Description;
8.0.0 | `schema`, `table` and `types` are now nullable.

&reftitle.examples;

### List Tables in a Catalog

    <?php
    $conn = odbc_connect($dsn, $user, $pass);
    $tables = odbc_tables($conn, 'SalesOrders', 'dbo', '%', 'TABLE');
    while (($row = odbc_fetch_array($tables))) {
        print_r($row);
        break; // further rows omitted for brevity
    }
    ?>

&example.outputs.similar;

    Array
    (
        [TABLE_CAT] => SalesOrders
        [TABLE_SCHEM] => dbo
        [TABLE_NAME] => Orders
        [TABLE_TYPE] => TABLE
        [REMARKS] =>
    )

&reftitle.seealso;

- `odbc_tableprivileges`
- `odbc_columns`
- `odbc_specialcolumns`
- `odbc_statistics`
- `odbc_procedures`