データを挿入するテーブルがすでに存在する場合は、次を使用しますINSERT INTO
。
with calendar as (
select :startdate + rownum - 1 as day
from dual
connect by rownum < :enddate - startdate )
insert into anothertable (no, dt, dayname)
select rownum as "S.No", to_date(day,'dd_mm_yyyy') as "Cal_Dt", to_char(day,'day') as "DayName"
from calendar
または、SELECT INTO
構文を使用して新しいテーブルを作成します。
with calendar as (
select :startdate + rownum - 1 as day
from dual
connect by rownum < :enddate - startdate )
select rownum as "S.No", to_date(day,'dd_mm_yyyy') as "Cal_Dt", to_char(day,'day') as "DayName" into newtable
from calendar
編集-実際にはコメントは完全に正しいです-Oracleについて考えていませんでした:-)OracleでSQLステートメントからテーブルを作成する適切な方法は次のとおりです。
with calendar as (
select :startdate + rownum - 1 as day
from dual
connect by rownum < :enddate - startdate )
CREATE TABLE newtable
AS
(select rownum as "S.No", to_date(day,'dd_mm_yyyy') as "Cal_Dt", to_char(day,'day') as "DayName"
from calendar)