日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

oracle insert into as select,比较create table as select * 与 insert into table select *

發(fā)布時間:2024/9/27 81 豆豆
生活随笔 收集整理的這篇文章主要介紹了 oracle insert into as select,比较create table as select * 与 insert into table select * 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

實(shí)驗(yàn)環(huán)境:

SYS@aaron> select * from v$version;

BANNER

--------------------------------------------------------------------------------

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

PL/SQL Release 11.2.0.1.0 - Production

CORE 11.2.0.1.0 Production

TNS for Linux: Version 11.2.0.1.0 - Production

NLSRTL Version 11.2.0.1.0 - Production

實(shí)驗(yàn)步驟:

1 首先創(chuàng)建一個原始表test01, 大小為504M

SEGMENT_NAME???? ???? SEGMENT_TYPE???? TABLESPACE_NAME ????????? ?? BLOCKS??? EXTENTS BYTES/1024/1024

-------------------- ------------------ ------------------------------ ---------- ---------- ---------------

TEST01 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?TABLE ? ? ? ? ? ? ? ? ? ? EXAMPLE ?????????????? ??? 64512 ? ? ? ? ? ? ? 134 ? ? ? ? ?504

2 使用create table test02 as select * from test01 創(chuàng)建表test02并觀察執(zhí)行時間 與產(chǎn)生的日志量

SYS@aaron> set timing on

SYS@aaron> create table test02 tablespace example as select * from test01;

Table created.

Elapsed: 00:00:14.70

SYS@aaron> alter system switch logfile

產(chǎn)生歸檔日志如下:

-rw-r----- 1 oracle oinstall963KDec 24 19:12 1_128_864773796.dbf

3 使用insert into table test02 as select * from test01, 觀察效率與產(chǎn)生的日志量

SYS@aaron> drop table test02;

Table dropped.

SYS@aaron> create table test02 as select * from test01 where 0=1;

Table created.

SYS@aaron> alter system switch logfile;

System altered.

SYS@aaron> insert into test02 select * from test01;

4523648 rows created.

Elapsed: 00:02:12.30

產(chǎn)生的日志量為:

-rw-r----- 1 oracle oinstall? 49M Dec 24 19:16 1_130_864773796.dbf

-rw-r----- 1 oracle oinstall? 44M Dec 24 19:16 1_131_864773796.dbf

-rw-r----- 1 oracle oinstall? 49M Dec 24 19:16 1_132_864773796.dbf

-rw-r----- 1 oracle oinstall? 49M Dec 24 19:17 1_133_864773796.dbf

-rw-r----- 1 oracle oinstall? 49M Dec 24 19:17 1_134_864773796.dbf

-rw-r----- 1 oracle oinstall? 49M Dec 24 19:17 1_135_864773796.dbf

-rw-r----- 1 oracle oinstall? 47M Dec 24 19:17 1_136_864773796.dbf

-rw-r----- 1 oracle oinstall? 49M Dec 24 19:18 1_137_864773796.dbf

-rw-r----- 1 oracle oinstall? 49M Dec 24 19:18 1_138_864773796.dbf

-rw-r----- 1 oracle oinstall? 49M Dec 24 19:18 1_139_864773796.dbf

-rw-r----- 1 oracle oinstall? 45M Dec 24 19:18 1_140_864773796.dbf

-rw-r----- 1 oracle oinstall? 12K Dec 24 19:19 1_141_864773796.dbf

總結(jié):使用create table as select *的方式更有效率 并且?guī)缀醪粫a(chǎn)生歸檔日志。

創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎

總結(jié)

以上是生活随笔為你收集整理的oracle insert into as select,比较create table as select * 与 insert into table select *的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。