Friday, November 6, 2009

GET ALL FIELD NAMES FROM A GIVEN TABLE

To Retrieve All Column names from a given table using Mysql query



There are situation, we need to have retrieve column names associated with particular a particular table. For this so many techniques are available

here is the query

SELECT
COLUMN_NAME
FROM information_schema.COLUMNS
WHERE
table_name ='your table_name';

Here we are using simple select query to return the desired output

what is information schema

INFORMATION_SCHEMA provides access to database metadata. A schema is a database, so the information_schema provides information about databases. Metadata is data about the data, such as the name of a database or table, the data type of a column, or access privileges. Other terms that sometimes are used for this information are data dictionary and system catalog.
more...

Here COLUMN_NAME is in the COLUMN associated with information schema.The entire query is direct and simple huh?

regards..

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails