Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
How can I get the list of columns from a table in the database we are currently using?
It can be done with the SHOW COLUMNS statement. Its Syntax would be as follows −
Syntax
SHOW COLUMNS FROM tab_name
Here tab_name is the name of the table from which we want to see the list of columns.
Example
In the example we are getting the list of columns from a table named Student_info −
mysql> SHOW COLUMNS FROM Student_info\G *************************** 1. row *************************** Field: studentid Type: int(11) Null: YES Key: Default: NULL Extra: *************************** 2. row *************************** Field: Name Type: varchar(40) Null: YES Key: Default: NULL Extra: *************************** 3. row *************************** Field: Address Type: varchar(20) Null: YES Key: Default: NULL Extra: *************************** 4. row *************************** Field: Subject Type: varchar(20) Null: YES Key: Default: NULL Extra: 4 rows in set (0.06 sec)
Advertisements
