CREATE TABLE AS SELECT(CAST)(二)-Concept
一、Temporary Segments Concept
Oracle often requires temporary work space for intermediate stages of database processing. There are different kinds of temporary segments in the database.
Some of them are created explicitly by the users. The others are created and accessed for the user by the system.
There are SQL operations containing a sorting step which require temporary segments. However, segments used for sorting are not the only segments having SEGMENT_TYPE=TEMPORARY. Temporary segments can also exist for permanent segments creation.
Temporary segments for sorting are created in the default temporary tablespace of the user. This tablespace may be of type TEMPORARY or PERMANENT.
(1) A TEMPORARY tablespace (Locally Managed Tablespace) is recommended for sort operations.
(2) Temporary segments for permanent segments creation are created in the tablespace specified in the create statement or in the user’s default tablespace.
a. Temporary Tables
only exists during a transaction or session.
DML statements on temporary tables do not generate redo logs for the data changes. However, undo logs for the data and redo logs for the undo logs are generated.
b. Temporary LOBs
The goal of temporary LOBs is to develop an interface to support the creation and deletion of lobs that act like local variables.
c. Temporary Segments as work area for sorting
When processing queries, Oracle often requires temporary workspace for intermediate stages of SQL statement execution.
The sort area is allocated in memory. If the sort operation needs additional memory (above the value specified by the SORT_AREA_SIZE parameter), the sorted rows are written to disk to free up the sort area so that it can be re-used for the remaining sort.
Oracle automatically allocates this disk space called a temporary segment.
The following statements may require the use of a temporary segment for sorting:
CREATE INDEX/SELECT ... ORDER BY/SELECT DISTINCT/SELECT ... GROUP BY/SELECT ... UNION/SELECT ... INTERSECT/SELECT ... MINUS/ANALYZE TABLE/Unindexed joins/Correlated subqueries
d. Temporary Segments for permanent segments creation
Besides sort operations, there are other SQL operations, which also require temporary segments:
CREATE PRIMARY/UNIQUE KEY CONSTRAINT
ALTER TABLE ... ENABLE PRIMARY/UNIQUE CONSTRAINT
CREATE TABLE STORAGE (MINEXTENTS>1)
CREATE TABLE AS SELECT
The CTAS creates a data segment in the target tablespace and marks this segment as temporary in dictionary.
On completion, the dictionary type is changed from temporary to table. In addition, if the SELECT performs a SORT operation, temporary space may be used as for a standard select.
CREATE PARTITION TABLE
ALTER TABLE ... SPLIT PARTITION
CREATE SNAPSHOT
CREATE INDEX
The CREATE INDEX statement, after sorting the index values, builds a temporary segment in the INDEX tablespace;
once the index is completely built, the segment type is changed to INDEX.
DROP TABLE
e. Temporary Tablespaces
二、Introduction to Direct-Path INSERT
1. Conventional insert operations:
Oracle reuses free space in the table, interleaving newly inserted data with existing data. During such operations, Oracle also maintains referential integrity constraints.
2. Direct-path INSERT operations:
Oracle appends the inserted data after existing data in the table. Data is written directly into datafiles, bypassing the buffer cache. Free space in the existing data is not reused, and referential integrity constraints are ignored. These procedures combined can enhance performance.
a. During direct-path INSERT, you can disable the logging of redo and undo entries
b. CREATE TABLE ... AS SELECT statement, does not have any indexes defined on it and not null constraint; you must define them later.
Note:If the database or tablespace is in FORCE LOGGING mode, then direct path INSERT always logs, regardless of the logging or nologging setting, such as STANDBY database.
參考文獻:
1. Different Kinds of Temporary Segments [ID 181132.1]
2.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9252210/viewspace-660173/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【SQL】14 UNION 操作符、SELECT INTO 語句、INSERT INTO SELECT 語句、CREATE DATABASE 語句、CREATE TABLE 語句SQLDatabase
- ERROR 1786 (HY000): Statement violates GTID consistency: CREATE TABLE ... SELECTError
- create table 使用select查詢語句建立表的方法分享
- Oracle table selectOracle
- create table,show tables,describe table,DROP TABLE,ALTER TABLE ,怎麼使用?
- MySQL5.6 create table原理分析MySql
- MySQL的create table as 與 like區別MySql
- use azure data studio to create external table for oracleOracle
- oracle 19c 無法create table解決Oracle
- Bootstrap select2 ,table, 清空表單formbootORM
- 帶allow-create的el-select限制長度
- 關於 mysql 中的 select * from table_a,table_b 的問題MySql
- NEW CONCEPT ENGLISH 51 - 60
- C++強制型別轉換:static_cast、dynamic_cast、const_cast、reinterpret_castC++型別AST
- 7.41 CASTAST
- ORA-31633: unable to create master table "SYSTEM.SYS_EXPORT_FULL_XX"ASTExport
- Laravel-admin 中 table,select 控制元件額外需求Laravel控制元件
- reinterpret_cast 和 static_cast 的區別AST
- dynamic_castAST
- static_cast與dynamic_cast到底是什麼?AST
- SQLite語句(二):INSERT DELETE UPDATE SELECTSQLitedelete
- 型別轉換(cast)型別AST
- reinterpret_cast解讀AST
- mybatis進行資料庫建表 CREATE command denied to user 'root'@'127.0.0.1' for table 問題MyBatis資料庫127.0.0.1
- 多路I/O複用:select、poll、epoll(二)
- C++中dynamic_cast與static_cast淺析與例項演示C++AST
- static_cast和dynamic_cast的區別,看完這篇你就懂了!AST
- BACON: Supercharge Your VLM with Bag-of-Concept Graph to Mitigate HallucinationsMIT
- SQL中的cast()函式SQLAST函式
- SQL Server 2016 函式:CASTSQLServer函式AST
- iview Table元件使用render新增Select下拉框並進行雙向繫結View元件
- create_singlethread_workqueue, create_workqueuethread
- select 下拉框用 Select select = new Select (element) 方法失敗
- (轉)Go 每日一庫之 castGoAST
- Golang 型別轉換庫 castGolang型別AST
- 我眼中的 Nginx(二):HTTP/2 dynamic table size updateNginxHTTP
- C++中型別轉換static_castC++型別AST
- 比CRUD多一點兒(二):基礎INSERT、SELECT語句
- SQL__CREATESQL