Pages

Tuesday, July 23, 2013

How to Retrieve Table Names From a Database

How to Retrieve Table Names From a Database

All relational databases that store data are composed of tables. Visually, a table is a group of rows and columns; each column describes a specific unit of data and each row contains the data itself. Tables are uniquely named within a database, ideally in a way that describes the data stored in the table. If the table names in a database are unclear, unknown or inconsistent, administrators may need to list the tables in order to use them. Most commonly used databases provide commands that allow users to list the tables they house.

Instructions

Retrieving Table Names From a MySQL Database

    1

    Run the MySQL command line utility and connect to MySQL.

    2

    Indicate the database you want to work with, where "database" is the MySQL database that contains the tables you want to list.

    mysql>use "database";

    3

    List the tables using the "show tables" command.

    mysql>list tables;

Retrieving Table Names From an Oracle Express Database

    4

    Run the SQL*Plus command line utility and connect to Oracle Express.

    5

    Determine which schema contains the tables you want to list. Oracle stores groupings of tables as schemas that correspond to usernames.

    6

    List the tables by querying the ALL_TABLES table, where 'USERNAME' is the schema that contains the group of tables you want to list.

    SQL>select table_name from all_tables where owner='USERNAME';

Retrieving Table Names from a SQL Server Express Database

    7

    Run the sqlcmd command line utility and connect to SQL Server Express.

    8

    Indicate the database you want to work with, where "database" is the SQL Server Express database that contains the sysobjects table you want to query.

    1>use "database"

    2>GO

    9

    List the tables in the database by running a query against the sysobjects system table. The xtype='U' indicates that the query should list only table objects.

    1>select name from sysobjects where xtype='U'

    2>GO

0 comments:

Post a Comment