oracle数据库 用语句向多个表中插入一列。
解决方案 »
- “select * into 表2 from 表1与insert into 表2 select * from 表1”的问题
- 执行完存储过程后执行SQL语句(SELECT)
- DBMS_MONITOR.session_trace_enable执行无效
- Oracle中如何利用作业实现自动将某个数据库表导出为.txt文件
- 多个PARTIOTION问题,知道的朋友近来看看
- Oracle 9i 登录问题
- 我的if 条件写错了吗?
- 一条简单的SQL语句,请各位大侠帮忙呀~
- 100分求教如何在一个数据库建不同的用户,并且赋予不同的权限
- 请问如何修改internalh and sys 的默认密码?
- 新手问题,求助
- 求助,关于oracle的update以及insert的问题
but Oracle also supports a multiple-table INSERT statement.
With a multitable insert, you can make a single pass
through the source data and load the data into more than one table. insert [ ALL | FIRST ]
WHEN condition THEN insert_into_clause [values_clause]
[insert_into_clause [values_clause]]...
[WHEN condition THEN insert_into_clause [values_clause]
[insert_into_clause [values_clause]]...
]...
[ELSE insert_into_clause [values_clause]
[insert_into_clause [values_clause]]...
] If a WHEN condition evaluates to TRUE, the corresponding INTO clause is executed.
If no WHEN condition evaluates to TRUE, the ELSE clause is executed.
The keyword ALL tells the database to check each WHEN condition. On the other hand,
the keyword FIRST tells the database to stop checking WHEN conditions after finding the first TRUE condition.an example:
SQL> truncate table test;
Table truncated
SQL> truncate table test1;
Table truncated
SQL>
SQL> insert first
2 when 1=1 then into test(id)
3 else into test1(seq_no)
4 select 1 from dual
5 ;
1 row inserted
SQL> select * from test;
ID NAME
----------- --------------------------------------------------------------------------------
1
SQL> select * from test1;
SEQ_NO TYPE1 TYPE2 AMT MARK
----------- ----- ----- ------------ ------
SQL>
insert all
when condition1 then into table1
when condition2 then into table2
else into table3
select * from tablename