什么是 Select 语句来返回表中的列名
问题描述:
是否有任何选择语句返回表中的列列表?
Is there any select statement to return the list of columns in the table?
答
INFORMATION_SCHEMA.COLUMNS 视图将提供特定表名的列名.
The INFORMATION_SCHEMA.COLUMNS view will provide the column names for a particular table name.
SELECT Column_Name + ', '
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'Table_Name'
还有其他几个视图以及上面的视图,您可能会发现它们很有用.这些 INFORMATION_SCHEMA 视图提供有关数据库架构的信息.
There are several other views as well as the one above which you may find useful. These INFORMATION_SCHEMA views provide information on the schema of 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