Oracle复制表数据的两种用法

来源:互联网 发布:网页 加密软件 编辑:程序博客网 时间:2024/06/07 17:30

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;

 

 

  • 测试插入.rar (366 Bytes)
  • 下载次数: 0