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 firstname.lastname@example.org. 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.
- Difference between Structured Query Language (SQL) and Transact-SQL (T-SQL)
- SQL | INSERT INTO Statement
- SQL | DELETE Statement
- SQL | UPDATE Statement
- SQL | INSERT IGNORE Statement
- SQL | Case Statement
- SQL | MERGE Statement
- MERGE Statement in SQL Explained
- Delete statement in MS SQL Server
- Reverse Statement Word by Word in SQL server
- SELECT INTO statement in SQL
- Select statement in MS SQL Server
- Insert statement in MS SQL Server
- Insert Into Select statement in MS SQL Server
- CREATE and DROP INDEX Statement in SQL
- SQL | Procedures in PL/SQL
- SQL | Difference between functions and stored procedures in PL/SQL
- Difference between SQL and T-SQL
- MySQL | CREATE USER Statement
- Difference between Row level and Statement level triggers