我想写一条SELECT
语句以显示表中的字段列表。
COLUMN
column_1
column_2
column_3
答案 0 :(得分:2)
您可以使用信息模式表,尤其是columns
:
select column_name
from INFORMATION_SCHEMA.COLUMNS
where table_schema = @schema_name and table_name = @table_name;
请注意,此元数据存储在每个数据库中。因此,如果要在另一个数据库中使用表,则需要三部分命名:
select column_name
from <database>.INFORMATION_SCHEMA.COLUMNS
where table_schema = @schema_name and table_name = @table_name;
答案 1 :(得分:1)
还有一个选项:这将返回任何表,临时查询甚至是存储过程上的结果。
(以"index" – diff against the Git index (aka staged for commit), (the DEFAULT)
"head" – diff against the file at HEAD (aka last commit in checked out branch)
为例)
示例
spt_values
返回
答案 2 :(得分:0)