Pages

Tuesday 15 October 2013

Describe Command in SQL



           This is a SQL command used to display the structure of a table present in the database. 

General Form of DESCRIBE command:

              DESCRIBE tableName

           Consider the below example showing the use of DESCRIBE command to display the structure of  the employees table present in the database of my Oracle 10g express edition DB software.

               DESCRIBE employees

Output of above statement:


               
           You can see in above output only the internal structure of employees table is displayed. It shows different columns present in tables and the constraints, data-types of column, length of data-types etc. Here the data present in the table is not displayed but only the internal structure of the table is displayed.

          In some situation you will not be aware of the internal structure of a table. In such conditions the DESCRIBE command will be a great help to you. Consider that I have to display only a few columns present in the table say employees and its data. But am not aware how these columns are internally named for employees table present in a database. In such situation I can make use of DESCRIBE command. 

          Below you can see the use of SELECT statement used to display only two particular columns of  employees table and its data.

            select first_name, salary from employees

Note: SQL commands are not case sensitive.

Output of above statement: