Routine Oracle Database tablespace operations

Source: Internet
Author: User

Question: As an Oracle DBA, it is inevitable to perform some operations on the tablespace in the database. This is an operation that I often perform when managing the database. It is recorded here, they are all presented in the form of examples. One is to facilitate your reference in your work, and the other is to share with you!

Note:A single data file cannot exceed 32 GB, which is often forgotten.

(1) create a data table space:
Example 1:
CREATE TABLESPACE USERS
LOGGING
DATAFILE '/dev/raw/raw6' SIZE 7996 M autoextend on
Extent management local segment space management auto;

Example 2:
Create tablespace MLEE_DATA
LOGGING
DATAFILE '/dev/raw/raw1400' SIZE 29996 M,
'/Dev/raw/raw1401' SIZE 29996 M,
'/Dev/raw/raw1402' SIZE 29996 M
Extent management local segment space management auto;

(2) create a temporary tablespace:
Create temporary tablespace zfmi_temp tempfile 'd: \ oracle \ oradata \ zfmi \ zfmi_temp.dbf 'size 32 m autoextend on next 32 m maxsize 2048 m extent management local;

Create temporary tablespace MLEE_TEMP tempfile '/dev/raw/raw1405' size 9996 M autoextend off extent management local;

(3) create an UNDO tablespace:
Create undo tablespace undotbs datafile '/opt/oracle/product/9.2.0.4/dbs/undo01.dbf' SIZE 200 m autoextend on next 4096 k


(4) Add a data file to the tablespace (the undo tablespace can be resized in the same way as www.bkjia.com ):
Alter tablespace tablespacename add datafile '/u02/oradata/$ ORACLE_SID/datafilename 'size128m autoextend on next 2048 K maxsize2048M

To resize a temporary tablespace, use the following statement:
Alter tablespace & tablespace_name add tempfile '/oradata/temp01.dbf' SIZE 2G;

SQL> alter database tempfile '/dev/raw/raw2507' resize 20470 M; -- increase the temporary tablespace file to about 20 GB.

(5) Clear temporary tablespace:
Alter tablespace temp shrink space;
In this way, all data in the temporary tablespace is cleared, and the temp usage is 0%.


(6) modify the tablespace Name:
You cannot modify the tablespace name before oracle10g unless it is rebuilt;
Oracle10g supports online modification and the syntax is simple:
Alter tablespace tablespacename_old rename to tablespacename_new;

(7) delete a tablespace:
Drop tablespace RMC_DATA including contents and datafiles cascade onstraints;

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.