Showing posts with label Oracle Database. Show all posts
Showing posts with label Oracle Database. Show all posts

Thursday 19 March 2020

Database installation using DBCA Silent installation with custom Template on 12C

oracle@s8:/u01/app/oracle/product/12.1.0/dbhome_1/bin> ./dbca -silent -createDatabase -templateName Teamcenter_Oracle.dbt -gdbName SMRTESTENV -sid SMRTESTENV -sysPassword system123 -systemPassword system123 -emConfiguration NONE -characterSet AL32UTF8
Creating and starting Oracle instance
2% complete
3% complete
4% complete
11% complete
Creating database files
12% complete
13% complete
14% complete
22% complete
Creating data dictionary views
25% complete
32% complete
33% complete
34% complete
35% complete
36% complete
37% complete
38% complete
39% complete
40% complete
41% complete
42% complete
43% complete
44% complete
45% complete
52% complete
55% complete
56% complete
58% complete
Completing Database Creation
62% complete
65% complete
68% complete
69% complete
70% complete
80% complete
90% complete
92% complete
Running Custom Scripts
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/SMRTESTENV/SMRTESTE.log" for further details.
Database creation complete. For details check the logfiles at:
 /u01/app/oracle/cfgtoollogs/dbca/SMRTESTENV.
Database Information:
Global Database Name:SMRTESTENV
System Identifier(SID):SMRTESTENV

oracle@sgdcpl08:/u01/app/oracle/product/12.1.0/dbhome_1/bin>

Check Template Teamcenter_Oracle.dbt on link

Drop Oracle database Manually

oracle@8:~> . oraenv
ORACLE_SID = [] ? zabbixdr
The Oracle base remains unchanged with value /u01/app/oracle

oracle@8:~> sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Thu Mar 19 08:49:16 2020

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area 4294967296 bytes
Fixed Size                  2932632 bytes
Variable Size             536871016 bytes
Database Buffers         3741319168 bytes
Redo Buffers               13844480 bytes
Database mounted.
Database opened.
SQL> @d

NAME      INSTANCE_NAME    DB_UNIQUE_NAME                 OPEN_MODE            DATABASE_ROLE    CURRENT_SCN        FAILOVER_SCN
--------- ---------------- ------------------------------ -------------------- ---------------- ------------------ ----------------------------------------
SMRKORID  zabbixdr        zabbixdr                      READ WRITE           PRIMARY          NO                 0

SQL> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup mount exclusive restrict;
ORACLE instance started.

Total System Global Area 4294967296 bytes
Fixed Size                  2932632 bytes
Variable Size             536871016 bytes
Database Buffers         3741319168 bytes
Redo Buffers               13844480 bytes
Database mounted.

SQL> !cat d.sql
set lines 200
select name, instance_name,db_unique_name, open_mode, database_role, flashback_on  current_scn,to_char(standby_became_primary_scn) failover_scn from v$database,v$instance;

SQL>


SQL>  @d


NAME      INSTANCE_NAME    DB_UNIQUE_NAME                 OPEN_MODE            DATABASE_ROLE    CURRENT_SCN        FAILOVER_SCN
--------- ---------------- ------------------------------ -------------------- ---------------- ------------------ ----------------------------------------
SMRKORID  zabbixdr        zabbixdr                      MOUNTED              PRIMARY          NO                 0

SQL> drop database;

Database dropped.

Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL>

alert.log file

drop database
Mon Mar 08 16:55:36 2021
Deleted file /u01/app/oracle/oradata/zabbixdr/system01.dbf
Deleted file /u01/app/oracle/oradata/zabbixdr/sysaux01.dbf
Deleted file /u01/app/oracle/oradata/zabbixdr/undotbs01.dbf
Deleted file /u01/app/oracle/oradata/zabbixdr/pdbseed/system01.dbf
Deleted file /u01/app/oracle/oradata/zabbixdr/users01.dbf
Deleted file /u01/app/oracle/oradata/zabbixdr/pdbseed/sysaux01.dbf
Deleted file /u01/app/oracle/oradata/zabbixdr/pdb1/system01.dbf
Deleted file /u01/app/oracle/oradata/zabbixdr/pdb1/sysaux01.dbf
Deleted file /u01/app/oracle/oradata/zabbixdr/pdb1/pdb1_users01.dbf
Deleted file /u01/app/oracle/oradata/zabbixdr/redo01.log
Deleted file /u01/app/oracle/oradata/zabbixdr/redo02.log
Deleted file /u01/app/oracle/oradata/zabbixdr/redo03.log
Deleted file /u01/app/oracle/oradata/zabbixdr/redo04.log
Deleted file /u01/app/oracle/oradata/zabbixdr/redo05.log
Deleted file /u01/app/oracle/oradata/zabbixdr/redo06.log
Deleted file /u01/app/oracle/oradata/zabbixdr/redo07.log
Deleted file /u01/app/oracle/oradata/zabbixdr/temp01.dbf
Deleted file /u01/app/oracle/oradata/zabbixdr/pdbseed/pdbseed_temp012021-02-16_05-38-06-PM.dbf
Deleted file /u01/app/oracle/oradata/zabbixdr/pdb1/temp012021-02-16_05-38-06-PM.dbf
Stopping background process RVWR
Starting background process RSM0
Mon Mar 08 16:55:36 2021
RSM0 started with pid=29, OS id=4553
Deleted Oracle managed file /u01/app/oracle/fast_recovery_area/ZABBIXDR/flashback/o1_mf_j2t9qj0p_.flb
Deleted Oracle managed file /u01/app/oracle/fast_recovery_area/ZABBIXDR/flashback/o1_mf_j2t9qncv_.flb
Deleted Oracle managed file /u01/app/oracle/fast_recovery_area/ZABBIXDR/flashback/o1_mf_j2tly5jo_.flb
Deleted Oracle managed file /u01/app/oracle/fast_recovery_area/ZABBIXDR/flashback/o1_mf_j2vh1307_.flb
Deleted Oracle managed file /u01/app/oracle/fast_recovery_area/ZABBIXDR/flashback/o1_mf_j2w44w63_.flb
Deleted Oracle managed file /u01/app/oracle/fast_recovery_area/ZABBIXDR/flashback/o1_mf_j2z99v3c_.flb
Deleted Oracle managed file /u01/app/oracle/fast_recovery_area/ZABBIXDR/flashback/o1_mf_j2z9bsf4_.flb
Deleted Oracle managed file /u01/app/oracle/fast_recovery_area/ZABBIXDR/flashback/o1_mf_j2z9clx4_.flb
Deleted Oracle managed file /u01/app/oracle/fast_recovery_area/ZABBIXDR/flashback/o1_mf_j2zt0wq6_.flb
Deleted Oracle managed file /u01/app/oracle/fast_recovery_area/ZABBIXDR/flashback/o1_mf_j31xrxfl_.flb
Deleted Oracle managed file /u01/app/oracle/fast_recovery_area/ZABBIXDR/flashback/o1_mf_j33knsy7_.flb
Deleted Oracle managed file /u01/app/oracle/fast_recovery_area/ZABBIXDR/flashback/o1_mf_j34oh724_.flb
Deleted Oracle managed file /u01/app/oracle/fast_recovery_area/ZABBIXDR/flashback/o1_mf_j35ozjhl_.flb
Flashback Database Disabled
Deleted file /u01/app/oracle/product/12.1.0.2/db_1/dbs/snapcf_zabbixdr.f
Shutting down archive processes
Archiving is disabled
Mon Mar 08 16:55:37 2021
ARCH shutting down
ARC3: Archival stopped
Mon Mar 08 16:55:37 2021
ARCH shutting down
ARC2: Archival stopped
Mon Mar 08 16:55:37 2021
ARCH shutting down
ARC1: Archival stopped
Mon Mar 08 16:55:37 2021
ARCH shutting down
ARC0: Archival stopped
ALTER DATABASE MOUNT
ORA-750 signalled during: ALTER DATABASE MOUNT...

------------------- Same as primary single instance database  ------------------------------

oracle@test08:~> . oraenv
ORACLE_SID = [oracle] ? NEWSMRUPGR10
The Oracle base remains unchanged with value /u01/app/oracle
oracle@test08:~> sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Tue Aug 24 08:29:13 2021

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup mount exclusive restrict;
ORACLE instance started.

Total System Global Area 2147483648 bytes
Fixed Size                  3712904 bytes
Variable Size            1426065528 bytes
Database Buffers          704643072 bytes
Redo Buffers               13062144 bytes
Database mounted.
SQL> @d

NAME      INSTANCE_NAME    DB_UNIQUE_NAME                 OPEN_MODE            DATABASE_ROLE    CURRENT_SCN        FAILOVER_SCN
--------- ---------------- ------------------------------ -------------------- ---------------- ------------------ ----------------------------------------
NEWSMRUP  NEWSMRUPGR10     NEWSMRUPGR10                   MOUNTED              PRIMARY          NO                 0

SQL> drop database;

Database dropped.

Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL>

alert.log

Database mounted in Exclusive Mode
Lost write protection disabled
Completed: ALTER DATABASE   MOUNT
Tue Aug 24 08:30:56 2021
drop database
Tue Aug 24 08:30:56 2021
Deleted file /u04/db_backup/Flash_recovery_area/NEWSMRUPGR10/datafile1/u01/app/oracle/oradata/NEWSMRUPGR10/system01.dbf
Deleted file /u04/db_backup/Flash_recovery_area/NEWSMRUPGR10/datafile1/u01/app/oracle/oradata/NEWSMRUPGR10/sysaux01.dbf
Deleted file /u04/db_backup/Flash_recovery_area/NEWSMRUPGR10/datafile1/u01/app/oracle/oradata/NEWSMRUPGR10/undotbs01.dbf
Deleted file /u04/db_backup/Flash_recovery_area/NEWSMRUPGR10/datafile1/u01/app/oracle/oradata/NEWSMRUPGR10/idata01.dbf
Deleted file /u04/db_backup/Flash_recovery_area/NEWSMRUPGR10/datafile1/u01/app/oracle/oradata/NEWSMRUPGR10/ilog01.dbf
Deleted file /u04/db_backup/Flash_recovery_area/NEWSMRUPGR10/datafile1/u01/app/oracle/oradata/NEWSMRUPGR10/indx01.dbf
Deleted file /u01/app/oracle/oradata/NEWSMRUPGR10/redo01.log
Deleted file /u01/app/oracle/oradata/NEWSMRUPGR10/redo02.log
Deleted file /u01/app/oracle/oradata/NEWSMRUPGR10/redo03.log
Deleted file /u01/app/oracle/oradata/NEWSMRUPGR10/temp01.dbf
Deleted file /u01/app/oracle/product/12.1.0/dbhome_1/dbs/snapcf_NEWSMRUPGR10.f
Shutting down archive processes
Archiving is disabled

Wednesday 11 March 2020

Database Creation 12.1.0.1.0 and above using template Script



Database Creation 12.1.0.1.0 using template Script and above


There are 3 basic scripts to create database using dbca

Please find details below list

Copy and paste below script  on location :
u01/app/oracle/product/12.1.0/dbhome_1/assistants/dbca/templates

dbca




Select Templete





  1. Template_Oracle.dbt
  2. tc_create_user_ilog.sql
  3. create_user.sql


#####################     Template_Oracle.dbt              ####################


<DatabaseTemplate name="tc" description="" version="12.1.0.1.0">

   <CommonAttributes>

      <option name="ISEARCH" value="false"/>

      <option name="OMS" value="false"/>

      <option name="JSERVER" value="false"/>

      <option name="SPATIAL" value="false"/>

      <option name="ODM" value="false">

         <tablespace id="SYSAUX"/>

      </option>

      <option name="IMEDIA" value="false"/>

      <option name="XDB_PROTOCOLS" value="false">

         <tablespace id="SYSAUX"/>

      </option>

      <option name="ORACLE_TEXT" value="false">

         <tablespace id="SYSAUX"/>

      </option>

      <option name="SAMPLE_SCHEMA" value="false"/>

      <option name="CWMLITE" value="false">

         <tablespace id="SYSAUX"/>

      </option>

      <option name="EM_REPOSITORY" value="true">

         <tablespace id="SYSAUX"/>

      </option>

   </CommonAttributes>

   <Variables/>

   <CustomScripts Execute="true">

      <CustomScript script="{ORACLE_HOME}/assistants/dbca/templates/tc_create_user_ilog.sql"/>

   </CustomScripts>

   <InitParamAttributes>

      <InitParams>

         <initParam name="control_files" value="(&quot;{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/control01.ctl&quot;, &quot;{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/control02.ctl&quot;, &quot;{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/control03.ctl&quot;)"/>

         <initParam name="db_domain" value=""/>

         <initParam name="db_file_multiblock_read_count" value="32"/>

         <initParam name="db_name" value="tc"/>

         <initParam name="instance_name" value="tc"/>

         <initParam name="db_recovery_file_dest" value="{ORACLE_BASE}/flash_recovery_area"/>

         <initParam name="db_recovery_file_dest_size" value="4096" unit="MB"/>

         <initParam name="open_cursors" value="300"/>

         <initParam name="pga_aggregate_target" value="500" unit="MB"/>

         <initParam name="processes" value="150"/>

         <initParam name="undo_tablespace" value="UNDOTBS1"/>

         <initParam name="query_rewrite_integrity" value="TRUSTED"/>

         <initParam name="sga_max_size" value="2048" unit="MB"/>

         <initParam name="sga_target" value="2048" unit="MB"/>

         <initParam name="optimizer_index_caching" value="95"/>

         <initParam name="optimizer_index_cost_adj" value="10"/>

      </InitParams>

      <MiscParams>

         <databaseType>MULTIPURPOSE</databaseType>

         <maxUserConn>20</maxUserConn>

         <percentageMemTOSGA>40</percentageMemTOSGA>

         <customSGA>true</customSGA>

         <archiveLogMode>false</archiveLogMode>

         <initParamFileName>{ORACLE_BASE}/admin/{DB_UNIQUE_NAME}/pfile/init.ora</initParamFileName>

      </MiscParams>

      <SPfile useSPFile="true">{ORACLE_HOME}/dbs/spfile{SID}.ora</SPfile>

   </InitParamAttributes>

   <StorageAttributes>

      <ControlfileAttributes id="Controlfile">

         <maxDatafiles>100</maxDatafiles>

         <maxLogfiles>16</maxLogfiles>

         <maxLogMembers>3</maxLogMembers>

         <maxLogHistory>1</maxLogHistory>

         <maxInstances>8</maxInstances>

         <image name="control01.ctl" filepath="{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/"/>

         <image name="control02.ctl" filepath="{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/"/>

         <image name="control03.ctl" filepath="{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/"/>

      </ControlfileAttributes>

      <DatafileAttributes id="{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/idata01.dbf">

         <tablespace>IDATA</tablespace>

         <temporary>false</temporary>

         <online>true</online>

         <status>0</status>

         <size unit="MB">500</size>

         <reuse>false</reuse>

         <autoExtend>true</autoExtend>

         <increment unit="KB">10240</increment>

         <maxSize unit="KB">-1</maxSize>

      </DatafileAttributes>

      <DatafileAttributes id="{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/ilog01.dbf">

         <tablespace>ILOG</tablespace>

         <temporary>false</temporary>

         <online>true</online>

         <status>0</status>

         <size unit="MB">50</size>

         <reuse>false</reuse>

         <autoExtend>true</autoExtend>

         <increment unit="KB">10240</increment>

         <maxSize unit="KB">-1</maxSize>

      </DatafileAttributes>

      <DatafileAttributes id="{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/indx01.dbf">

         <tablespace>INDX</tablespace>

         <temporary>false</temporary>

         <online>true</online>

         <status>0</status>

         <size unit="MB">50</size>

         <reuse>false</reuse>

         <autoExtend>true</autoExtend>

         <increment unit="KB">10240</increment>

         <maxSize unit="KB">-1</maxSize>

      </DatafileAttributes>

      <DatafileAttributes id="{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/sysaux01.dbf">

         <tablespace>SYSAUX</tablespace>

         <temporary>false</temporary>

         <online>true</online>

         <status>0</status>

         <size unit="MB">120</size>

         <reuse>true</reuse>

         <autoExtend>true</autoExtend>

         <increment unit="KB">10240</increment>

         <maxSize unit="MB">-1</maxSize>

      </DatafileAttributes>

      <DatafileAttributes id="{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/system01.dbf">

         <tablespace>SYSTEM</tablespace>

         <temporary>false</temporary>

         <online>true</online>

         <status>0</status>

         <size unit="MB">400</size>

         <reuse>true</reuse>

         <autoExtend>true</autoExtend>

         <increment unit="KB">10240</increment>

         <maxSize unit="MB">-1</maxSize>

      </DatafileAttributes>

      <DatafileAttributes id="{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/temp01.dbf">

         <tablespace>TEMP</tablespace>

         <temporary>false</temporary>

         <online>true</online>

         <status>0</status>

         <size unit="MB">50</size>

         <reuse>true</reuse>

         <autoExtend>false</autoExtend>

         <increment unit="KB">640</increment>

         <maxSize unit="MB">-1</maxSize>

      </DatafileAttributes>

      <DatafileAttributes id="{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/undotbs01.dbf">

         <tablespace>UNDOTBS1</tablespace>

         <temporary>false</temporary>

         <online>true</online>

         <status>0</status>

         <size unit="MB">500</size>

         <reuse>true</reuse>

         <autoExtend>true</autoExtend>

         <increment unit="KB">10240</increment>

         <maxSize unit="MB">-1</maxSize>

      </DatafileAttributes>

      <TablespaceAttributes id="IDATA">

         <online>true</online>

         <offlineMode>1</offlineMode>

         <readOnly>false</readOnly>

         <temporary>false</temporary>

         <defaultTemp>false</defaultTemp>

         <undo>false</undo>

         <local>true</local>

         <blockSize>-1</blockSize>

         <allocation>1</allocation>

         <uniAllocSize unit="KB">-1</uniAllocSize>

         <initSize unit="KB">-1</initSize>

         <increment unit="KB">-1</increment>

         <incrementPercent>1</incrementPercent>

         <minExtends>-1</minExtends>

         <maxExtends>-2</maxExtends>

         <minExtendsSize unit="KB">-1</minExtendsSize>

         <logging>true</logging>

         <recoverable>false</recoverable>

         <maxFreeSpace>0</maxFreeSpace>

         <autoSegmentMgmt>true</autoSegmentMgmt>

         <datafilesList>

            <TablespaceDatafileAttributes id="{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/idata01.dbf">

               <id>1</id>

            </TablespaceDatafileAttributes>

         </datafilesList>

      </TablespaceAttributes>

      <TablespaceAttributes id="ILOG">

         <online>true</online>

         <offlineMode>1</offlineMode>

         <readOnly>false</readOnly>

         <temporary>false</temporary>

         <defaultTemp>false</defaultTemp>

         <undo>false</undo>

         <local>true</local>

         <blockSize>-1</blockSize>

         <allocation>1</allocation>

         <uniAllocSize unit="KB">-1</uniAllocSize>

         <initSize unit="KB">-1</initSize>

         <increment unit="KB">-1</increment>

         <incrementPercent>1</incrementPercent>

         <minExtends>-1</minExtends>

         <maxExtends>-2</maxExtends>

         <minExtendsSize unit="KB">-1</minExtendsSize>

         <logging>true</logging>

         <recoverable>false</recoverable>

         <maxFreeSpace>0</maxFreeSpace>

         <autoSegmentMgmt>true</autoSegmentMgmt>

         <datafilesList>

            <TablespaceDatafileAttributes id="{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/ilog01.dbf">

               <id>1</id>

            </TablespaceDatafileAttributes>

         </datafilesList>

      </TablespaceAttributes>

      <TablespaceAttributes id="INDX">

         <online>true</online>

         <offlineMode>1</offlineMode>

         <readOnly>false</readOnly>

         <temporary>false</temporary>

         <defaultTemp>false</defaultTemp>

         <undo>false</undo>

         <local>true</local>

         <blockSize>-1</blockSize>

         <allocation>1</allocation>

         <uniAllocSize unit="KB">-1</uniAllocSize>

         <initSize unit="KB">-1</initSize>

         <increment unit="KB">-1</increment>

         <incrementPercent>1</incrementPercent>

         <minExtends>-1</minExtends>

         <maxExtends>-2</maxExtends>

         <minExtendsSize unit="KB">-1</minExtendsSize>

         <logging>true</logging>

         <recoverable>false</recoverable>

         <maxFreeSpace>0</maxFreeSpace>

         <autoSegmentMgmt>true</autoSegmentMgmt>

         <datafilesList>

            <TablespaceDatafileAttributes id="{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/indx01.dbf">

               <id>1</id>

            </TablespaceDatafileAttributes>

         </datafilesList>

      </TablespaceAttributes>

      <TablespaceAttributes id="SYSAUX">

         <online>true</online>

         <offlineMode>1</offlineMode>

         <readOnly>false</readOnly>

         <temporary>false</temporary>

         <defaultTemp>false</defaultTemp>

         <undo>false</undo>

         <local>true</local>

         <blockSize>-1</blockSize>

         <allocation>1</allocation>

         <uniAllocSize unit="KB">-1</uniAllocSize>

         <initSize unit="KB">64</initSize>

         <increment unit="KB">64</increment>

         <incrementPercent>50</incrementPercent>

         <minExtends>1</minExtends>

         <maxExtends>4096</maxExtends>

         <minExtendsSize unit="KB">64</minExtendsSize>

         <logging>true</logging>

         <recoverable>false</recoverable>

         <maxFreeSpace>0</maxFreeSpace>

         <autoSegmentMgmt>true</autoSegmentMgmt>

         <datafilesList>

            <TablespaceDatafileAttributes id="{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/sysaux01.dbf">

               <id>-1</id>

            </TablespaceDatafileAttributes>

         </datafilesList>

      </TablespaceAttributes>

      <TablespaceAttributes id="SYSTEM">

         <online>true</online>

         <offlineMode>1</offlineMode>

         <readOnly>false</readOnly>

         <temporary>false</temporary>

         <defaultTemp>false</defaultTemp>

         <undo>false</undo>

         <local>true</local>

         <blockSize>-1</blockSize>

         <allocation>3</allocation>

         <uniAllocSize unit="KB">-1</uniAllocSize>

         <initSize unit="KB">64</initSize>

         <increment unit="KB">64</increment>

         <incrementPercent>50</incrementPercent>

         <minExtends>1</minExtends>

         <maxExtends>-1</maxExtends>

         <minExtendsSize unit="KB">64</minExtendsSize>

         <logging>true</logging>

         <recoverable>false</recoverable>

         <maxFreeSpace>0</maxFreeSpace>

         <autoSegmentMgmt>true</autoSegmentMgmt>

         <datafilesList>

            <TablespaceDatafileAttributes id="{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/system01.dbf">

               <id>-1</id>

            </TablespaceDatafileAttributes>

         </datafilesList>

      </TablespaceAttributes>

      <TablespaceAttributes id="TEMP">

         <online>true</online>

         <offlineMode>1</offlineMode>

         <readOnly>false</readOnly>

         <temporary>true</temporary>

         <defaultTemp>true</defaultTemp>

         <undo>false</undo>

         <local>true</local>

         <blockSize>-1</blockSize>

         <allocation>1</allocation>

         <uniAllocSize unit="KB">-1</uniAllocSize>

         <initSize unit="KB">64</initSize>

         <increment unit="KB">64</increment>

         <incrementPercent>0</incrementPercent>

         <minExtends>1</minExtends>

         <maxExtends>0</maxExtends>

         <minExtendsSize unit="KB">64</minExtendsSize>

         <logging>true</logging>

         <recoverable>false</recoverable>

         <maxFreeSpace>0</maxFreeSpace>

         <autoSegmentMgmt>true</autoSegmentMgmt>

         <datafilesList>

            <TablespaceDatafileAttributes id="{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/temp01.dbf">

               <id>-1</id>

            </TablespaceDatafileAttributes>

         </datafilesList>

      </TablespaceAttributes>

      <TablespaceAttributes id="UNDOTBS1">

         <online>true</online>

         <offlineMode>1</offlineMode>

         <readOnly>false</readOnly>

         <temporary>false</temporary>

         <defaultTemp>false</defaultTemp>

         <undo>true</undo>

         <local>true</local>

         <blockSize>-1</blockSize>

         <allocation>1</allocation>

         <uniAllocSize unit="KB">-1</uniAllocSize>

         <initSize unit="KB">512</initSize>

         <increment unit="KB">512</increment>

         <incrementPercent>50</incrementPercent>

         <minExtends>8</minExtends>

         <maxExtends>4096</maxExtends>

         <minExtendsSize unit="KB">512</minExtendsSize>

         <logging>true</logging>

         <recoverable>false</recoverable>

         <maxFreeSpace>0</maxFreeSpace>

         <autoSegmentMgmt>true</autoSegmentMgmt>

         <datafilesList>

            <TablespaceDatafileAttributes id="{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/undotbs01.dbf">

               <id>-1</id>

            </TablespaceDatafileAttributes>

         </datafilesList>

      </TablespaceAttributes>

      <RedoLogGroupAttributes id="1">

         <reuse>false</reuse>

         <fileSize unit="KB">102400</fileSize>

         <Thread>1</Thread>

         <member ordinal="0" memberName="redo01.log" filepath="{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/"/>

      </RedoLogGroupAttributes>

      <RedoLogGroupAttributes id="2">

         <reuse>false</reuse>

         <fileSize unit="KB">102400</fileSize>

         <Thread>1</Thread>

         <member ordinal="0" memberName="redo02.log" filepath="{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/"/>

      </RedoLogGroupAttributes>

      <RedoLogGroupAttributes id="3">

         <reuse>false</reuse>

         <fileSize unit="KB">102400</fileSize>

         <Thread>1</Thread>

         <member ordinal="0" memberName="redo03.log" filepath="{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/"/>

      </RedoLogGroupAttributes>

   </StorageAttributes>

</DatabaseTemplate>

#################          tc_create_user_ilog.sql               ##################

REM EDS PLM
REM
REM File: tc_create_user_ilog.sql
REM
REM ****************************************************************************
REM Revision    History:
REM Date        Author         Comment
REM =========   ======         =================================================

REM
REM ****************************************************************************

REM This script:
REM 1) creates the Tc test user account
REM 2) creates the Tc test logging tables/indexes

spool tc_create_user_ilog.lst

connect / as sysdba

REM create the Tc test account
@@create_user.sql


#################           create_user.sql                 #######################

REM EDS PLM
REM
REM File: create_user.sql
REM
REM ****************************************************************************
REM Revision    History:
REM Date        Author         Comment
REM =========   ======         =================================================
REM 12-Mar-03      Initial.
REM 14-Jul-05        Remove dba privilege;only grant those required.
REM 11-Jan-06       Give test imp_full_database role.
REM
REM ****************************************************************************

REM This script creates the TcEng test account.
REM This script expects 2 existing tablespaces: "idata" and "temp".

prompt Creating test account and granting privileges.
grant Connect, Create table, Create procedure, Create view, Select_catalog_role, alter session to test identified by test;


prompt Setting default tablespaces for the test account.
alter user test default tablespace idata temporary tablespace temp;
ALTER USER "TEST" QUOTA UNLIMITED ON "IDATA" QUOTA UNLIMITED ON "ILOG" QUOTA UNLIMITED ON "INDX";


spool off

exit

Wednesday 27 November 2019

Oracle NID UTILITY TARGET -- Change DBNAME ONLY


  • [oracle@srv3 admin]$ sqlplus sys/system123@rac as sysdba


SQL*Plus: Release 12.1.0.2.0 Production on Wed Nov 27 17:11:06 2019

Copyright (c) 1982, 2014, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> sho parameter db_name

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_name                              string      RAC
SQL> sho parameter db_unique

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_unique_name                       string      RAC
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options


  • [oracle@srv3 admin]$ nid TARGET=sys/system123@RAC DBNAME=STDRAC SETNAME=YES


DBNEWID: Release 12.1.0.2.0 - Production on Wed Nov 27 17:11:30 2019

Copyright (c) 1982, 2014, Oracle and/or its affiliates.  All rights reserved.

Connected to database RAC (DBID=2608333762)

NID-00121: Database should not be open


Change of database name failed during validation - database is intact.
DBNEWID - Completed with validation errors.

  • [oracle@srv3 admin]$ sqlplus sys/system123@rac as sysdba


SQL*Plus: Release 12.1.0.2.0 Production on Wed Nov 27 17:11:53 2019

Copyright (c) 1982, 2014, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options


  • SQL> shut immediate;

Database closed.
Database dismounted.
ORACLE instance shut down.
ERROR:
ORA-12514: TNS:listener does not currently know of service requested in connect
descriptor


Warning: You are no longer connected to ORACLE.
SQL> exit

  • [oracle@srv3 admin]$ sqlplus / as sysdba


SQL*Plus: Release 12.1.0.2.0 Production on Wed Nov 27 17:13:22 2019

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

Connected to an idle instance.


  • SQL> startup mount;

ORACLE instance started.

Total System Global Area  754974720 bytes
Fixed Size                  2928968 bytes
Variable Size             549457592 bytes
Database Buffers          197132288 bytes
Redo Buffers                5455872 bytes
Database mounted.
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options


  • [oracle@srv3 admin]$ nid TARGET=sys/system123@RAC DBNAME=STDRAC SETNAME=YES


DBNEWID: Release 12.1.0.2.0 - Production on Wed Nov 27 17:13:40 2019

Copyright (c) 1982, 2014, Oracle and/or its affiliates.  All rights reserved.

Connected to database RAC (DBID=2608333762)

Connected to server version 12.1.0

Control Files in database:
    /u01/app/oracle/oradata/RAC/control01.ctl
    /u01/app/oracle/fast_recovery_area/RAC/control02.ctl


  • Change database name of database RAC to STDRAC? (Y/[N]) => Y


Proceeding with operation
Changing database name from RAC to STDRAC
    Control File /u01/app/oracle/oradata/RAC/control01.ctl - modified
    Control File /u01/app/oracle/fast_recovery_area/RAC/control02.ctl - modified
    Datafile /u01/app/oracle/oradata/RAC/system01.db - wrote new name
    Datafile /u01/app/oracle/oradata/RAC/idata01.db - wrote new name
    Datafile /u01/app/oracle/oradata/RAC/sysaux01.db - wrote new name
    Datafile /u01/app/oracle/oradata/RAC/undotbs01.db - wrote new name
    Datafile /u01/app/oracle/oradata/RAC/users01.db - wrote new name
    Datafile /u01/app/oracle/oradata/RAC/ilog01.db - wrote new name
    Datafile /u01/app/oracle/oradata/RAC/indx01.db - wrote new name
    Datafile /u01/app/oracle/oradata/RAC/temp01.db - wrote new name
    Control File /u01/app/oracle/oradata/RAC/control01.ctl - wrote new name
    Control File /u01/app/oracle/fast_recovery_area/RAC/control02.ctl - wrote new name
    Instance shut down

Database name changed to STDRAC.
Modify parameter file and generate a new password file before restarting.
Succesfully changed database name.
DBNEWID - Completed succesfully.


###################   Change CDB Database name Example ###################
[SMRCDB] to [STDRAC]

oracle@srv4:/u01/app/oracle/product/12.2.0/dbhome_1/network/admin> . oraenv
ORACLE_SID = [SMRCDB] ?
The Oracle base remains unchanged with value /u01/app/oracle
oracle@srv4:/u01/app/oracle/product/12.2.0/dbhome_1/network/admin> sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Thu Aug 6 22:55:13 2020

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup mount;
ORACLE instance started.

Total System Global Area 1795162112 bytes
Fixed Size                  8793832 bytes
Variable Size             704643352 bytes
Database Buffers         1073741824 bytes
Redo Buffers                7983104 bytes
Database mounted.
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
oracle@srv4:/u01/app/oracle/product/12.2.0/dbhome_1/network/admin> nid TARGET=sys/system123@SMRCDB DBNAME=STDRAC SETNAME=YES

DBNEWID: Release 12.2.0.1.0 - Production on Thu Aug 6 22:56:25 2020

Copyright (c) 1982, 2017, Oracle and/or its affiliates.  All rights reserved.

Connected to database SMRCDB (DBID=3280283628)

Connected to server version 12.2.0

Control Files in database:
    /u01/app/oracle/oradata/SMRCDB/control01.ctl
    /u01/app/oracle/fast_recovery_area/SMRCDB/control02.ctl

Change database name of database SMRCDB to STDRAC? (Y/[N]) => Y

Proceeding with operation
Changing database name from SMRCDB to STDRAC
    Control File /u01/app/oracle/oradata/SMRCDB/control01.ctl - modified
    Control File /u01/app/oracle/fast_recovery_area/SMRCDB/control02.ctl - modified
    Datafile /u01/app/oracle/oradata/SMRCDB/system01.db - wrote new name
    Datafile /u01/app/oracle/oradata/SMRCDB/sysaux01.db - wrote new name
    Datafile /u01/app/oracle/oradata/SMRCDB/undotbs01.db - wrote new name
    Datafile /u01/app/oracle/oradata/SMRCDB/pdbseed/system01.db - wrote new name
    Datafile /u01/app/oracle/oradata/SMRCDB/pdbseed/sysaux01.db - wrote new name
    Datafile /u01/app/oracle/oradata/SMRCDB/users01.db - wrote new name
    Datafile /u01/app/oracle/oradata/SMRCDB/pdbseed/undotbs01.db - wrote new name
    Datafile /u01/app/oracle/oradata/SMRCDB/temp01.db - wrote new name
    Datafile /u01/app/oracle/oradata/SMRCDB/pdbseed/temp012020-08-04_22-52-23-393-PM.db - wrote new name
    Control File /u01/app/oracle/oradata/SMRCDB/control01.ctl - wrote new name
    Control File /u01/app/oracle/fast_recovery_area/SMRCDB/control02.ctl - wrote new name
    Instance shut down

Database name changed to STDRAC.
Modify parameter file and generate a new password file before restarting.
Succesfully changed database name.
DBNEWID - Completed succesfully.


  • Create pfile from  SMRCDB pfile change db_name to 'STDRAC' and start database with pfile.

oracle@srv4:/u01/app/oracle/oradata/SMRCDB> cat /u01/app/oracle/product/12.2.0/dbhome_1/dbs/initSTDRAC.ora
STDRAC.__data_transfer_cache_size=0
STDRAC.__db_cache_size=1107296256
STDRAC.__inmemory_ext_roarea=0
STDRAC.__inmemory_ext_rwarea=0
STDRAC.__java_pool_size=16777216
STDRAC.__large_pool_size=33554432
STDRAC.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
STDRAC.__pga_aggregate_target=603979776
STDRAC.__sga_target=1795162112
STDRAC.__shared_io_pool_size=67108864
STDRAC.__shared_pool_size=553648128
STDRAC.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/SMRCDB/adump'
*.audit_trail='db'
*.compatible='12.2.0'
*.control_files='/u01/app/oracle/oradata/SMRCDB/control01.ctl','/u01/app/oracle/fast_recovery_area/SMRCDB/control02.ctl'
*.db_block_size=8192
*.db_create_file_dest='/u01/app/oracle/oradata/SMRCDB/'
#DB_CREATE_FILE_DEST='/u01/app/oracle/oradata/SMRCDB/'
*.db_name='STDRAC'
*.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area/SMRCDB'
*.db_recovery_file_dest_size=10398m
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=STDRACXDB)'
*.enable_pluggable_database=true
*.local_listener='(ADDRESS=(PROTOCOL=TCP)(HOST=srv4.example.com)(PORT=1523))'
*.log_archive_format='%t_%s_%r.dbf'
*.nls_language='AMERICAN'
*.nls_territory='AMERICA'
*.open_cursors=300
*.pga_aggregate_target=570m
*.processes=800
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=1708m
*.undo_tablespace='UNDOTBS1'
oracle@srv4:/u01/app/oracle/oradata/SMRCDB>


oracle@srv4:/u01/app/oracle/product/12.2.0/dbhome_1/network/admin>
SQL> startup pfile='/u01/app/oracle/product/12.2.0/dbhome_1/dbs/initSTDRAC.ora';
ORACLE instance started.

Total System Global Area 1795162112 bytes
Fixed Size                  8793832 bytes
Variable Size             704643352 bytes
Database Buffers         1073741824 bytes
Redo Buffers                7983104 bytes
Database mounted.
Database opened.
SQL>
SQL> select name,open_mode,database_role from v$database;

NAME      OPEN_MODE            DATABASE_ROLE
--------- -------------------- ----------------
STDRAC    READ WRITE           PRIMARY



SQL> sho pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
SQL> select CDB from v$database;

CDB
---
YES



Tuesday 12 November 2019

Oracle Database - Log Minor Examples

alter system set utl_file_dir='D:\63_archivelog\log_minor' scope=spfile;
D:\63_archivelog\log_minor
##############################################################################################################

EXECUTE DBMS_LOGMNR_D.BUILD('dictionary.ora', 'D:\63_archivelog\log_minor', DBMS_LOGMNR_D.STORE_IN_FLAT_FILE);

SQL> execute DBMS_LOGMNR.ADD_LOGFILE ('C:\ORACLE\ORADATA\ORDB1\REDO01.LOG');

SQL> execute DBMS_LOGMNR.ADD_LOGFILE ('C:\ORACLE\ORADATA\ORDB1\REDO02.LOG');

SQL> execute DBMS_LOGMNR.ADD_LOGFILE ('C:\ORACLE\ORADATA\ORDB1\REDO03.LOG');

SQL> execute DBMS_LOGMNR.ADD_LOGFILE ('C:\ORACLE\ORADATA\ORDB1\REDO04.LOG');
################################################################################################################


EXECUTE DBMS_LOGMNR.ADD_LOGFILE( LOGFILENAME => '/tmp/group_1.259.919359545', OPTIONS => DBMS_LOGMNR.NEW);

EXECUTE DBMS_LOGMNR.ADD_LOGFILE(LOGFILENAME => '/tmp/group_2.261.919359549',OPTIONS => DBMS_LOGMNR.ADDFILE);

execute DBMS_LOGMNR.ADD_LOGFILE (LOGFILENAME => 'D:\63_archivelog\1_230_1005460847.arc', OPTIONS => DBMS_LOGMNR.NEW);
execute DBMS_LOGMNR.ADD_LOGFILE (LOGFILENAME => 'D:\63_archivelog\1_231_1005460847.arc', OPTIONS => DBMS_LOGMNR.ADDFILE);
execute DBMS_LOGMNR.ADD_LOGFILE (LOGFILENAME => 'D:\63_archivelog\1_232_1005460847.arc', OPTIONS => DBMS_LOGMNR.ADDFILE);
execute DBMS_LOGMNR.ADD_LOGFILE (LOGFILENAME => 'D:\63_archivelog\1_233_1005460847.arc', OPTIONS => DBMS_LOGMNR.ADDFILE);
execute DBMS_LOGMNR.ADD_LOGFILE (LOGFILENAME => 'D:\63_archivelog\1_234_1005460847.arc', OPTIONS => DBMS_LOGMNR.ADDFILE);
execute DBMS_LOGMNR.ADD_LOGFILE (LOGFILENAME => 'D:\63_archivelog\1_235_1005460847.arc', OPTIONS => DBMS_LOGMNR.ADDFILE);
execute DBMS_LOGMNR.ADD_LOGFILE (LOGFILENAME => 'D:\63_archivelog\1_236_1005460847.arc', OPTIONS => DBMS_LOGMNR.ADDFILE);
execute DBMS_LOGMNR.ADD_LOGFILE (LOGFILENAME => 'D:\63_archivelog\1_237_1005460847.arc', OPTIONS => DBMS_LOGMNR.ADDFILE);


EXECUTE DBMS_LOGMNR.START_LOGMNR (DICTFILENAME => 'D:\63_archivelog\log_minor\DICTIONARY1.ORA');

SELECT scn, operation, sql_redo, sql_undo FROM v$logmnr_contents;