Open In App

SQL | DESCRIBE Statement

Last Updated : 10 May, 2023
Improve
Improve
Like Article
Like
Save
Share
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 


Previous Article
Next Article

Similar Reads

Difference between Structured Query Language (SQL) and Transact-SQL (T-SQL)
Structured Query Language (SQL): Structured Query Language (SQL) has a specific design motive for defining, accessing and changement of data. It is considered as non-procedural, In that case the important elements and its results are first specified without taking care of the how they are computed. It is implemented over the database which is drive
2 min read
Configure SQL Jobs in SQL Server using T-SQL
In this article, we will learn how to configure SQL jobs in SQL Server using T-SQL. Also, we will discuss the parameters of SQL jobs in SQL Server using T-SQL in detail. Let's discuss it one by one. Introduction :SQL Server Agent is a component used for database task automation. For Example, If we need to perform index maintenance on Production ser
7 min read
Reverse Statement Word by Word in SQL server
To reverse any statement Word by Word in SQL server we could use the SUBSTRING function which allows us to extract and display the part of a string. Pre-requisite :SUBSTRING function Approach : Declared three variables (@Input, @Output, @Length) using the DECLARE statement. Use the WHILE Loop to iterate every character present in the @Input. For th
2 min read
Select statement in MS SQL Server
In this article, the most basic statement used in SQL is being discussed. Basic statement: select There are large amounts of data available everywhere. The data is stored in a sequential order in form of a table. Each table consists of a row which represents a unique record and column represents a field. Schemas are used to arrange the tables in a
2 min read
Insert statement in MS SQL Server
A database contains of many tables which has data stored in an order. To add up the rows, the user needs to use insert statement. Syntax : insert into table_name(column_list) values(values_list) For better understanding, an example is given below. Example - A table named student must have values inserted into it. It has to be done as follows: inser
2 min read
Insert Into Select statement in MS SQL Server
Prerequisites - Insert statement in MS SQL Server, Select statement in MS SQL Server Consider a university database. There are two tables namely Student and Marks. In case, the marks of a few students has to be transferred from the marks table to the marks table, there are many ways to do so. One can use subqueries (query nested in another query) b
2 min read
CREATE and DROP INDEX Statement in SQL
The CREATE INDEX statement will create indexes in tables. Indexes are used for data procurement from the databases faster. The users cannot see the indexes, they are running in the background of queries, used to speed up searches/queries. Create an index on a table : Syntax: CREATE INDEX indexname ON tablename (columnname1, columnname2, ...); Creat
2 min read
SQL Statement to Remove Part of a String
Here we will see SQL statements to remove part of the string. Method 1: Using SUBSTRING() and LEN() functionWe will use this method if we want to remove a part of the string whose position is known to us. 1. SUBSTRING(): This function is used to find a sub-string from the string from the given position. It takes three parameters: String: It is a re
3 min read
How to Update Multiple Columns in Single Update Statement in SQL?
In this article, we will see, how to update multiple columns in a single statement in SQL. We can update multiple columns by specifying multiple columns after the SET command in the UPDATE statement. The UPDATE statement is always followed by the SET command, it specifies the column where the update is required. UPDATE for Multiple ColumnsSyntax: U
3 min read
Multi-Statement Table Valued Function in SQL Server
In SQL Server, a multi-statement table-valued function (TVF) is a user-defined function that returns a table of rows and columns. Unlike a scalar function, which returns a single value, a TVF can return multiple rows and columns. Multi-statement function is very much similar to inline functions only difference is that in multi-statement function we
4 min read