2007년 10월 31일 수요일

query한 결과를 table에 넣기

예제:
insert into aa ( id )
         select user_name as id from user;

>>-INSERT  INTO--table_name--+-----------------------+---------->
                             |    .-,-----------.    |
                             |    V             |    |
                             '-(----column_name-+--)-'

                .-,-----------.
                V             |
>--+-VALUES--(----+-literal-+-+--)-+---------------------------><
   |              +-NULL----+      |
   |              '-DEFAULT-'      |
   +-select_statement--------------+
   '-DEFAULT VALUES----------------'


table 생성

create table Q1_00_Sales
   (product char(30), month char(5), dollars dec(7,2));


값 입력




insert into Q1_00_Sales (product, month, dollars) select prod_name, month, dollars from sales natural join product natural join period natural join store where qtr = 'Q1_00' and city like 'Los Gatos%'

댓글 없음:

댓글 쓰기