

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 列示或搜尋指定的資料表或檢視的資料欄
<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\_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 |  | 是 | integer |  |  | 
| 3 | awsdatacatalog | rdspostgresql | rdspostgresqldb1\_public\_account | created\_on | 3 |  | 是 | timestamp |  |  | 
| 4 | awsdatacatalog | rdspostgresql | rdspostgresqldb1\_public\_account | last\_login | 4 |  | 是 | timestamp |  |  | 
| 5 | awsdatacatalog | rdspostgresql | rdspostgresqldb1\_public\_account | email | 5 |  | 是 | varchar |  |  | 
| 6 | awsdatacatalog | rdspostgresql | rdspostgresqldb1\_public\_account | username | 6 |  | 是 | varchar |  |  | 

**Example – 列出指定檢視的資料欄**  
下列範例查詢會針對檢視 `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) |  |  | 

**Example – 在指定的資料庫與資料表中依名稱搜尋資料欄**  
下列範例查詢會在 `sid` 資料庫的 `arrayview` 檢視中搜尋 `default` 資料欄的中繼資料。  

```
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 |  |  | 