SHOW COLUMNS
Enterprise command reference.
Command Snapshot
| Field | Value |
|---|---|
| Category | DDL and Administration |
| Mutates Data | No |
| Scope | Statement |
| Privilege Model | Requires DDL/administrative privilege according to target object scope. |
Purpose
Executes the SHOW COLUMNS SQL command with MonkDB distributed runtime semantics.
Syntax
SHOW COLUMNS { FROM | IN } table_name [ { FROM | IN } table_schema ] [ LIKE 'pattern' | WHERE expression ]
Operational Notes
- Use schema-qualified identifiers in automation and automation pipelines.
- Validate behavior in staging for cluster-impacting or governance-impacting changes.
- Confirm runtime effects through system tables and metrics before and after execution.
When to Use
- Use during planned schema and runtime administration changes.
- Use in automation pipelines with environment-specific validation and rollback strategy.
When Not to Use
- Avoid during incident windows unless the command is part of approved mitigation.
- Avoid schema changes in peak traffic windows without staged rollout.
Common Errors and Troubleshooting
| Symptom | Likely Cause | Action |
|---|---|---|
| Permission denied / unauthorized | Missing privilege on object or cluster scope | Re-run with required grants or elevated admin role. |
| Analysis/parse error | Syntax variant or object shape mismatch | Compare with canonical syntax and object definition. |
| Runtime failure under load | Resource limits, breaker pressure, or node state transitions | Check sys.jobs, sys.operations, sys.checks, and retry after mitigation. |
Cross-References
Detailed Reference
The SHOW COLUMNS command is commonly used across SQL-based databases, including MonkDB, MySQL, and others, to retrieve metadata about the columns of a specified table. Below is a detailed breakdown of its usage, syntax, parameters, and clauses.
SQL Statement
SHOW COLUMNS { FROM | IN } table_name [ { FROM | IN } table_schema ] [ LIKE 'pattern' | WHERE expression ]
Description
The SHOW COLUMNS command fetches metadata about the columns of a specified table. It provides information such as:
- Column names
- Data types
- Nullability
- Keys (e.g., primary or foreign keys)
- Default values
- Additional attributes (e.g., auto-increment)
Columns are typically displayed in alphabetical order. If more detailed information is required, querying the information_schema.columns table is recommended.
Parameters
table_name: Specifies the name of the table whose column information is to be retrieved.table_schema: Specifies the schema containing the table. If omitted, the default schema (e.g., doc) is used.
Clauses
LIKE Clause
The LIKE clause filters column names based on a string pattern. For example
SHOW COLUMNS FROM table_name LIKE 'prefix%';
This retrieves columns whose names start with prefix..
WHERE Clause
The WHERE clause allows filtering based on more complex conditions. For example
SHOW COLUMNS FROM table_name WHERE data_type = 'VARCHAR';
This retrieves only columns with a VARCHAR data type.
Examples
Basic Usage
Retrieve all columns from a table
SHOW COLUMNS FROM customers;
Specifying Schema
Retrieve columns from a specific schema
SHOW COLUMNS FROM customers IN monkdb;
Using LIKE Clause and filter columns by name pattern
SHOW COLUMNS FROM orders LIKE 'order_%';
Using WHERE Clause and filter columns based on conditions
SHOW COLUMNS FROM payments WHERE data_type = 'DECIMAL';
Example Output
+-------------+----------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+----------+------+-----+---------+----------------+ | ID | int(11) | NO | PRI | NULL | auto_increment | | Name | char(35) | NO | | | | | Population | int(11) | NO | | 0 | | +-------------+----------+------+-----+---------+----------------+