Basic Maintenance of Oracle tablespace and data files

Source: Internet
Author: User

Some basic concepts:
A tablespace can belong to only one database at a time;
In addition to the SYSTEM tablespace or the tablespace with active rollback segments, other tablespaces can be taken offline;
Table space can be switched between read/write and read-only statuses;
A data file can belong to only one tablespace;
Segments cannot span tablespaces, But segments can span multiple data files belonging to the same tablespace;
A zone may not span data files; it must exist in a data file;
For Oracle, tablespaces are mainly divided into system and other non-system tablespaces, or into important and unimportant tablespaces, how can I store my business data in the XXX tablespace? But oracle does, because the database can run as long as the system tablespace exists.
Some commands:

Create a tablespace
Create tablespace mytb1 datafile '/u01/oradata/mytb01.dfb 'size 10 m autoextend on next 5 m maxsize 1024 M;
Create tablespace mytb1 datafile '/u01/oradata/mytb01.dfb' SIZE 10 m autoextend on next 5 m maxsize unlimited;
Create tablespace mytb1 datafile '/u01/oracle/9i/oradata/gt9i/mytb01.dbf' size 10 m autoextend off, '/u01/oracle/9i/oradata/gt9i/mytb02.dbf' size 10 m autoextend off;
Create temporary tablespace mytbtmp1 TEMPFILE '/u01/oradata/mytbtmp1.dfb 'size 10 m autoextend on next 5 m maxsize 10240 M;
CREATE undo TABLESPACE mytbtmp1 TEMPFILE '/u01/oradata/mytbtmp1.dfb 'size 10 m autoextend on next 5 m maxsize 10240 M;

About temporary tablespace
Cannot set read-only
Cannot rename
Always nologging
Not backed up
Not restored

Offline tablespace
Alter tablespace mytb1 offline; -- note that there are four options. The default value is normal, TEMPORARY | IMMEDIATE | for recover.
Bring tablespaces online
Alter tablespace mytb1 online;

Read-Only tablespace
Alter tablespace mytb1 read only;
Read and Write tablespaces
Alter tablespace mytb1 read write;

Add data files
Alter tablespace mytb1 add datafile '/u01/oracle/9i/oradata/gt9i/mytb01.dbf' size 10 m;

Resize data files
Alter tablespace mytb1 datafile '/u01/oracle/9i/oradata/gt9i/mytb01.dbf' resize 10 m;

Move data files
Alter tablespace mytb1 rename datafile '/u01/oracle/9i/oradata/gt9i/mytb01.dbf' to '/u01/oracle/9i/oradata/gt9i/mytb02.dbf ';

Database-level mobile data files
Alter database rename file '/u01/oracle/9i/oradata/gt9i/mytb01.dbf' to '/u01/oracle/9i/oradata/gt9i/mytb02.dbf ';

Delete a tablespace
Drop tablespace mytb1 including contents and datafiles;
Drop tablespace mytb1 including contents cascade constraints;
-The End-

For more information about Oracle, see Oracle topics page http://www.bkjia.com/topicnews.aspx? Tid = 12

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.