In a Database Management System (DBMS), tables are created with specific columns, data types, and constraints. Sometimes it is necessary to view the structure of a table to understand its columns and properties.
The DESCRIBE command is used to display the structure of a table, including column names, data types, and other details. This command helps users quickly understand how a table is designed.
The DESCRIBE command is used to display the structure of a table in a database, including information about its columns, data types, null values, keys, default values, and extra properties.
In MySQL, the DESCRIBE command can also be written in short form as DESC.
DESCRIBE table_name;
or
DESC table_name;
When the DESCRIBE command is executed:
First select a database:
USE student_db;
Now describe the table:
DESCRIBE students;
| Field | Type | Null | Key | Default | Extra |
|---|---|---|---|---|---|
| id | int | NO | PRI | NULL | auto_increment |
| name | varchar(50) | YES | NULL | ||
| age | int | YES | NULL | ||
| course | varchar(50) | YES | NULL |
| Column | Description |
|---|---|
| Field | Name of the column in the table |
| Type | Data type of the column |
| Null | Indicates whether the column can store NULL values |
| Key | Shows if the column is a key (PRI for Primary Key) |
| Default | Default value assigned to the column |
| Extra | Additional information such as auto_increment |
The DESCRIBE command is commonly used for:
DESCRIBE shows the structure of a table.DESC is the short form of DESCRIBE.The DESCRIBE command is used to display the structure of a table in a database. It provides detailed information about columns, data types, and constraints. This command is very useful for understanding how a table is organized before performing operations such as inserting or retrieving data.