Script for generate the Tablespace and Alter Tablespace Useful for Export and Import(Exdp and impdp) and DB Migration using expdp and impdp

Script for generate the Tablespace and Alter Tablespace  Useful for Export and Import(exdp and impdp) and DB migration using expdp and impdp


-- User Case: Useful for Export and Import(Exdp and impdp)
-- DB Migration Using expdp and impdp

set echo off heading off termout off feed off pages 0 numwidth 10 linesize 80
spool create_ts.sql
select 'set echo off termout off feed off pages 0' || chr(10) ||
       'spool create_ts.lis'
from dual
/
--
-- 1st: For each tablespace, select the first datafile that was
-- created and create this again as first file for this (each) tablespace
--
select 'CREATE TABLESPACE ' || f1.tablespace_name || chr(10) ||
       ' DATAFILE ' || '''' || f1.file_name || '''' || ' SIZE ' || '2G' || chr(10) ||
       ' AUTOEXTEND ON NEXT 100M MAXSIZE UNLIMITED' ||
       ';'
from dba_tablespaces t1, dba_data_files f1
where f1.tablespace_name = t1.tablespace_name
and f1.tablespace_name not in('SYSTEM','USERS','UNDOTBS1','SYSAUX')
and f1.file_id = (select min(f2.file_id)
                    from dba_data_files f2
                   where f2.tablespace_name = f1.tablespace_name)
order by f1.file_id
/
--
-- 2nd: For each tablespace, create additional datafiles if any there.
--
select 'ALTER TABLESPACE ' || f1.tablespace_name || chr(10) ||
       ' ADD DATAFILE ' || '''' || f1.file_name || '''' || ' SIZE ' || '2G' || chr(10) || ' AUTOEXTEND ON NEXT 100M MAXSIZE UNLIMITED'||';'
from dba_data_files f1
where f1.tablespace_name not in('SYSTEM','USERS','UNDOTBS1','SYSAUX')
and f1.file_id > (select min(f2.file_id)
                    from dba_data_files f2
where f2.tablespace_name = f1.tablespace_name)
order by f1.file_id
/
--
-- 3rd: For each temporary tablespace, create additional tempfile if any there.
--
select 'CREATE TEMPORARY TABLESPACE ' || f1.tablespace_name || chr(10) ||
       ' TEMPFILE ' || '''' || f1.file_name || '''' || ' SIZE ' || '2G' || chr(10) ||
       ' AUTOEXTEND ON NEXT 100M MAXSIZE UNLIMITED' ||
       ';'
from dba_tablespaces t1, dba_temp_files f1
where f1.tablespace_name = t1.tablespace_name
and f1.tablespace_name not in('SYSTEM','USERS','UNDOTBS1','SYSAUX')
and f1.file_id = (select min(f2.file_id)
                    from dba_temp_files f2
                   where f2.tablespace_name = f1.tablespace_name)
order by f1.file_id
/
--
-- 4th: For each temporary tablespace, create additional tempfiles if any there.
--
select 'ALTER TABLESPACE ' || f1.tablespace_name || chr(10) ||
       ' ADD TEMPFILE ' || '''' || f1.file_name || '''' || ' SIZE ' || '2G' || chr(10) || ' AUTOEXTEND ON NEXT 100M MAXSIZE UNLIMITED'||';'
from dba_temp_files f1
where f1.tablespace_name not in('SYSTEM','USERS','UNDOTBS1','SYSAUX')
and f1.file_id > (select min(f2.file_id)
                    from dba_temp_files f2
where f2.tablespace_name = f1.tablespace_name)
order by f1.file_id
/
select 'spool off;' from dual
/
spool off;
appsdbahelp

17+ years of experience in Oracle Database, Oracle Cloud Infrastructure(OCI), Oracle EBS on Cloud, Oracle E-Business Suite, DevOps tools, Oracle WebLogic, Oracle Application Server, Oracle Access Manager and various Operating System flavors including Redhat Linux, UNIX (Solaris, HP-UX) and Windows. Expert in Oracle9i/10g/11g/12c/19c database administration, upgrade, configuration and tuning. Experience in Oracle E-Business Suite technological stack, including architecture, installation, configuration, maintenance, tuning, cloning and patching procedures. Expert in Oracle Cloud Infrastructure(OCI), Oracle EBS On Cloud and Oracle EBS Cloud Manager Experience with Oracle Cloud Solution and Expert of Oracle ERP/Oracle HCM Cloud deployment Experience in Terraform, JSON and chef cloud infrastructure automation framework Knowledge of ASM, Data Guard, Real Application Cluster, Exadata and Exalogic Knowledge of Oracle Enterprise Manager(OEM) Grid Control, Oracle WebLogic, Oracle Internet Directory, Oracle Access Manager and Apache Ability to analyze problem, develops solutions and bring program/project execution to completion.

Post a Comment

Previous Post Next Post