选择您的 Cookie 首选项

我们使用必要 Cookie 和类似工具提供我们的网站和服务。我们使用性能 Cookie 收集匿名统计数据,以便我们可以了解客户如何使用我们的网站并进行改进。必要 Cookie 无法停用,但您可以单击“自定义”或“拒绝”来拒绝性能 Cookie。

如果您同意,AWS 和经批准的第三方还将使用 Cookie 提供有用的网站功能、记住您的首选项并显示相关内容,包括相关广告。要接受或拒绝所有非必要 Cookie,请单击“接受”或“拒绝”。要做出更详细的选择,请单击“自定义”。

列出或搜索指定表或视图的列

聚焦模式
列出或搜索指定表或视图的列 - Amazon Athena

您可以列出表的所有列、视图的所有列,或者在指定的数据库和表中按名称搜索列。

要列出列,请使用 SELECT * 查询。在 FROM 子句中,指定 information_schema.columns。在 WHERE 子句中,使用 table_schema='database_name' 以指定数据库,使用 table_name = 'table_name' 指定包含要列出的列的表或视图。

例 – 列出指定表的所有列

以下示例查询列出了 rdspostgresqldb1_public_account 表的所有列。

SELECT * FROM information_schema.columns WHERE table_schema = 'rdspostgresql' AND table_name = 'rdspostgresqldb1_public_account'

下表显示了示例结果。

table_catalog table_schema table_name column_name ordinal_position column_default is_nullable data_type comment extra_info
1 awsdatacatalog rdspostgresql rdspostgresqldb1_public_account password 1 varchar
2 awsdatacatalog rdspostgresql rdspostgresqldb1_public_account user_id 2 整数
3 awsdatacatalog rdspostgresql rdspostgresqldb1_public_account created_on 3 时间戳
4 awsdatacatalog rdspostgresql rdspostgresqldb1_public_account last_login 4 时间戳
5 awsdatacatalog rdspostgresql rdspostgresqldb1_public_account email 5 varchar
6 awsdatacatalog rdspostgresql rdspostgresqldb1_public_account username 6 varchar
例 – 列出指定视图的列

以下示例查询列出了 default 数据库中用于 arrayview 视图的所有列。

SELECT * FROM information_schema.columns WHERE table_schema = 'default' AND table_name = 'arrayview'

下表显示了示例结果。

table_catalog table_schema table_name column_name ordinal_position column_default is_nullable data_type comment extra_info
1 awsdatacatalog 默认值 arrayview searchdate 1 varchar
2 awsdatacatalog 默认值 arrayview sid 2 varchar
3 awsdatacatalog 默认值 arrayview btid 3 varchar
4 awsdatacatalog 默认值 arrayview p 4 varchar
5 awsdatacatalog 默认值 arrayview infantprice 5 varchar
6 awsdatacatalog 默认值 arrayview sump 6 varchar
7 awsdatacatalog 默认值 arrayview journeymaparray 7 array(varchar)
例 – 在指定数据库和表中按名称搜索列

以下示例查询在 default 数据库的 arrayview 视图中搜索 sid 列的元数据。

SELECT * FROM information_schema.columns WHERE table_schema = 'default' AND table_name = 'arrayview' AND column_name='sid'

下图显示了一个示例结果。

table_catalog table_schema table_name column_name ordinal_position column_default is_nullable data_type comment extra_info
1 awsdatacatalog 默认值 arrayview sid 2 varchar
隐私网站条款Cookie 首选项
© 2025, Amazon Web Services, Inc. 或其附属公司。保留所有权利。