- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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)
- Related Articles
- How can I get the list of columns from a table in the other database than we are currently using?
- How can I get the list of columns from a table in the other database than we\nare currently using IN operator?
- How can I check the list of MySQL tables, in a different database than we are using currently, along with table type in the result set?
- How can I check the list of MySQL tables, in a different database than we are using currently, along with table type in the result set using IN operator?
- How can I see the constraints which are applied to a table stored in the database I am currently using?
- How can I see the constraints which are applied to a table stored in another database then I am currently using?
- How can we get a list of columns in an existing MySQL table?
- How can we list all the columns of a MySQL view as we can list the columns of a MySQL table?
- How can I check the list of MySQL tables, in the current database we are using, along with table type in the result set?
- How can we get the list of tables in a particular database from MySQL Server command line?
- How can we create a table from an existing MySQL table in the database?
- How to can I get the names of my MySQL table columns?
- How can we write PHP script to get the list of MySQL database?
- How can we display a list of currently existing MySQL databases on the server?
- How can we check the list of all triggers in a database?

Advertisements