ora-01847 解决记录
1、日期字段的是数据非法的,要么就是转换时格式不合格,如:TO_CHAR(‘2021-05-21’,‘YYYYMM’)
也可能是一种特殊的‘ ’,如全角的空格等。
创建分区
create table T_PHONE_BI_D_yf_2022
(
“TIMEST” VARCHAR2(24),
“TIMEST2” VARCHAR2(24),
“COL_1” VARCHAR2(60),
“COL_2” VARCHAR2(60),
“COL_3” VARCHAR2(60),
“COL_4” VARCHAR2(60),
“COL_5” VARCHAR2(60),
“COL_6” VARCHAR2(60),
“COL_7” VARCHAR2(60),
“COL_8” VARCHAR2(60),
“COL_9” VARCHAR2(60),
“COL_10” VARCHAR2(60)
)
partition by range(“TIMEST”)
(
partition P20210430 values LESS THAN (TO_DATE(‘20210501’,‘YYYYMMDD’ ))tablespace user_tb
)
扩展日分区
WITH lvl AS
(SELECT to_char((p + LEVEL-1),‘yyyymmdd’) p,to_char((p + LEVEL),‘yyyymmdd’) p1
FROM (SELECT to_date(‘20210101’, --从哪天开始创建分区
‘yyyymmdd’) p
FROM dual)
CONNECT BY LEVEL <= 365 --一次性创建多少天的数据
)
SELECT ‘alter table T_PHONE_BI_D_yf_2022 add partition P’ || p ||
’ values less than (to_date(’’’|| p1 || ‘’’,’‘yyymmdd’’))
tablespace USER_DEFAULT
pctfree 10
initrans 1
maxtrans 255;’ a
FROM lvl