SQL Keywords

SQL DESCRIBE

What is SQL DESCRIBE?

Returns the column structure of a table or view, including names, data types, nullability, keys, and defaults.
Sign up to get up to date news on SQL keywords
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Compatible dialects for SQL DESCRIBE: Supported: MySQL, MariaDB, Oracle (SQL*Plus CLI). Not supported natively: PostgreSQL, SQL Server, SQLite, Snowflake, BigQuery.

SQL DESCRIBE Full Explanation

DESCRIBE (alias DESC) is a non-standard but popular SQL command that reveals a table or view's schema. When run, the database engine queries its system catalog and outputs one row per column, showing the column name, data type, whether NULL values are allowed, key information, default values, and additional metadata like auto-increment flags. Because DESCRIBE is read-only, it never changes data or schema; it only surfaces metadata. Note that DESCRIBE is not part of the ANSI SQL standard and is primarily implemented in MySQL, MariaDB, and Oracle SQL*Plus. Other systems offer similar functionality through proprietary commands (for example, \d in psql) or by querying INFORMATION_SCHEMA. Attempting to run DESCRIBE in an unsupported database returns a syntax error.

SQL DESCRIBE Syntax

DESCRIBE [database_name.]table_name;
-- or
DESC [database_name.]table_name;

SQL DESCRIBE Parameters

  • database_name (STRING) - Optional. Explicit database or schema that contains the table.
  • table_name (STRING) - Required. Name of the table or view to inspect.

Example Queries Using SQL DESCRIBE

-- Basic usage
DESCRIBE users;

-- With schema qualification
DESCRIBE analytics.events;

-- Alias form
DESC orders;

-- View description
DESC active_customers_view;

Expected Output Using SQL DESCRIBE

  • The server returns a result set with one row per column
  • In MySQL/MariaDB the columns are: Field, Type, Null, Key, Default, Extra
  • Users can scroll or fetch this result just like any SELECT output

Use Cases with SQL DESCRIBE

  • Quickly inspect a table before writing SELECT or INSERT statements
  • Verify data types and default values during development
  • Confirm primary keys and indexes when debugging queries
  • Teach newcomers the schema without granting INFORMATION_SCHEMA access

Common Mistakes with SQL DESCRIBE

  • Running DESCRIBE in PostgreSQL or SQL Server and receiving a syntax error
  • Forgetting to qualify the schema when multiple tables share the same name
  • Assuming DESCRIBE shows foreign key references; it only flags key columns, not full constraints
  • Misinterpreting ENUM display in the Type column as plain text rather than an enumerated set

Related Topics

SHOW COLUMNS, INFORMATION_SCHEMA.COLUMNS, EXPLAIN, SHOW TABLES, PRAGMA table_info (SQLite)

First Introduced In

MySQL 3.23 and Oracle SQL*Plus (circa 1980s)

Frequently Asked Questions

What databases support DESCRIBE?

MySQL, MariaDB, and Oracle's SQL*Plus CLI support DESCRIBE natively. Other databases require alternative commands.

Does DESCRIBE lock the table?

No. It only reads metadata from the system catalog and never acquires locks that block writes.

Can I filter the columns returned by DESCRIBE?

Not directly. Use SHOW COLUMNS LIKE 'pattern' or query INFORMATION_SCHEMA for granular filtering.

How do I get foreign key details?

DESCRIBE shows only whether a column participates in a key. To view full foreign key constraints, query INFORMATION_SCHEMA.KEY_COLUMN_USAGE or use SHOW CREATE TABLE.

Sign up to get up to date news on SQL keywords
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.
Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo

Check out other commonly used SQL Keywords!