MySQL Show Table Columns

Profile picture for user arilio666

In MySQL, the most effective way to get the list of columns from a table is using the SHOW COLUMNS command.

Syntax

SHOW COLUMNS FROM table_name;

To make the list of columns appear before us, we have to specify the desired table name using the FROM clause of the SHOW COLUMNS.

MySQL show columns from all tables

Let us play around with the actor table from the sakila database.

Let us specify the database where the actor table is in using IN clause.

SHOW COLUMNS FROM actor IN sakila;

We can see from the output that it displays the number of columns in it and their other information.

Show complete column record in MySQL

To get the complete information from the table, we can use the FULL keyword; this displays the complete information of the columns from the table.

SHOW FULL COLUMNS FROM actor;

We can see additional information from the actor table.

MySQL show columns like

There is also an option to use pattern and expression to list information's starting letters.

SHOW COLUMNS FROM actor LIKE 'l%';

Conclusion:

So this is how we can use the show column command in MySQL.

Tags