Open In App
Related Articles

SQL | DESCRIBE Statement

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

Prerequisite: SQL Create Clause

As the name suggests, DESCRIBE is used to describe something. Since in a database, we have tables, that’s why do we use DESCRIBE or DESC(both are the same) commands to describe the structure of a table.

 Syntax:

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 4 columns named id, name, email, and age and all are of can contain null values. 

Query:

CREATE TABLE users (
  id INT PRIMARY KEY,
  name VARCHAR(50),
  email VARCHAR(100),
  age INT
);

DESC users;

Output:

 

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 the table is shown in the describe tab of the Database System Software.

So desc or describe command shows the structure of the table which include the name of the column, the data type of the column and the nullability which means, that column can contain null values or not.

All of these features of the table are described at the time of Creation of the table.

Creating a Table or Defining the Structure of a Table

Query:

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. 

Demonstrate DESC 

Step 1: Defining the structure of the table.

Creating a table:

create table one
(
 id int not null,
 name char(25),
 city varchar2(25)
)

Step 2: Displaying the structure of the table:

Table:

DESC one
  OR
DESCRIBE one

Output:

IMG5

 

Note: Here above ID column is of not null type and rest 2 columns can contain null values. Note: You have to execute the 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 References: Oracle.com 


Last Updated : 10 May, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads