ghalib
ghalib

Reputation: 203

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?

Upvotes: 0

Views: 61

Answers (1)

Jim Macaulay
Jim Macaulay

Reputation: 5141


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;

Upvotes: 1

Related Questions