SQL get Column Name

Ads
 

SQL get Column Name

SQL get Column Name is used to return the Fieldnames of the table.

SQL get Column Name is used to return the Fieldnames of the table.

SQL get Column Name

     

SQL get Column Name is used to return the Fieldnames of the table.

Understand with Example

The Tutorial illustrate an example from 'SQL get Column Name'. To understand and elaborate example we create a table 'stu' with required fieldnames and datatypes respectively.

 

 

Create Table Stu:

Create Table Stu(Id int,Name Varchar(15));

Query:

The show columns is used to show fieldname and datatypes  from table 'Stu'.

SHOW COLUMNS FROM STU;

Result

+--------+-------------+------+-----+---------+-------+
| Field  | Type        | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| Id     | varchar(2)  | YES  |     |         |       |
| Name   | varchar(15) | YES  |     |         |       |
| Class  | varchar(10) | YES  |     |         |       |
| sub_id | varchar(2)  | YES  |     |         |       |
| marks  | varchar(3)  | YES  |     |         |       |
+--------+-------------+------+-----+---------+-------+

Ads

Ads