1995 年 1 月 1 日から 2023 年 12 月 31 日までのデータをロードしたいのですが、正しい構文は何ですか。現在、以下のクエリの助けを借りて、3年間(1096レコード)のデータしかありません。
CREATE TABLE "DATE_DIM"
( "DATE_KEY" NUMBER(10,0) CONSTRAINT "NN_DATE_KEY" NOT NULL ENABLE,
"DATE_VALUE" DATE,
"DATE_DAY_OF_WEEK" NUMBER,
"DATE_DAY_OF_WEEK_NAME" VARCHAR2(10 BYTE),
"DATE_WEEKEND_FLAG" NUMBER,
"DATE_WEEK_IN_MONTH" NUMBER,
"DATE_WEEK_IN_YEAR" NUMBER,
"DATE_WEEK_START_DATE" DATE,
"DATE_WEEK_END_DATE" DATE,
"DATE_DAY_OF_MONTH" NUMBER,
"DATE_MONTH_START_DATE" DATE,
"DATE_MONTH_NUMBER" VARCHAR2(2 BYTE),
"DATE_MONTH_NAME" VARCHAR2(10 BYTE),
"DATE_MONTH_ABBR" VARCHAR2(3 BYTE),
"DATE_QUARTER_NUMBER" VARCHAR2(1 BYTE),
"DATE_QUARTER_NAME" VARCHAR2(2 BYTE),
"DATE_QUARTER" VARCHAR2(8 BYTE),
"DATE_FISCAL_YEAR" VARCHAR2(4 BYTE),
"DATE_DAY_OF_YEAR_NUMBER" NUMBER,
"DATE_DAYS_IN_YEAR" NUMBER,
"DATE_HOLIDAY_IND" VARCHAR2(1 BYTE),
CONSTRAINT "PK_DATE_DIM" PRIMARY KEY ("DATE_KEY");
INSERT INTO date_dim
SELECT TO_NUMBER (TO_CHAR (mydate, 'yyyymmdd')) AS date_key,
TO_CHAR (mydate, 'dd-MON-yyyy') AS date_value,
TO_NUMBER (TO_CHAR (mydate, 'D')) AS date_day_of_week,
TO_CHAR (mydate, 'Day') AS date_day_of_week_name,
CASE WHEN TO_NUMBER (TO_CHAR (mydate, 'D')) IN (1, 7) THEN 1
ELSE 0
END AS date_weekend_flag,
TO_NUMBER (TO_CHAR (mydate, 'W')) AS date_week_in_month,
TO_NUMBER (TO_CHAR (mydate, 'WW')) AS date_week_in_year,
TRUNC(mydate, 'w') AS date_week_start_date,
TRUNC(mydate, 'w') + 7 - 1/864 AS date_week_end_date,
TO_NUMBER (TO_CHAR (mydate, 'DD')) AS date_day_of_month,
to_date(to_char(mydate,'MM') || '01' || to_char(mydate,'YYYY'),'MMDDYYYY') AS date_Month_START_DATE,
TO_CHAR (mydate, 'MM') AS date_month_number,
TO_CHAR (mydate, 'Month') AS date_month_name,
TO_CHAR (mydate, 'MON') AS date_month_abbr,
TO_CHAR (mydate, 'Q') AS date_quarter_number,
'Q' || TO_CHAR (mydate, 'Q') AS date_quarter_name,
'Q'
|| UPPER(TO_CHAR(mydate,'Q')
|| '-'
|| TO_CHAR(mydate,'YYYY')) AS date_quarter,
TO_CHAR (mydate, 'yyyy') AS date_fiscal_year,
TO_NUMBER (TO_CHAR (mydate, 'DDD')) AS date_day_of_year_number,
ADD_MONTHS (TRUNC (mydate, 'Y'), 12) - TRUNC (mydate, 'Y') AS date_days_in_year,
' ' as DATE_HOLIDAY_FLAG
FROM ( SELECT TRUNC (ADD_MONTHS (SYSDATE, -12), 'yy') - 1 + LEVEL AS mydate
FROM dual
CONNECT BY LEVEL <= (SELECT TRUNC (ADD_MONTHS (SYSDATE, 24), 'yy')
- TRUNC (ADD_MONTHS (SYSDATE, -12), 'yy')
FROM DUAL
)
);