To show columns of a table in a database that is not the current database, you use the following form: SHOW COLUMNS FROM database_name.table_name Code language: SQL (Structured Query Language) ( sql ) To show the columns of a table, you specify the table name in the FROM clause of the SHOW COLUMNS statement. The more flexible way to get a list of columns in a table is to use the MySQL SHOW COLUMNS command. For example, the following statement is equivalent to the DESCRIBE above: DESC orders Ĭode language: SQL (Structured Query Language) ( sql ) MySQL SHOW COLUMNS command In practice, you use the DESC statement which is a shorthand of the DESCRIBE statement. | customerNumber | int(11) | NO | MUL | NULL | | | orderNumber | int(11) | NO | PRI | NULL | | | Field | Type | Null | Key | Default | Extra | Issue the USE command to switch to the database to classicmodels: mysql> USE classicmodels >mysql -u root -pĬode language: SQL (Structured Query Language) ( sql )
The following example demonstrates how to display columns of the orders table in the classicmodels database. To show all columns of a table, you use the following steps: