mysql> show columns from tablename;
In MySQL, you can use the DESCRIBE
statement or the SHOW COLUMNS
statement to retrieve information about the columns of a table. Both commands provide details about the structure of a table.
- DESCRIBE statement:
sql
DESCRIBE your_table_name;
Example:
sqlDESCRIBE employees;
- SHOW COLUMNS statement:
sql
SHOW COLUMNS FROM your_table_name;
Example:
sqlSHOW COLUMNS FROM employees;
Both of these commands will return information about the columns, such as the column name, data type, whether it allows NULL values, key information, default values, and extra information (e.g., auto-increment). Choose either DESCRIBE
or SHOW COLUMNS
based on your preference; they essentially provide the same information.