Prerequisite : Sql Create Clause,
As the name suggests, DESCRIBE is used to describe something. Since in database we have tables, that’s why we use DESCRIBE or DESC(both are same) command to describe the structure of a table.
DESCRIBE one; OR DESC one;
Note : We can use either DESCRIBE or DESC(both are Case Insensitive).
Suppose our table whose name is one has 3 columns named FIRST_NAME, LAST_NAME and SALARY and all are of can contain null values.
Name Null Type FIRST_NAME CHAR(25) LAST_NAME CHAR(25) SALARY NUMBER(6)
- Here, above on using DESC or either DESCRIBE we are able to see the structure of a table but not on the console tab, the structure of table is shown in the describe tab of the Database System Software.
- So desc or describe command shows the structure of table which include name of the column, data-type of column and the nullability which means, that column can contain null values or not.
- All of these features of table are described at the time of Creation of table.
Creating table or defining the structure of a table
create table one ( id int not null, name char(25) )
Here, we created a table whose name is one and its columns are ID, NAME and the id is of not null type i.e, we can’t put null values in the ID column but we can put null values in the NAME column.
Example to demonstrate DESC:
Step 1: Defining structure of table i.e, Creating a table:
create table one ( id int not null, name char(25), city varchar2(25) )
Step 2: Displaying the structure of table:
DESC one OR DESCRIBE one
Output: Name Null Type ID Not Null INT NAME CHAR(25) CITY VARCHAR2(25)
Note: Here above ID column is of not null type and rest 2 column can contain null values.
Note: You have to execute DESC command on your system software only, because this command won’t run on any editor. Make sure to run this command on your own installed Database only
This article is contributed by Rajat Rawat 4. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- SELECT INTO statement in SQL
- SQL | Case Statement
- SQL | INSERT INTO Statement
- SQL | DELETE Statement
- SQL | UPDATE Statement
- SQL | MERGE Statement
- MERGE Statement in SQL Explained
- SQL | INSERT IGNORE Statement
- MySQL | CREATE USER Statement
- Top 10 High Paying Jobs That Demand SQL
- Count the number of a special day between two dates by using PL/SQL
- MySQLi Procedural Functions
- MySQL | CONNECTION_ID( ) Function
- MySQL | CAST( ) Function