Inserting, Updating, and Removing Records in MySQL
MySQL·3 min read·Jan 1, 2025
Displaying the structure of a table
In order to be able to insert, update, or delete records into and from a table, it is important to understand its composition and attributes.
To quickly display information about the structure of a table, including its attributes names, data types, lengths, nullable constraints, and default values, you can use the DESCRIBE keyword:
DESCRIBE table_name;Example
This SQL statement will describe the structure of the contracts table:
mysql> DESCRIBE contracts;+---------------+----------------------------+------+-----+---------+----------------+| Field | Type | Null | Key | Default | Extra |+---------------+----------------------------+------+-----+---------+----------------+| id | int | NO | PRI | NULL | auto_increment || contract_name | varchar(255) | NO | | NULL | || employee_id | int | NO | MUL | NULL | || start_date | date | NO | | NULL | || end_date | date | YES | | NULL | || status | enum('Active','Completed') | NO | | Active | || budget | int | YES | | NULL | |+---------------+----------------------------+------+-----+---------+----------------+