

# 列出或搜索指定表或视图的列
<a name="querying-glue-catalog-listing-columns"></a>

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

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

**Example – 列出指定表的所有列**  
以下示例查询列出了 `rdspostgresqldb1_public_account` 表的所有列。  

```
SELECT *
FROM   information_schema.columns
WHERE  table_schema = 'rdspostgresql'
       AND table_name = 'rdspostgresqldb1_public_account'
```
下表显示了示例结果。  


****  

|  | table\$1catalog | table\$1schema | table\$1name | column\$1name | ordinal\$1position | column\$1default | is\$1nullable | data\$1type | comment | extra\$1info | 
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | 
| 1 | awsdatacatalog | rdspostgresql | rdspostgresqldb1\$1public\$1account | password | 1 |  | 是 | varchar |  |  | 
| 2 | awsdatacatalog | rdspostgresql | rdspostgresqldb1\$1public\$1account | user\$1id | 2 |  | 是 | 整数 |  |  | 
| 3 | awsdatacatalog | rdspostgresql | rdspostgresqldb1\$1public\$1account | created\$1on | 3 |  | 是 | timestamp |  |  | 
| 4 | awsdatacatalog | rdspostgresql | rdspostgresqldb1\$1public\$1account | last\$1login | 4 |  | 是 | timestamp |  |  | 
| 5 | awsdatacatalog | rdspostgresql | rdspostgresqldb1\$1public\$1account | 电子邮件 | 5 |  | 是 | varchar |  |  | 
| 6 | awsdatacatalog | rdspostgresql | rdspostgresqldb1\$1public\$1account | username | 6 |  | 是 | varchar |  |  | 

**Example – 列出指定视图的列**  
以下示例查询列出了 `default` 数据库中用于 `arrayview` 视图的所有列。  

```
SELECT *
FROM   information_schema.columns
WHERE  table_schema = 'default'
       AND table_name = 'arrayview'
```
下表显示了示例结果。  


****  

|  | table\$1catalog | table\$1schema | table\$1name | column\$1name | ordinal\$1position | column\$1default | is\$1nullable | data\$1type | comment | extra\$1info | 
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | 
| 1 | awsdatacatalog | default | arrayview | searchdate | 1 |  | 是 | varchar |  |  | 
| 2 | awsdatacatalog | default | arrayview | sid | 2 |  | 是 | varchar |  |  | 
| 3 | awsdatacatalog | default | arrayview | btid | 3 |  | 是 | varchar |  |  | 
| 4 | awsdatacatalog | default | arrayview | p | 4 |  | 是 | varchar |  |  | 
| 5 | awsdatacatalog | default | arrayview | infantprice | 5 |  | 是 | varchar |  |  | 
| 6 | awsdatacatalog | default | arrayview | sump | 6 |  | 是 | varchar |  |  | 
| 7 | awsdatacatalog | default | arrayview | journeymaparray | 7 |  | 是 | array(varchar) |  |  | 

**Example – 在指定数据库和表中按名称搜索列**  
以下示例查询在 `default` 数据库的 `arrayview` 视图中搜索 `sid` 列的元数据。  

```
SELECT *
FROM   information_schema.columns
WHERE  table_schema = 'default'
       AND table_name = 'arrayview' 
       AND column_name='sid'
```
下图显示了一个示例结果。  


****  

|  | table\$1catalog | table\$1schema | table\$1name | column\$1name | ordinal\$1position | column\$1default | is\$1nullable | data\$1type | comment | extra\$1info | 
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | 
| 1 | awsdatacatalog | default | arrayview | sid | 2 |  | 是 | varchar |  |  | 