What is a Select statement to return column names in a table

Is there any select statement to return a list of columns in a table?

+3
source share
4 answers

The INFORMATION_SCHEMA.COLUMNS view will display the column names for a specific table name.

SELECT Column_Name + ', '
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'Table_Name'

There are several other views, as well as the ones above, which you may find useful. These INFORMATION_SCHEMA views provide schema information for your database.

Select top 10 * from Information_Schema.tables 
Select top 10 * from Information_Schema.views 
Select top 10 * from Information_Schema.routines 
Select top 10 * from Information_Schema.parameters
+10
source

Paul's answer is suitable for mysql. ON EDIT: and sql server, apparently. Arrgh. Sorry Paul.

sql- sys.syscolumns, : Sybase?

+1

sp_help TableName

, .

+1

SqlServer 2005,

SELECT _ ' ', data_type ' ' FROM information_schema.columns WHERE table_name = ' '

. sdonthula@live.com

0

Source: https://habr.com/ru/post/1706083/


All Articles