Oracle SQL 中的多行插入
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10868874/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
multiple row insert in Oracle SQL
提问by Davit khaburdzania
I use multiple row insert syntax in oracle SQL like this:
我在 oracle SQL 中使用多行插入语法,如下所示:
INSERT ALL
INTO student(ID, FIRST_NAME, LAST_NAME, AGE) VALUES(4,'test_name','test_lname',17)
INTO student(ID, FIRST_NAME, LAST_NAME, AGE) VALUES(5,'test_name2','test_lname2',20)
INTO student(ID, FIRST_NAME, LAST_NAME, AGE) VALUES(6,'test_name3','test_lname3',21)
select * from dual;
can anyone explain me what is the meaning of using
任何人都可以解释我使用的含义是什么
select * from dual
选择 * 从双
at the and of statement?
在和声明?
回答by shareef
it the syntax for INSERT ALL
它的语法 INSERT ALL
INSERT ALL
INTO <table_name> VALUES <column_name_list)
INTO <table_name> VALUES <column_name_list)
...
<SELECT Statement>;
if there is nothing you want to select after inserting you do select * from dual
如果在插入后没有您想要选择的内容,请执行 select * from dual
otherwise you do your select you want usually to confirm the insert success
否则你做你通常想要确认插入成功的选择
回答by Simon Dorociak
The DUAL table is a special one-row table present by default in all Oracle database installations. It is suitable for use in selecting a pseudocolumn such as SYSDATE or USER. The table has a single VARCHAR2(1) column called DUMMY that has a value of 'X'.
DUAL 表是一种特殊的单行表,默认情况下存在于所有 Oracle 数据库安装中。它适用于选择 SYSDATE 或 USER 等伪列。该表有一个名为 DUMMY 的 VARCHAR2(1) 列,其值为“X”。
回答by JZab
The insert all can be used to insert data from a select statement, to another table In your example you have already provided the values to insert, that's why you need to do the select * from dual, to trigger the insertion.
insert all 可用于将数据从 select 语句插入到另一个表在您的示例中,您已经提供了要插入的值,这就是为什么您需要执行 select * from dual 来触发插入。
http://jzab.blogspot.com/2013/05/oracle-insert-multiple-rows-with-single.html
http://jzab.blogspot.com/2013/05/oracle-insert-multiple-rows-with-single.html