10 / 13

How to get information about the table?

To retrieve entire information of a table, we use DESCRIBE, DESC or SHOW COLUMNS statements.

Syntax:
Filtering columns to be shown:
We can specify the name of the database along with the table name as shown in the query below
Usually, the information provided by the SHOW COLUMNS statements contains field type, can be null or not, key, default values and some extra details. If you use the full clause details like collation, privileges and comments will be added.
Difficulty: 2/10
Topics: metadata queries, information_schema, table inspection

Scenario Questions

0-2 years experience
  1. 1

    You're about to write an INSERT for a users table but aren't sure of the exact column names and types. What command do you run to check?

  2. 2

    A teammate claims the email column is VARCHAR(255) but you think it might be TEXT. How do you verify who's right without asking anyone else?

  3. 3

    You're reviewing a migration file and need to see the exact CREATE TABLE statement for the current orders table. What's the quickest way to get that?

2-5 years experience
  1. 1

    You're adding a composite index to a 50M-row events table in production. Before you run the ALTER, you need to confirm the existing indexes so you don't create a duplicate. How do you inspect them safely?

  2. 2

    A query on transactions is scanning the whole table. You suspect a missing index. Walk me through the exact commands you'd run to examine the table structure and current indexes, and what you'd look for.

  3. 3

    You're writing a deployment script that needs to conditionally add a column only if it doesn't exist. Would you use SHOW COLUMNS or query INFORMATION_SCHEMA.COLUMNS? Why?

5-8 years experience
  1. 1

    We're building an internal schema migration tool that runs across hundreds of databases. Compare using INFORMATION_SCHEMA vs SHOW commands for programmatic schema inspection — what are the tradeoffs in performance, consistency, and portability?

  2. 2

    During a zero-downtime migration, you need to verify table structure on read replicas without adding load to the primary. How do you safely inspect metadata, and what replication lag considerations apply?

  3. 3

    You're diagnosing a replication lag spike and suspect a table definition mismatch between primary and replica. What specific metadata would you compare, and how would you automate that check across a fleet?

8+ years experience
  1. 1

    We're standardizing schema inspection across 500+ databases running mixed MySQL 5.7 and 8.0. Design an approach that handles version differences in INFORMATION_SCHEMA (e.g., TABLES.TABLE_ROWS accuracy, new INNODB_TABLESPACES tables) without breaking existing tooling.

  2. 2

    Building a database governance platform that needs real-time schema change detection (DDL capture) across a fleet. How would you architect metadata collection without relying on polling INFORMATION_SCHEMA, and what MySQL features would you leverage?

  3. 3

    Migrating a fleet from MySQL 5.7 to 8.0 — what INFORMATION_SCHEMA changes (e.g., COLUMNS.EXTRA deprecation, new CHECK_CONSTRAINTS table) break existing inspection tooling, and how do you plan a phased rollout that keeps both versions operational?

Follow-up Questions

  • What's the practical difference between DESCRIBE and SHOW COLUMNS?
  • When would you choose INFORMATION_SCHEMA over SHOW commands?
  • How do you get foreign key definitions for a table?