ghalib ghalib - 2 months ago 5
SQL Question

SQL Get the column names from a table as data?

I have Table name Employees like;


Emp_Id Emp_Name Emp_Grade Emp_Mobile



I want to return the column names as data
how i can do this via query?

Answer


Hi,
You can use below query to get the column names,

SELECT COLUMN_NAME FROM COLS WHERE TABLE_NAME = 'your_table_name';

Provide table name in the WHERE condition
You can also describe table to know their constraints, data type and length using,

DESC your_table_name;
Comments