

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

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

# STL\$1LOAD\$1ERRORS
<a name="r_STL_LOAD_ERRORS"></a>

顯示所有 Amazon Redshift 載入錯誤的記錄。

STL\$1LOAD\$1ERRORS 包含所有 Amazon Redshift 載入錯誤的歷史記錄。如需可能載入錯誤和說明的完整清單，請參閱[載入錯誤參考](r_Load_Error_Reference.md)。

在您查詢 STL\$1LOAD\$1ERRORS 以了解有關錯誤的一般資訊之後，查詢 [STL\$1LOADERROR\$1DETAIL](r_STL_LOADERROR_DETAIL.md) 以取得其他詳細資訊，例如發生剖析錯誤的確切資料列和欄。

所有使用者都可看見 STL\$1LOAD\$1ERROR。超級使用者可以看見所有資料列；一般使用者只能看見自己的資料。如需詳細資訊，請參閱[系統資料表和檢視中資料的可見性](cm_chap_system-tables.md#c_visibility-of-data)。

**注意**  
STL\$1LOAD\$1ERRORS 僅包含在主佈建叢集上執行的查詢。但不包含在並行擴縮叢集上或無伺服器命名空間上執行的查詢。若要存取在主要叢集、並行擴縮叢集和無伺服器命名空間上執行的查詢說明計畫，建議您使用 SYS 監控檢視 [SYS\$1LOAD\$1ERROR\$1DETAIL](SYS_LOAD_ERROR_DETAIL.md)。SYS 監視檢視中的資料會格式化為更易於使用和理解。

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

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

## 範例查詢
<a name="r_STL_LOAD_ERRORS-sample-queries2"></a>

下列查詢會將 STL\$1LOAD\$1ERRORS 聯結至 STL\$1LOADERROR\$1DETAIL，以檢視最近載入期間發生之錯誤的詳細資訊。

```
select d.query, substring(d.filename,14,20), 
d.line_number as line, 
substring(d.value,1,16) as value,
substring(le.err_reason,1,48) as err_reason
from stl_loaderror_detail d, stl_load_errors le
where d.query = le.query
and d.query = pg_last_copy_id(); 

 query |    substring      | line |  value   |              err_reason
-------+-------------------+------+----------+----------------------------
    558| allusers_pipe.txt |  251 | 251      | String contains invalid or 
                                               unsupported UTF8 code
    558| allusers_pipe.txt |  251 | ZRU29FGR | String contains invalid or 
                                               unsupported UTF8 code
    558| allusers_pipe.txt |  251 | Kaitlin  | String contains invalid or 
                                               unsupported UTF8 code
    558| allusers_pipe.txt |  251 | Walter   | String contains invalid or 
                                               unsupported UTF8 code
```

下列範例會使用 STL\$1LOAD\$1ERRORS 與 STV\$1TBL\$1PERM 搭配來建立新檢視，然後使用該檢視來判斷將資料載入至 EVENT 資料表時發生哪些錯誤：

```
create view loadview as
(select distinct tbl, trim(name) as table_name, query, starttime,
trim(filename) as input, line_number, colname, err_code,
trim(err_reason) as reason
from stl_load_errors sl, stv_tbl_perm sp
where sl.tbl = sp.id);
```

接著，下列查詢實際上會傳回上次載入 EVENT 資料表時發生的錯誤：

```
select table_name, query, line_number, colname, starttime, 
trim(reason) as error
from loadview
where table_name ='event'
order by line_number limit 1;
```

此查詢會傳回 EVENT 資料表上次發生的載入錯誤。如果未發生任何載入錯誤，則查詢不會傳回任何資料列。在此範例中，查詢會傳回單一錯誤：

```
 table_name | query | line_number | colname | error | starttime
------+-----+----+----+--------------------------------------------------------+----------------------
event | 309 |  0 |  5 | Error in Timestamp value or format [%Y-%m-%d %H:%M:%S] | 2014-04-22 15:12:44

(1 row)
```

 如果 COPY 命令會自動分割大型、未壓縮、文字分隔的檔案資料以促進平行處理，則 *line\$1number*、*is\$1partial* 和 *start\$1offset* 欄會顯示分割的相關資訊。(如果原始檔案中的行號不可用，則行號可能是未知的。) 

```
--scan ranges information
SELECT line_number, POSITION, btrim(raw_line), btrim(raw_field_value),
btrim(err_reason), is_partial, start_offset FROM stl_load_errors
WHERE query = pg_last_copy_id();

--result
-1,51,"1008771|13463413|463414|2|28.00|38520.72|0.06|0.07|NO|1998-08-30|1998-09-25|1998-09-04|TAKE BACK RETURN|RAIL|ans cajole sly","NO","Char length exceeds DDL length",1,67108864
```