Premium lesson

Inserting, Updating, and Removing Records in MySQL

MySQL·5 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    |                |+---------------+----------------------------+------+-----+---------+----------------+
icon light bulb key

Unlock the Build RESTful APIs in Node.js module

Learn how to build real database-backed and framework-powered RESTful APIs with MySQL, Sequelize, and Express.

You get immediate access to:

  • 37 focused lessons across MySQL, Sequelize, backend, and Express
  • 4 real-world projects with commented solutions
  • Ongoing updates to this bundle
  • Lifetime access to this bundle
Unlock this module