單表Insert into的語句就不說了,這里主要說插入多條語句的說明
For a multitable insert operation, each expression in the values_clause must refer to columns returned by the select list of the subquery. If you omit the values_clause, then the select list of the subquery determines the values to be inserted, so it must have the same number of columns as the column list of the corresponding insert_into_clause. If you do not specify a column list in the insert_into_clause, then the computed row must provide values for all columns in the target table.
對於多表插入操作,values_clause 中的每個表達式都必須引用子查詢的選擇列表返回的列。如果省略values_clause,則子查詢的select 列表決定了要插入的值,因此它的列數必須與相應insert_into_clause 的列列表相同。如果未在 insert_into_clause 中指定列列表,則計算行必須為目標表中的所有列提供值。
For both types of insert operations, if you specify a column list in the insert_into_clause, then the database assigns to each column in the list a corresponding value from the values clause or the subquery. You can specify DEFAULT for any value in the values_clause. If you have specified a default value for the corresponding column of the table or view, then that value is inserted. If no default value for the corresponding column has been specified, then the database inserts null. Refer to "About SQL Expressions" and SELECT for syntax of valid expressions.
對於這兩種類型的插入操作,如果您在 insert_into_clause 中指定了一個列列表,那么數據庫會從 values 子句或子查詢中為列表中的每一列分配一個相應的值。您可以為 values_clause 中的任何值指定 DEFAULT。如果您為表或視圖的相應列指定了默認值,則會插入該值。如果未指定相應列的默認值,則數據庫插入空值。有關有效表達式的語法,請參閱“關於 SQL 表達式”和 SELECT。
格式語法: INSERT ALL INTO tab_name(col_name) VALUES(val...) SELECT 1 FROM dual;
- 如果省略
values_clause
子句,那么INSERT INTO的表的值來自SELECT子句查詢的列值,需要SELECT為每個聲明的列定義都返回值;也就是可以提供后退默認值 - 如果省略
col_defines
列定義,那么提供的VALUES子句或者SELECT子查詢都需要為每個列賦予值進行插入 - 如果VALUES子句中使用DEFAULT關鍵字,那么值來源於列的默認值,如果列沒有默認值,那么會插入NULL。
注意:
values_clause
子句中可以使用SELECT子查詢的列的值- 如果需要使用SELECT子查詢,切記需要與 {聲明的列 或者 與表中列(沒有聲明列名)} 都需要賦予默認值
官方文檔里來源地址:https://docs.oracle.com/cd/E11882_01/server.112/e41084/statements_9014.htm#i2121694 搜索 values_clause 可快速定位相關的位置