Last Updated: 28 May, 2023
In MySQL, we can display all the columns of a table.
MySQL has provided two ways to display all the columns of table:
The SHOW COLUMNS statement is use with table for display information about the columns. It also works for views. We can only view information for those columns for which we have privileges.
The syntax and example for the SHOW COLUMNS statement are as follows:
Syntax:
SHOW COLUMNS FROM table_name;
After running this statement, we will get a result set that includes information about each column in the table, such as the column name, data type, default value, whether the column can be null or not, and other attributes.
Example:
SHOW COUMNS FROM student;
The DESCRIBE statement in MySQL is used to obtain information about the structure of a table or a view. It provides details about the columns in the table, such as the name, data type, length, and whether the column can allow null values.
The DESCRIBE statement provides information similar to SHOW COLUMNS.
The syntax for using the DESCRIBE command is as follows:
Syntax:
DESCRIBE table_name;
After running this statement, we will get a result set that includes information about each column in the table, such as the column name, data type, default value, whether the column can be null or not, and other attributes.
Example:
DESCRIBE student;
Additionally, we can use the DESCRIBE command with a wildcard character to get information about multiple tables at once. For example, to get the structure of all tables that start with the letter 's', we can use the following command:
Example:
DESCRIBE s%;
That's all, guys. I hope this MySQL article is helpful for you.
Happy Learning... 😀
feedback@javabytechie.com