Oracle复制表数据两种用法:
1. insert into A(a,b) select a,b from B;
2. create table C as select a,b from B;
如下为试验数据:
写道
--新建测试表
create table test_sj1
(
id integer primary key,
name varchar2(100)
);
create table test_sj2
(
id integer primary key,
name varchar2(100)
);
--插入测试表1
insert into test_sj1(id,name) values(1,'李刚');
commit;
select *
from test_sj1;
--表1向表2复制 表2存在
insert into test_sj2(id,name)
select id,name
from test_sj1;
commit;
select *
from test_sj2;
--复制表1数据,表3可以不存在
create table test_sj3 as
select *
from test_sj1;
select *
from test_sj3;
create table test_sj1
(
id integer primary key,
name varchar2(100)
);
create table test_sj2
(
id integer primary key,
name varchar2(100)
);
--插入测试表1
insert into test_sj1(id,name) values(1,'李刚');
commit;
select *
from test_sj1;
--表1向表2复制 表2存在
insert into test_sj2(id,name)
select id,name
from test_sj1;
commit;
select *
from test_sj2;
--复制表1数据,表3可以不存在
create table test_sj3 as
select *
from test_sj1;
select *
from test_sj3;