Oracle Create Table as Select

CTAS employs the direct path load, in other words, it skips loading data into buffer cache.

 

PGA consumption

Consider two scenarios:

a) Create table target as select * from source;

The result of select statement is not saved in memory, Oracle writes it directly to disk. Even if source table is large, PGA and Temp is not used.

 

b) Create table target as select col1, sum(col2) from source group by col1;

Oracle has to do Hash Group By for this kind of query; PGA and temp possibly are used.

 

To create a new partitioned table, user needs to issue:

Create table xxx

Partition by range (colx)

(

Partition pxxx values less than ()

)

As Select * from xxx

 

To create the table in parallel, you can either:

1). Create table xxx parallel y as select * from zzz;
2). Create table yyy as select /*+ parallel */ * from zzz;

There's a major difference between statement 1 and 2. For statement 1, Oracle parallelizes both create and select parts, while for 2, only the select part is parallelized. When creating table in parallel,  each parallel execution server allocates a new extent, and fills it with data. 

Oracle documents state:
The CREATE operation of CREATE TABLE ... AS SELECT can be parallelized only by a PARALLEL clause or an ALTER SESSION FORCE PARALLEL DDL statement.
When the CREATE operation of CREATE TABLE ... AS SELECT is parallelized, Oracle Database also parallelizes the scan operation if possible

The scan operation cannot be parallelized if, for example:

  • The SELECT clause has a NO_PARALLEL hint.

  • The operation scans an index of a nonpartitioned table.

When the CREATE operation is not parallelized, the SELECT can be parallelized if it has a PARALLEL hint or if the selected table (or partitioned index) has a parallel declaration.

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/638844/viewspace-1061114/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/638844/viewspace-1061114/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值