DESCRIBE

DESCRIBE is a SQL command used primarily in Oracle and MySQL databases. It provides metadata about a specific database table such as the names of columns, the data types of each column, and whether a column can contain NULL values.

Example

DESCRIBE Users;

Output

+--------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| username | varchar(100) | YES | | NULL | |
| email | varchar(100) | YES | | NULL | |
| password | varchar(100) | YES | | NULL | |
+--------------+--------------+------+-----+---------+----------------+

Explanation

The DESCRIBE statement in MySQL provides a summary of the metadata associated with a specified database table. Here, it describes the structure of the ‘Users’ table including details about each field or column such as name, data type, whether the field can accept null values, the key type, the default value, and any extra information.

Example

DESCRIBE employees;

Output

Name Null? Type
------------------------ -------- ----------------
EMPLOYEE_ID NOT NULL NUMBER(6)
FIRST_NAME VARCHAR2(20)
LAST_NAME NOT NULL VARCHAR2(25)
EMAIL NOT NULL VARCHAR2(25)
PHONE_NUMBER VARCHAR2(20)
HIRE_DATE NOT NULL DATE
JOB_ID NOT NULL VARCHAR2(10)
SALARY NUMBER(8,2)
COMMISSION_PCT NUMBER(2,2)
MANAGER_ID NUMBER(6)
DEPARTMENT_ID NUMBER(4)

Explanation

The DESCRIBE command in the Oracle SQL displays the structure of a table including columns’ names, their type, and whether they can be null or not. In this example, the DESCRIBE employees; command provides the details of the employees table structure.

For in-depth explanations and examples SQL keywords where you write your SQL, install our extension.