Identifying Table and Column Names

SQL*Plus has two tools for finding out the names of the database tables and the names of the columns in the tables:

  • SELECT TNAME FROM TAB; This SELECT statement will list the table and view names for which you have access.

  • DESC (table name) or Describe (table name) Either version of the command displays the names, data types, and NOT NULL constraints of the columns contained in the table or view.

Identifying table and column names are two of the common tasks you will perform when using a database. If you don’t have a table relationship diagram, these tools will be very useful to you.

Listing 4.1 illustrates the use of the former command.

Listing 4.1. Displays Table Names
 SQL> select tname from tab; TNAME ------------------------------ ...

Get Oracle SQL and PL/SQL Handbook: A Guide for Data Administrators, Developers, and Business Analysts now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.