Home > Backend Development > PHP Tutorial > oracle怎么把查询结果插入到另一表中?

oracle怎么把查询结果插入到另一表中?

PHPz
Release: 2020-09-05 09:56:20
Original
11150 people have browsed it

方法:1、使用“create table B as select * from A”语句将A表的查询结果直接生成并导入到新表B中;2、使用“insert into B select * from A”语句将A表查询结果插入到B表中。

oracle怎么把查询结果插入到另一表中?

oracle 把查询结果插入到表中几种方式

一、Oracle数据库中,把一张表的查询结果直接生成并导入一张新表中。 

例如:现有只有A表,查询A表,并且把结果导入B表中。使用如下SQL语句: 

create table B as select * from A
Copy after login

二、Oracle数据库中支持把查询结果导入到另外一张表中。

例如:有两个表A和B

1)、如果两个表的表结构是否相同,但要插入的字段类型相同:

I、把A表的全部字段数据插入到B表中:

insert into B select * from A;
Copy after login

II 把A表中某些字段的数据插入B表中:

insert into B(字段名)(select 字段名 from A)
Copy after login

2)如果不在同一个schema下请在表名前加上schema,例如有schema a和b:

insert into b.B select * from a.A
Copy after login

更多相关知识,请访问 PHP中文网!!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template