1. 程式人生 > >建立分割槽表的時候出現ORA-01843

建立分割槽表的時候出現ORA-01843

RDBMS 12.2.0.1 , OS Windows 。

在建立分割槽表的時候,提示ORA-01843錯誤。

[email protected]/nocdb>CREATE TABLE time_range_sales
  2  ( prod_id NUMBER(6)
  3  , cust_id NUMBER
  4  , time_id DATE
  5  , channel_id CHAR(1)
  6  , promo_id NUMBER(6)
  7  , quantity_sold NUMBER(3)
  8  , amount_sold NUMBER(10,2)
  9  )
 10  PARTITION BY RANGE (time_id)
 11  (PARTITION SALES_1998 VALUES LESS THAN (TO_DATE('01-JAN-1999','DD-MON-YYYY')),
 12  PARTITION SALES_1999 VALUES LESS THAN (TO_DATE('01-JAN-2000','DD-MON-YYYY')),
 13  PARTITION SALES_2000 VALUES LESS THAN (TO_DATE('01-JAN-2001','DD-MON-YYYY')),
 14  PARTITION SALES_2001 VALUES LESS THAN (MAXVALUE)
 15  );
(PARTITION SALES_1998 VALUES LESS THAN (TO_DATE('01-JAN-1999','DD-MON-YYYY')),
                                                              *
第 11 行出現錯誤:
ORA-01843: 無效的月份


[email protected]
/nocdb>host

方法1 ,修改NLS_DATE_LANAUAGE為american

ALTER SESSION SET NLS_DATE_LANGUAGE='AMERICAN';

[email protected]/nocdb>show parameter nls_date_language

NAME                                 TYPE                   VALUE
------------------------------------ ---------------------- ------------------------------
nls_date_language                    string                 SIMPLIFIED CHINESE
[email protected]
/nocdb> [email protected]/nocdb>CREATE TABLE time_range_sales 2 ( prod_id NUMBER(6) 3 , cust_id NUMBER 4 , time_id DATE 5 , channel_id CHAR(1) 6 , promo_id NUMBER(6) 7 , quantity_sold NUMBER(3) 8 , amount_sold NUMBER(10,2) 9 ) 10 PARTITION BY RANGE (time_id) 11 (PARTITION SALES_1998 VALUES LESS THAN (TO_DATE('01-JAN-1999','DD-MON-YYYY')), 12 PARTITION SALES_1999 VALUES LESS THAN (TO_DATE('01-JAN-2000','DD-MON-YYYY')), 13 PARTITION SALES_2000 VALUES LESS THAN (TO_DATE('01-JAN-2001','DD-MON-YYYY')), 14 PARTITION SALES_2001 VALUES LESS THAN (MAXVALUE) 15 ); 表已建立。
[email protected]
/nocdb>

方法2 。在OS層面設定set NLS_LANG=AMERICAN_AMERICA.ZHS16GBK

C:\Users\zhao-pc>set NLS_LANG=AMERICAN_AMERICA.ZHS16GBK

C:\Users\zhao-pc>echo %NLS_LANG%
AMERICAN_AMERICA.ZHS16GBK

@>conn sys/[email protected]/nocdb as sysdba
Connected.
[email protected]/nocdb>CREATE TABLE time_range_sales
  2  ( prod_id NUMBER(6)
  3  , cust_id NUMBER
  4  , time_id DATE
  5  , channel_id CHAR(1)
  6  , promo_id NUMBER(6)
  7  , quantity_sold NUMBER(3)
  8  , amount_sold NUMBER(10,2)
  9  )
 10  PARTITION BY RANGE (time_id)
 11  (PARTITION SALES_1998 VALUES LESS THAN (TO_DATE('01-JAN-1999','DD-MON-YYYY')),
 12  PARTITION SALES_1999 VALUES LESS THAN (TO_DATE('01-JAN-2000','DD-MON-YYYY')),
 13  PARTITION SALES_2000 VALUES LESS THAN (TO_DATE('01-JAN-2001','DD-MON-YYYY')),
 14  PARTITION SALES_2001 VALUES LESS THAN (MAXVALUE)
 15  );

Table created.

[email protected]/nocdb>

之前在Linux上的時候,設定過NLS_LANG=en_US . 手頭上沒有環境,暫時未測試。

BTW:在考OCM的時候,當時也出現過這個錯誤的提示。還好當時處理了,今天又發現這個問題了。

END