-
在SQL语言基础中,涉及到从另一个表中复制行的操作
资源介绍
从另一个表中拷贝行
*
SQL> INSERT INTO managers(id, name, salary, hiredate)
2 SELECT empno, ename, sal, hiredate
3 FROM emp
4 WHERE job = 'MANAGER';
3 rows created.
创建带有子查询的 INSERT语句。
不要使用 VALUES 子句.
子查询中的列要与INSERT子句中的列相匹配.
*
Copying Rows from Another Table
You can use the INSERT statement to add rows to a table where the values are derived from existing tables. In place of the VALUES clause, you use a subquery.
Syntax
INSERT INTO table [ column (, column) ]
subquery;
where: table is the table name
column is the name of the column in the table to populate
subquery is the subquery that returns rows into the table
For more information, see Oracle Server SQL Reference, Release 8, “SELECT,” Subqueries section.
The number of columns and their datatypes in the column list of the INSERT clause must match the number of values and their datatypes in the subquery.
Instructor Note
Please run the script lab9_12.sql to create the managers table. Do not get into too many details on copying rows from another table.
- 上一篇: 安装IDS数据库-HDR数据库知识
- 下一篇: 对基于另一个表的行进行更改-SQL语言基础