

 Amazon Redshift 將不再支援從修補程式 198 開始建立新的 Python UDFs。現有 Python UDF 將繼續正常運作至 2026 年 6 月 30 日。如需詳細資訊，請參閱[部落格文章](https://aws.amazon.com/blogs/big-data/amazon-redshift-python-user-defined-functions-will-reach-end-of-support-after-june-30-2026/)。

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

# PG\$1TABLE\$1DEF
<a name="r_PG_TABLE_DEF"></a>

儲存資料表欄位的相關資訊。

PG\$1TABLE\$1DEF 僅傳回使用者可見之資料表的相關資訊。如果 PG\$1TABLE\$1DEF 未傳回預期的結果，確認 [search\$1path](r_search_path.md) 參數是否正確設定為包含相關的結構描述。

您可以使用 [SVV\$1TABLE\$1INFO](r_SVV_TABLE_INFO.md) 來檢視資料表的更全面性資訊，包括資料配送偏度、索引鍵配送偏度、資料表大小、統計等方面的問題。

## 資料表欄
<a name="r_PG_TABLE_DEF-table-columns2"></a>

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/redshift/latest/dg/r_PG_TABLE_DEF.html)

## 範例
<a name="r_PG_TABLE_DEF-example2"></a>

下列範例顯示 LINEORDER\$1COMPOUND 資料表的複合排序索引鍵欄位。

```
select "column", type, encoding, distkey, sortkey, "notnull" 
from pg_table_def
where tablename = 'lineorder_compound' 
and sortkey <> 0;

column       | type    | encoding | distkey | sortkey | notnull
-------------+---------+----------+---------+---------+--------
lo_orderkey  | integer | delta32k | false   |       1 | true   
lo_custkey   | integer | none     | false   |       2 | true   
lo_partkey   | integer | none     | true    |       3 | true   
lo_suppkey   | integer | delta32k | false   |       4 | true   
lo_orderdate | integer | delta    | false   |       5 | true   
(5 rows)
```

 下列範例顯示 LINEORDER\$1INTERLEAVED 資料表的交錯排序索引鍵欄位。

```
select "column", type, encoding, distkey, sortkey, "notnull" 
from pg_table_def
where tablename = 'lineorder_interleaved' 
and sortkey <> 0;

column       | type    | encoding | distkey | sortkey | notnull
-------------+---------+----------+---------+---------+--------
lo_orderkey  | integer | delta32k | false   |      -1 | true   
lo_custkey   | integer | none     | false   |       2 | true   
lo_partkey   | integer | none     | true    |      -3 | true   
lo_suppkey   | integer | delta32k | false   |       4 | true   
lo_orderdate | integer | delta    | false   |      -5 | true   
(5 rows)
```

PG\$1TABLE\$1DEF 將僅傳回在搜尋路徑中包含之結構描述中資料表的相關資訊。如需詳細資訊，請參閱[search\$1path](r_search_path.md)。

例如，假設您建立新結構描述和新資料表，以及查詢 PG\$1TABLE\$1DEF。

```
create schema demo;
create table demo.demotable (one int);
select * from pg_table_def where tablename = 'demotable';

schemaname|tablename|column| type | encoding | distkey | sortkey | notnull 
----------+---------+------+------+----------+---------+---------+--------
```

查詢未傳回新資料表的任何列。檢查 `search_path` 的設定。

```
show search_path;

  search_path
---------------
 $user, public
(1 row)
```

將 `demo` 結構描述新增至搜尋路徑中並再次執行查詢。

```
set search_path to '$user', 'public', 'demo';

select * from pg_table_def where tablename = 'demotable';

schemaname| tablename |column|  type   | encoding |distkey|sortkey| notnull
----------+-----------+------+---------+----------+-------+-------+--------
demo      | demotable | one  | integer | none     | f     |     0 | f
(1 row)
```