每一个Oracle版本,都会有很多新特性和技术推出。这些技术特性,在很大程度上都能改进Oracle运行效率和应用效果,或者提高我们日
每一个Oracle版本,都会有很多新特性和技术推出。这些技术特性,在很大程度上都能改进Oracle运行效率和应用效果,或者提高我们日常工作能力。
Temp表空间是Oracle表空间体系中一种很特殊的表空间对象。临时表空间主要用于支持临时表空间使用、排序分组动作空间溢出暂存等作用。我们对Temp的使用,大都是局限在空间分配和大小设置上。在11g有,有一系列针对Temp表空间的新特性,可以很大程度上帮助我们工作。
视图dba_temp_free_space是11g引入的一个新视图,用于描述临时表空间使用情况。
--------------------------------------分割线 --------------------------------------
相关阅读:
Oracle Undo 镜像数据探究
Oracle 回滚(ROLLBACK)和撤销(Undo)
Undo 表空间损坏导致无法open
Undo表空间失败的处理方法
Oracle Undo表空间重建与恢复
--------------------------------------分割线 --------------------------------------
SQL> select * from dba_temp_free_space;
TABLESPACE_NAME TABLESPACE_SIZE ALLOCATED_SPACE FREE_SPACE
--------------- --------------- --------------- ----------
TEMP 481296384 481296384 479199232
最近和一个朋友聊起其中allocated_space和free_space的含义,觉得很有意思。笔者决定通过一些实验来证明结论。
1、环境准备
笔者使用Oracle11gR2环境进行测试。
SQL> select * from v$version;
BANNER
------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
PL/SQL Release 11.2.0.3.0 - Production
CORE 11.2.0.3.0 Production
TNS for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
当前仅包括默认的Temp临时表空间。
SQL> select file_name, file_id, tablespace_name from dba_temp_files;
FILE_NAME FILE_ID TABLESPACE_NAME
------------------------------ ---------- ------------------------------
/u01/app/oradata/ORA11G/datafi 1 TEMP
le/o1_mf_temp_92t73qm8_.tmp
说明:为减少系统对实验结果影响,笔者创建全新的临时表空间,通过一系列的典型操作来,监控字段变化形态来证明实验结论。
2、表空间创建过程
首先我们创建临时表空间temptest。之前,我们检查磁盘空间空闲情况:
[oracle@SimpleLinux ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 48G 24G 22G 52% /
tmpfs 6.0G 256M 5.8G 5% /dev/shm
/dev/mapper/VolGrp01-lv1
194M 5.6M 179M 4% /voltest01
当前/目录对应大小48G,使用24G,有22G可用空间。下面创建表空间:
SQL> create temporary tablespace temptest tempfile size 5G
2 extent management local uniform size 1m;
Tablespace created
和创建同样大小数据表空间相比起来,执行创建临时表空间语句速度很快。之后查看磁盘空间情况。
[oracle@SimpleLinux ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 48G 24G 22G 52% /
tmpfs 6.0G 256M 5.8G 5% /dev/shm
/dev/mapper/VolGrp01-lv1
194M 5.6M 179M 4% /voltest01
容量上没有任何变化,,如果Oracle创建了5G空间,至少会显示在磁盘大小上。但是,从Oracle内部注册体系和文件系统中,我们都是可以看到临时文件的生成。
SQL> select file_name, file_id, tablespace_name from dba_temp_files;
FILE_NAME FILE_ID TABLESPACE_NAME
------------------------------ ---------- ---------------
/u01/app/oradata/ORA11G/datafi 1 TEMP
le/o1_mf_temp_92t73qm8_.tmp
/u01/app/oradata/ORA11G/datafi 2 TEMPTEST
le/o1_mf_temptest_9j80859z_.tm
p
[oracle@SimpleLinux datafile]$ ls -l | grep temptest
-rw-r----- 1 oracle oinstall 5368717312 Feb 19 08:55 o1_mf_temptest_9j80859z_.tmp
这个是Oracle临时数据文件的特性,Oracle临时文件和数据文件不同,创建之后是不直接占满空间的。我们都有这样的经历,创建一个很大的数据表空间,create/add过程依据不同的系统IO情况,是很消耗时间的。但是临时文件不是,一个上十几G的临时文件可以在很快的创建成功。
但是,这个过程其实是“障眼法”。Oracle虽然创建了临时文件,文件系统中也分配显示大小文件,但是空间却没有真正的分配。这在一些文献中称为“稀疏文件”,文件架构范围都在,但是没有实际写入过程。TempFile中的allocated,也就与稀疏文件有关。
注意:这就告诉我们系统部署人员,要注意临时文件的这个特性,不要以为磁盘上有很多的空间。
此时,我们观察视图dba_temp_free_space,结果如下:
SQL> select * from dba_temp_free_space;
TABLESPACE_NAME TABLESPACE_SIZE ALLOCATED_SPACE FREE_SPACE
--------------- --------------- --------------- ----------
TEMP 481296384 481296384 480247808
TEMPTEST 5368709120 1048576 5367660544
Tablespace_size为5368709120bytes大小,折合5G。这就是我们对临时表空间Temptest的定义值。

MySQLviewshavelimitations:1)Theydon'tsupportallSQLoperations,restrictingdatamanipulationthroughviewswithjoinsorsubqueries.2)Theycanimpactperformance,especiallywithcomplexqueriesorlargedatasets.3)Viewsdon'tstoredata,potentiallyleadingtooutdatedinforma

ProperusermanagementinMySQLiscrucialforenhancingsecurityandensuringefficientdatabaseoperation.1)UseCREATEUSERtoaddusers,specifyingconnectionsourcewith@'localhost'or@'%'.2)GrantspecificprivilegeswithGRANT,usingleastprivilegeprincipletominimizerisks.3)

MySQLdoesn'timposeahardlimitontriggers,butpracticalfactorsdeterminetheireffectiveuse:1)Serverconfigurationimpactstriggermanagement;2)Complextriggersincreasesystemload;3)Largertablesslowtriggerperformance;4)Highconcurrencycancausetriggercontention;5)M

Yes,it'ssafetostoreBLOBdatainMySQL,butconsiderthesefactors:1)StorageSpace:BLOBscanconsumesignificantspace,potentiallyincreasingcostsandslowingperformance.2)Performance:LargerrowsizesduetoBLOBsmayslowdownqueries.3)BackupandRecovery:Theseprocessescanbe

Adding MySQL users through the PHP web interface can use MySQLi extensions. The steps are as follows: 1. Connect to the MySQL database and use the MySQLi extension. 2. Create a user, use the CREATEUSER statement, and use the PASSWORD() function to encrypt the password. 3. Prevent SQL injection and use the mysqli_real_escape_string() function to process user input. 4. Assign permissions to new users and use the GRANT statement.

MySQL'sBLOBissuitableforstoringbinarydatawithinarelationaldatabase,whileNoSQLoptionslikeMongoDB,Redis,andCassandraofferflexible,scalablesolutionsforunstructureddata.BLOBissimplerbutcanslowdownperformancewithlargedata;NoSQLprovidesbetterscalabilityand

ToaddauserinMySQL,use:CREATEUSER'username'@'host'IDENTIFIEDBY'password';Here'showtodoitsecurely:1)Choosethehostcarefullytocontrolaccess.2)SetresourcelimitswithoptionslikeMAX_QUERIES_PER_HOUR.3)Usestrong,uniquepasswords.4)EnforceSSL/TLSconnectionswith

ToavoidcommonmistakeswithstringdatatypesinMySQL,understandstringtypenuances,choosetherighttype,andmanageencodingandcollationsettingseffectively.1)UseCHARforfixed-lengthstrings,VARCHARforvariable-length,andTEXT/BLOBforlargerdata.2)Setcorrectcharacters


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

SublimeText3 English version
Recommended: Win version, supports code prompts!

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

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

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

WebStorm Mac version
Useful JavaScript development tools
