How do I view the structure of a table in SQL?

The DESCRIBE (or DESC) command in SQL is used to display the structure of a table, including column names, data types, and constraints. It's a fundamental tool for understanding table schemas and quickly inspecting data.

Sign up for the latest in SQL knowledge from the Galaxy Team!
Welcome to the Galaxy, Guardian!
Oops! Something went wrong while submitting the form.

Description

Table of Contents

The `DESCRIBE` (or `DESC`) command is a crucial part of database management. It allows you to quickly and easily see the structure of a table without having to manually look through documentation or create complex queries. This command is particularly useful when you're working with a new database or table, or when you need to refresh your memory about the structure of an existing table. It's a simple, yet powerful, tool for understanding the layout of your data. For example, if you're unsure about the data types of columns in a table, `DESCRIBE` provides this information directly. This command is often used in conjunction with other DDL (Data Definition Language) commands, such as `CREATE TABLE`, `ALTER TABLE`, and `DROP TABLE`, to manage and understand the structure of your database.

Why Desc SQL is important

Understanding table structures is fundamental to writing effective SQL queries. The `DESCRIBE` command provides this crucial information quickly, saving time and effort. It's essential for troubleshooting queries and ensuring data integrity.

Desc SQL Example Usage


-- Create a sample table
CREATE TABLE Customers (
    CustomerID INT PRIMARY KEY,
    FirstName VARCHAR(50),
    LastName VARCHAR(50),
    Email VARCHAR(100),
    City VARCHAR(50)
);

-- Describe the Customers table
DESCRIBE Customers;
-- or
DESC Customers;

Desc SQL Syntax



Common Mistakes

Frequently Asked Questions (FAQs)

What information does the DESCRIBE command show about a table?

`DESCRIBE` (or `DESC`) returns every column name alongside its data type, nullability, default value, and key information. In one quick glance you get the full blueprint of the table’s schema without digging through documentation or querying information_schema.

When is DESCRIBE most useful during day-to-day development?

The command is indispensable when you open an unfamiliar database, revisit a legacy table, or simply need to confirm a column’s data type before writing a JOIN, ALTER TABLE, or DROP COLUMN. Because it executes instantly, it’s the fastest way to refresh your memory on a table’s layout.

How does Galaxy improve the experience of using DESCRIBE and other DDL commands?

Galaxy’s lightning-fast SQL editor lets you run DESCRIBE with a single shortcut and shows a neatly formatted result grid. The context-aware AI copilot can then suggest follow-up queries—such as optimized ALTER TABLE statements or sample SELECTs—based on the schema it just analyzed. With Galaxy Collections, you can also endorse and share these vetted commands with teammates instead of pasting raw SQL into Slack.

Want to learn about other SQL terms?

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo
Welcome to the Galaxy, Guardian!
Oops! Something went wrong while submitting the form.