Temporary Tablespace 用于存放瞬时数据,只有在session连接期间才能够看到数据。Permanentobject无法创建在temporarytablespace
Temporary Tablespace
Temporary Tablespace 用于存放瞬时数据,只有在session连接期间才能够看到数据。Permanentobject无法创建在temporarytablespace中。
空间利用原理:
它不会由smon来监控、回收空间。而是使用SEP(Sort Extent Pool)来记录空闲的extent。
在OracleDatabase创建数据库的时候会自动的创建默认临时表空间,并且临时表空间的类型是 Locally Managed Temporary Tablespace with Tempfile 。
Temporary File
本地管理临时表空间拥有temp file,它是为存放hash数据、排序数据等而设计的文件。Temp file同样在超出memory大小后存储结果集的数据。
TemporaryFile在创建的时候,就像一个稀疏文件,不会占用磁盘空间。只有当第一次使用的时候才会在其中创建temporary segment,分配disk block。
Temp file 与 通常的数据文件(permanent data file)有如下不同点:
1. 持久化数据库对象比如说通常的表,不会存放于temp file中。
2. temp file 通常是nologging状态。
3. 无法将temp file置于read-only状态(无法write,,temp file将没有意义)。
4. 无法使用alter database创建 temp file 。
5. 无法保证temp file的大小,就像UNIX系统下的sparse files 。稀疏文件解释请看附录1。
6. 查询temp file的视图也和普通数据文件视图不一样,是在dba_temp_files和v$tempfile中。
Temporary Segment
执行查询的过程中,oracle db通常需要临时工作空间。通常来说,sorting、hashing、merging bitmaps都需要用到临时段。当创建一个索引的时候,oracle db 同样将索引segment放在临时segemnt中,然后索引创建完之后转换为持久化index segment。
如果操作可以在内存中完成,那么oracle db不会使用临时segment。不管怎样如果memory不可用,那么数据库自动的分配一个在存储磁盘上面的临时segment。
临时segement的改变不会记录在online redo log中,除了那些在临时段上面的空间管理操作。
Temporary table
临时表中的数据,只保证存在于事务或者会话当中(取决于定义信息)。数据在会话当中是私有的,也就是说其他的会话只能看到自己会话内更改的数据。
在创建临时表的时候,只需要指定临时表的生命周期范围,事务 or 会话 有效,而不需要指定它的存储参数,创建一个临时表,其实只是创建了临时表的定义信息。只有当在session内第一次插入数据的时候,才会在用户相应的临时表空间内非配temporary segment(一个segment可以被多个用户使用,只是分配各自的extent)。
临时表通常只有定义信息,并且数据存放是动态的。可以存放于同一个temporary tablespace , 也可以是不同的。比如user 1 default temporary tablespace 为temp 1 ,user 2 为temp 2 ,那么u1 存储临时数据到 temp1 中,u2 存储临时表数据到temp2 中。
虽然临时表数据的存储是动态的,但是因为临时表的定义信息是静态的,所以也可以创建索引在临时表上,数据的存放也与临时表类似,在第一次使用的时候分配临时segemnt。当然,也可以创建视图、触发器在临时表上。
什么时候需要使用Temporary Tablespace
首先就是当使用临时表的时候多个用户会共享使用一个temporarysegment,还有hashing,bitmap merge,然后就是排序操作了,当操作需要使用的内存空间大于sort_area_size的时候,就会使用临时表空间做为临时存储,进行排序操作,以下是需要排序的操作,也就是说有可能使用临时表空间的操作。
- Index creation.
创建索引的时候,服务器进程在构建tree之前按照索引值排序好(这可能会在临时表空间中进行)。排序完成后,会在indextablespace中使用临时segment构建最终的index,一旦索引构建结束,segment type改变为index 。(如果创建index失败,则需要smon来负责清理这些index tablespace中的临时空间)
- ORDER BY or GROUP BY clauses of SELECTstatements.
- DISTINCT values of SELECT statements.
需要排序来消除重复值
- UNION, INTERSECTor MINUS operations.
因为需要消除重复值,所以需要排序操作(这里不包括unionall)
- Sort-Merge joins.
如果没有索引可用,一个等值连接需要分别执行全表所描和排序操作。然后排序好的rowsource会被合并在一起,取出两个rowsource 中匹配的行。
- Analyze command execution.
分析、收集统计信息的时候会需要排序操作。优化器需要收集的统计信息在附录2
-Others
比如说创建主键,createtable as select 等操作。

InnoDBBufferPool reduces disk I/O by caching data and indexing pages, improving database performance. Its working principle includes: 1. Data reading: Read data from BufferPool; 2. Data writing: After modifying the data, write to BufferPool and refresh it to disk regularly; 3. Cache management: Use the LRU algorithm to manage cache pages; 4. Reading mechanism: Load adjacent data pages in advance. By sizing the BufferPool and using multiple instances, database performance can be optimized.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

MySQL is worth learning because it is a powerful open source database management system suitable for data storage, management and analysis. 1) MySQL is a relational database that uses SQL to operate data and is suitable for structured data management. 2) The SQL language is the key to interacting with MySQL and supports CRUD operations. 3) The working principle of MySQL includes client/server architecture, storage engine and query optimizer. 4) Basic usage includes creating databases and tables, and advanced usage involves joining tables using JOIN. 5) Common errors include syntax errors and permission issues, and debugging skills include checking syntax and using EXPLAIN commands. 6) Performance optimization involves the use of indexes, optimization of SQL statements and regular maintenance of databases.

MySQL is suitable for beginners to learn database skills. 1. Install MySQL server and client tools. 2. Understand basic SQL queries, such as SELECT. 3. Master data operations: create tables, insert, update, and delete data. 4. Learn advanced skills: subquery and window functions. 5. Debugging and optimization: Check syntax, use indexes, avoid SELECT*, and use LIMIT.

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.

MySQL is an open source relational database management system that is widely used in Web development. Its key features include: 1. Supports multiple storage engines, such as InnoDB and MyISAM, suitable for different scenarios; 2. Provides master-slave replication functions to facilitate load balancing and data backup; 3. Improve query efficiency through query optimization and index use.

SQL is used to interact with MySQL database to realize data addition, deletion, modification, inspection and database design. 1) SQL performs data operations through SELECT, INSERT, UPDATE, DELETE statements; 2) Use CREATE, ALTER, DROP statements for database design and management; 3) Complex queries and data analysis are implemented through SQL to improve business decision-making efficiency.

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software