Thursday, January 14, 2016

Showing table columns ordered by name

Here is SQL syntax for showing table columns ordered by name:

SELECT *
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = 'tablename'
ORDER BY column_name;


To show only name, type and schema:

SELECT column_name, column_type, table_schema
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = '
tablename'

ORDER BY column_name;



No comments:

Post a Comment