Loading Page Content...
Preparing courses, live labs, and learning resources.सामग्री लोड हो रही है, कृपया प्रतीक्षा करें...
Preparing courses, live labs, and learning resources.सामग्री लोड हो रही है, कृपया प्रतीक्षा करें...
When stepping into a new company or taking over an existing codebase, you rarely start with a clean slate. You must inspect existing database schemas, verify column data types, check nullability, examine default values, and review exact table definitions. MySQL provides three essential introspection commands: SHOW TABLES, DESCRIBE, and SHOW CREATE TABLE.
SHOW TABLES)To view all tables, views, and sequence objects in your active database:
DESCRIBEThe DESCRIBE statement (shorthand: DESC) gives a structured overview of a table's columns:
DESCRIBE Output:+----------------+------------------------------------------------+------+-----+-------------------+-----------------------------------------------+
| Field | Type | Null | Key | Default | Extra |
+----------------+------------------------------------------------+------+-----+-------------------+-----------------------------------------------+
| customer_id | int unsigned | NO | PRI | NULL | auto_increment |
| first_name | varchar(50) | NO | | NULL | |
| email | varchar(255) | NO | UNI | NULL | |
| account_status | enum('Active','Suspended','Pending_Verificati')| NO | | Pending_Verificati| |
| created_at | timestamp | NO | | CURRENT_TIMESTAMP | DEFAULT_GENERATED |
| updated_at | timestamp | NO | | CURRENT_TIMESTAMP | DEFAULT_GENERATED on update CURRENT_TIMESTAMP |
+----------------+------------------------------------------------+------+-----+-------------------+-----------------------------------------------+NULL values (YES or NO).PRI: Primary Key.UNI: Unique Key constraint.MUL: Multiple (non-unique index, or the first column of a composite index).auto_increment or on update CURRENT_TIMESTAMP.SHOW CREATE TABLEWhile DESCRIBE shows a tabular summary, it does not reveal foreign key constraint definitions, storage engine settings, character sets, or index names. To see the exact SQL code required to recreate the table from scratch:
information_schema.COLUMNSFor automated tooling, ORMs, and reporting scripts, you can query column metadata using standard SQL:
\G with SHOW CREATE TABLE: In the MySQL CLI, always end SHOW CREATE TABLE with \G instead of a semicolon. This prevents ugly text wrapping and prints the DDL cleanly!MUL): A MUL key in DESC output signifies that the column is indexed, but allows duplicate values. It is commonly found on foreign key columns.DESCRIBE table_name; in MySQL?DESCRIBE customers;, what does the value PRI in the Key column signify?MUL indicator in the Key column of DESCRIBE output mean?information_schema contains exhaustive metadata for every column across all database tables?Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
| Previous Lesson | Next Lesson |
|---|---|
| Creating Tables Syntax & Rules | Modifying Tables with ALTER TABLE |
Test your understanding of this lesson with 5 questions. Each question has one correct answer.