

 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/)。

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

# STV\$1TBL\$1PERM
<a name="r_STV_TBL_PERM"></a>

STV\$1TBL\$1PERM 資料表包含 Amazon Redshift 中永久資料表的相關資訊，其中包括使用者為目前工作階段建立的暫時資料表。STV\$1TBL\$1PERM 包含所有資料庫中所有資料表的資訊。

此資料表不同於 [STV\$1TBL\$1TRANS](r_STV_TBL_TRANS.md)，它包含系統在查詢處理過程中建立之暫時性資料庫的相關資訊。

只有超級使用者可以看到 STV\$1TBL\$1PERM。如需詳細資訊，請參閱[系統資料表和檢視中資料的可見性](cm_chap_system-tables.md#c_visibility-of-data)。

## 資料表欄
<a name="r_STV_TBL_PERM-table-columns"></a>

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

## 範例查詢
<a name="r_STV_TBL_PERM-sample-queries"></a>

下列查詢會傳回不同的資料表 ID 與名稱的清單：

```
select distinct id, name
from stv_tbl_perm order by name;

   id   |          name
--------+-------------------------
 100571 | category
 100575 | date
 100580 | event
 100596 | listing
 100003 | padb_config_harvest
 100612 | sales
...
```

其他系統資料表使用資料表 ID，因此知道哪個資料表 ID 對應至某特定資料表是非常有用的。在此範例中，SELECT DISTINCT 用於移除重複 (資料表被發佈至多個分割)。

若要判斷 VENUE 資料表中各個欄位使用的區塊數，請輸入以下查詢：

```
select col, count(*)
from stv_blocklist, stv_tbl_perm
where stv_blocklist.tbl = stv_tbl_perm.id
and stv_blocklist.slice = stv_tbl_perm.slice
and stv_tbl_perm.name = 'venue'
group by col
order by col;

 col | count
-----+-------
   0 |     8
   1 |     8
   2 |     8
   3 |     8
   4 |     8
   5 |     8
   6 |     8
   7 |     8
(8 rows)
```

## 使用須知
<a name="r_STV_TBL_PERM-usage-notes"></a>

ROWS 欄位包含未清空但已刪除 (或已清空但有 SORT ONLY 選項) 的資料列數。因此，當您直接查詢特定資料表時，STV\$1TBL\$1PERM 資料表中 ROWS 欄位的總和 (SUM) 可能會與 COUNT(\$1) 結果不相符。例如，如果從 VENUE 刪除 2 個資料列，COUNT(\$1) 結果為 200，但 SUM(ROWS) 結果仍是 202：

```
delete from venue
where venueid in (1,2);

select count(*) from venue;
count
-------
200
(1 row)

select trim(name) tablename, sum(rows)
from stv_tbl_perm where name='venue' group by name;

tablename | sum
-----------+-----
venue     | 202
(1 row)
```

為了同步 STV\$1TBL\$1PERM 中的資料，請執行完整清空 VENUE 資料表。

```
vacuum venue;

select trim(name) tablename, sum(rows)
from stv_tbl_perm
where name='venue'
group by name;

tablename | sum
-----------+-----
venue     | 200
(1 row)
```