How to place tables and indexes in different tablespaces in Oracle

Source: Internet
Author: User
Oracle does not distinguish whether tables or indexes are stored in tablespaces. When the data volume is small, you can place tables and indexes in the same tablespace. However, as the data volume increases, it is best to separate the tables and indexes and store them in different tablespaces because: 1) improve performance: Try to store the tablespaces of the tables and indexes on different disks to make them different.

Oracle does not distinguish whether tables or indexes are stored in tablespaces. When the data volume is small, you can place tables and indexes in the same tablespace. However, as the data volume increases, it is best to separate the tables and indexes and store them in different tablespaces because: 1) improve performance: Try to store the tablespaces of the tables and indexes on different disks to make them different.

Oracle does not distinguish whether tables or indexes are stored in tablespaces. When the data volume is small, you can place tables and indexes in the same tablespace. However, as the data volume increases, it is better to store the table and index separately in different tablespaces.

Because:
1) Performance Improvement: Try to store tablespaces of tables and indexes on different disks and split the two types of data with different IO properties. This will improve the overall I/O performance of the disk;

2) Ease of management: imagine that if the index data file is damaged, you only need to create an index without causing data loss.

The following statement is used to move the index tablespace:

The Code is as follows:


Alter index INDEX_OWNER.INDEX_NAME rebuild tablespace NEW_TBS;


You can also use the following statement to obtain all statements for moving the index tablespace in a schema:

The Code is as follows:


Select 'alter Index' | owner | '.' | index_name | 'rebuild tablespace NEW_TBS ;'
From dba_indexes
Where table_owner = 'schema _ name'
Order by index_name;


Note that once the table and index are placed in different tablespaces, when creating a new table, if the table has a primary key or unique constraint, remember to specify the tablespace to the index, see the following example:

The Code is as follows:


Create table tmp (
MON VARCHAR2 (6 ),
IDNO VARCHAR2 (10 ),
Constraint pk_name primary key (MON, IDNO)
Using index tablespace index_tbs,
CONSTRAINT uk_name UNIQUE (MON)
Using index tablespace index_tbs
);

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.