- 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
Display all fields of a table in MySQL?
To display all fields, set the database with table_schema and specific table with table_name as in the below syntax −
select column_name as anyAliasName from information_schema.columns where table_schema=database() and table_name=’yourTableName’\G
Let us first create a table −
mysql> create table DemoTable1938 ( StudentId int, StudentName varchar(20), StudentAge int, StudentCountryName varchar(20), StudentMobileNumber bigint ); Query OK, 0 rows affected (0.00 sec)
Here is the query to display all fields of a table −
mysql> select column_name as ALL_FIELDS from information_schema.columns where table_schema=database() and table_name='DemoTable1938'\G
This will produce the following output −
*************************** 1. row *************************** ALL_FIELDS: StudentId *************************** 2. row *************************** ALL_FIELDS: StudentName *************************** 3. row *************************** ALL_FIELDS: StudentAge *************************** 4. row *************************** ALL_FIELDS: StudentCountryName *************************** 5. row *************************** ALL_FIELDS: StudentMobileNumber 5 rows in set (0.00 sec)
- Related Articles
- MySQL query to display all the fields that contain a capital letter?
- How to display all constraints on a table in MySQL?
- Get number of fields in MySQL table?
- Update all the fields in a table with null or non-null values with MySQL
- Checking all the list of fields for a table in SAP HANA
- Remove first two characters of all fields in MySQL?
- Display result of a table into a temp table with MySQL?
- Display all products having the highest amount in a MySQL table with product details?
- Get the count of two table fields in a single MySQL query?
- How to display the bit(1) fields in MySQL?
- MySQL query to display structure of a table
- Display all grants of a specific user in MySQL
- Copy all rows of a table to another table in MySQL?
- How to display the Engine of a MySQL table?
- MongoDB query to display all the fields value, except _id

Advertisements