The role of temp tablespace and the role of temp tablespace
The role of temp tablespace:
Temp tablespace is mainly used for sorting operations [such as creating indexes, order by and group by, distinct, union/intersect/minus/, sort-merge, join, analyze command], index [such as creating indexes, importing data using IMP
Data files and log files are the most important files in the database. They are where the data is stored. Each database has at least one data file associated with it, and usually more than one, there are many. How is the data organized in the data file? To understand this, we first have to understand what table spaces (tablespace), segments (segment), zones (extent), blocks, are the basic units in which the Oracle database organizes data in a data fil
Temporary Tablespace
Temporary Tablespace is used to store instantaneous data, which can be viewed only during session connection. Permanentobject cannot be created in temporarytablespace.
Space utilization principle:
It will not be monitored or recycled by smon. Instead, SEP (Sort Extent Pool) is used to record idle extent.
When you create a database in OracleDatabase, the default Temporary
that this situation is allowed ).Alter system kill session '2017 9'
7. delete a large temporary tablespace.
SQL> alter tablespace temp tempfile offline; --> take it offline first
Tablespace altered.
SQL> drop tablespace temp including contents and datafiles; --> Delete temp
When creating a user, there is a default tablespace parameter. You can view the view database_properties to see the corresponding information.
SQL> select a. property_name, A. property_value from database_properties A where a. property_name like '% default % ';
Property_name property_value
--------------------------------------------------
Default_temp_tablespace temp
Default_permanent_tablespace users
Default_tbs_type smallfile
SQL> alter database de
When creating a user,There is a default tablespace Parameter.You can view the viewDatabase_propertiesYou can see the corresponding information.
SQL> select a. property_name, a. property_value from database_properties a where a. property_name like '% DEFAULT % ';
PROPERTY_NAMEPROPERTY_VALUE
--------------------------------------------------
DEFAULT_TEMP_TABLESPACETEMP
DEFAULT_PERMANENT_TABLESPACEUSERS
DEFAULT_TBS_TYPESMALLFILE
SQL>Alter database defaul
process will release the temporary segment and clean up the temp tablespace. However, in many cases, our database cannot be down, therefore, this method lacks some application opportunities, but it is still very useful.4. Using Event diagnosis is also the most effective method.1. Determine the Ts of the temp tablespace #SQL> select ts #, name from SYS. Ts $;TS # Name----------------------------------------
Table Space:
Oracle's UNDOTBS01.DBF file is too big a solution
1. Prohibit undo tablespace automatic growth
ALTER DATABASE datafile ' FULL_PATH/UNDOTBS01.DBF ' autoextend off;
2.--Create a new small space for the undo Tablespace
Create undo tablespace undotBS2 DataFile ' Full_path/undotbs02. DBF ' size 100m;
--Set the new table space for the system Undo_tablespa
on the dictionary SYS. Fet $ and SYS. uet $ are not required; competition for data dictionary is reduced; UNDO records are not generated; and periodic merge operations are no longer required.
For example, a local table space is created and the size of the interval is allocated to 64 KB.SQL> Create tablespace demoDatafile '/ora01/OEM/oemdemo01.dbf' size 10 mExtent management local uniform size 64 K;
Query the table select * From dba_tablespace;
Automa
Check the tables that use the shared tablespace and the shared tablespace.Check tables that use the shared tablespace
Recently I took over a new database machine and found that some tables in some databases do not have ibd files but frm files, while ibdata1 files have a total of 20 GB +. It is estimated that the shared tablespace is used.
Stored in the ibdata1 F
. SQL> alter tablespace TMP3 tablespace GROUP TMPGRP; Tablespace altered. 5. Check the information about the temporary tablespace group in the system again. SQL> select * from dba_tablespace_groups; GROUP_NAME TABLESPACE_NAME -------------------------- TMPGRP TMP1TMPGRP TMP2TMPGRP TMP3TMPGRP TMP4 6. remove temporary
. net undo tablespace.
The VB. net undo tablespace being used by the current routine cannot be deleted. If you are sure to delete the UNDO tablespace being used by the current routine, you should first switch the UNDO tablespace. Then, delete the corresponding UNDO tablespace
Shutdown immediate
-- Restart the service
Startup
-- Delete the original hybrid tablespace
Drop tablespace undotbs1 including contents and datafiles;
-- Create the original undo tablespace
Create undo tablespace undotbs1 datafile '/opt/app/oracle/oradata/orcl/undotbs01.dbf'
Table space name and status information:
Select * From dba_tablespaces;
Table space creation statement:
Select dbms_metadata.get_ddl ('tablespace', ts. tablespace_name)
From dba_tablespaces ts;
---- View the tablespace information of the databaseSelect * from V $ datafile;
Select * -- segment_name, sum (bytes)/1024From user_extents group by segment_name;
-- 1. view the remaining
. sm $ ts_avail A, SYS. sm $ ts_used B, SYS. sm $ ts_free CWhere a. tablespace_name = B. tablespace_name and A. tablespace_name = C. tablespace_name;
///////////////////////////////////////////////////////////////////////////
1. Go to Oracle # Su-oracleas4101> LSNRCTL startas4101> connect internal; svrmgrl> shutdown immediate; svrmgrl> startup 2. Check the table spaces svrmgrl> select * From dba_tablespaces; system RBS temp tools users 3. Set the users table
Oracle tablespace to view SQL usage, oracle tablespace SQL
In daily work, the most important thing for DBA is to check the usage of the tablespace to check whether the tablespace is full.
The procedure is as follows:
Step 1: Open PLSQL
Step 2: Create an SQL window
Step 3: Enter the code:
select a.tablespace_name table
:-- Query the default temporary tablespaceSelect * from database_properties where property_name = 'default _ TEMP_TABLESPACE ';-- Modify the default temporary tablespaceAlter database default temporary tablespace temp1;All users' default temporary tablespace will be switched to the new temporary tablespace:Select username, temporary_tablespace, default _ from dba_users;-- Change the temporary
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.