Thursday, March 1, 2012

Striping Tables and Indexes across multiple disks at Table Level and Index Level

Step 1 : Login as 'SYS' as user and create tablespace
SQL> conn sys/oracle@db as sysdba

SQL> create tablespace TBFES datafile 'D:\db\TBFES01.dbf' size 10m autoextend on next 5m maxsize unlimited
Tablespace created.

SQL> create tablespace PRD datafile 'D:\db\PRD01.dbf' size 10m autoextend on next 5m maxsize unlimited
Tablespace created.

SQL> create user scott identified by oracle default tablespace PRD
User created.

Step 2 : Grant privileges to user
SQL> grant CONNECT,RESOURCE,CREATE TABLE,CREATE ANY PROCEDURE,CREATE SYNONYM,DEBUG ANY PROCEDURE,
           DEBUG CONNECT SESSION,CREATE ANY JOB,
           CREATE TYPE,CREATE VIEW,MANAGE ANY QUEUE,MANAGE SCHEDULER
Grant succeeded.

SQL> grant UNLIMITED TABLESPACE to scott
Grant succeeded.
SQL> grant execute on dbms_sqlhash to scott
Grant succeeded.
SQL> grant execute on dbms_scheduler to scott
Grant succeeded.
SQL> grant execute on dbms_lock to scott
Grant succeeded.
SQL> grant execute on dbms_job to scott
Grant succeeded.
SQL> create or replace directory imp as 'D:\volume'
Directory created.
SQL> grant read,write on directory imp to scott
Grant succeeded.

Step 3 : Check the autoextensible and size for created tablespaces
SQL> select file_name,autoextensible,bytes/1024/1024 MB from dba_data_files where tablespace_name in ('PRD','TBFES')

FILE_NAME                                     AUT         MB                                                                                         
--------------------------------------------- --- ----------                                                                                         
D:\DB\TBFES01.DBF                             YES         10                                                                                         
D:\DB\PRD01.DBF                               YES         10                                                                                         

Step 4 : BEFORE IMPORTING expdp_scott_exclude_comp_19022012.dmp tablespace size
SQL> select file_name,autoextensible,bytes/1024/1024 MB from dba_data_files where tablespace_name in ('PRD','TBFES')

FILE_NAME                                     AUT         MB                                                                                         
--------------------------------------------- --- ----------                                                                                         
D:\DB\TBFES01.DBF                             YES         10                                                                                         
D:\DB\PRD01.DBF                               YES         10                                                                                         

Step 5 : IMPORTING expdp_scott_exclude_comp_19022012.dmp
SQL> host impdp directory=imp dumpfile=expdp_scott_exclude_comp_19022012.dmp logfile=imp.log parallel=4 remap_schema=scott:scott tables=scott.tableext transform=oid:y:type

Step 6 : CREATING DATAFILES in DIFFERENT PARTITIONS
SQL> alter tablespace tbfes add datafile 'H:\DB\TBFES01.dbf' size 10m autoextend on next 2m maxsize unlimited;
Tablespace altered.

SQL> alter tablespace tbfes add datafile 'I:\DB\TBFES01.dbf' size 10m autoextend on next 2m maxsize unlimited;
Tablespace altered.

SQL> alter tablespace PRD add datafile 'I:\DB\PRD01.dbf' size 10m autoextend on next 2m maxsize unlimited;
Tablespace altered.

SQL> alter tablespace PRD add datafile 'H:\DB\PRD01.dbf' size 10m autoextend on next 2m maxsize unlimited;
Tablespace altered.

Step 7 : Allocate an extent for the tableext table of the SCOTT schema on the newly-created data file
SQL> conn scott/oracle@db
Connected.

SQL> alter table tableext allocate extent (datafile 'D:\DB\tbfes01.dbf'size 1M)
Table altered.

SQL> alter table tableext allocate extent (datafile 'H:\DB\tbfes01.dbf' size 1M)
Table altered.

SQL> alter table tableext allocate extent (datafile 'I:\DB\tbfes01.dbf' size 1M)
Table altered.

SQL> conn sys/oracle@db as sysdba
Connected.

Step 8 : AFTER IMPORT and ADDING DATAFILES TABLESPACE SIZE
SQL> select file_name,autoextensible,bytes/1024/1024 MB from dba_data_files where tablespace_name in ('PRD','TBFES');

FILE_NAME                                     AUT         MB                                                                                         
--------------------------------------------- --- ----------                                                                                         
D:\DB\TBFES01.DBF                             YES        805                                                                                         
D:\DB\PRD01.DBF                               YES        470                                                                                         
H:\DB\TBFES01.DBF                             YES         10                                                                                         
I:\DB\TBFES01.DBF                             YES         10                                                                                         
I:\DB\PRD01.DBF                               YES         10                                                                                         
H:\DB\PRD01.DBF                               YES         10                                                                                         

6 rows selected.

Step 9 : IMPORTING INCREMENTED DUMP
SQL> host impdp directory=imp dumpfile=26022012.dmp logfile=log1.log parallel=4 remap_schema=scott:scott tables=scott.tableext table_exists_action=append exclude=indexes

SQL> select file_name,autoextensible,bytes/1024/1024 MB from dba_data_files where tablespace_name in ('PRD','TBFES');

FILE_NAME                                     AUT         MB                                                                                         
--------------------------------------------- --- ----------                                                                                         
D:\DB\TBFES01.DBF                             YES       1195                                                                                         
D:\DB\PRD01.DBF                               YES        635                                                                                         
H:\DB\TBFES01.DBF                             YES        358                                                                                         
I:\DB\TBFES01.DBF                             YES        338                                                                                         
I:\DB\PRD01.DBF                               YES        186                                                                                         
H:\DB\PRD01.DBF                               YES        172                                                                                         

6 rows selected.

No comments:

Post a Comment