Getting column names from a table – SQL Query

Posted: February 10, 2010 in SQL

Below is the query to get all the column names from your table.

SELECT column_name ‘Column Name’
FROM information_schema.columns
WHERE table_name =’table_name’

The query uses  “information_schema.columns”  to get the column details of the table.

There are also other information of your table like data type of column same as column_name which you can retrieve using this.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s