Wednesday, July 29, 2015

Oracle 12c Notes

      We cannot put a pluggable database into archivelog mode, it doesn't have independent log files that could be archived. Either the whole database to be in archivelog mode or none of it. Archivelog destination is common location for any number of pluggable databases as well as for container database and Archive logs are independently identified with the container id.

      Logging in to Pluggable/container databases

         Export ORACLE_SID
         Sqlplus sys@CONNECTIDENTIFIER as sysdba, Which prompts for the password, Please provide it will take to SQL prompt if credentials are valid.

      [oracle@xoomoda1 ~]$  sqlplus sys@DBPLUG as sysdba
  
      SQL*Plus: Release 12.1.0.2.0 Production on Tue Jul 28 13:47:45 2015

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

     Enter password:

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

                                   SQL> show CON_ID

                                  CON_ID
                                  ------------------------------
                                  3

                                SQL> sho CON_NAME

                               CON_NAME
                               ------------------------------
                               DBPLUG

    If you want to connect to container database or any pluggable database.

                                    SQL> conn sys@DBCONT as sysdba
   Enter password:
   Connected.
   SQL> sho CON_ID
   
   CON_ID
    -----------------------------
     1
   SQL> sho CON_NAME

   CON_NAME
   -----------------------------
   CDB$ROOT


    To check on which database (container/pluggable) databases you have logged in please do as follow.
    
    SQL> sho CON_ID

   CON_ID
    ---------------------------
    1
    SQL> sho CON_NAME

    CON_NAME
    -----------------------------
    CDB$ROOT

    From the con_name we can confirm it is a container database because it contains string ROOT.

    SQL> show CON_ID

    CON_ID
    ------------------------------
    3

    SQL> sho CON_NAME

    CON_NAME
    ------------------------------
    PROD

    Here we don’t know is it a container database or pluggable database. So query the v$pdbs which list out all the pluggable database under the root container.

    e.g:
     
    SQL> select CON_ID,NAME,OPEN_MODE,RESTRICTED from v$pdbs;

    CON_ID  NAME          OPEN_MODE     RES 
     ---------- ----------------         ------------------   --------
         2         PDB$SEED   READ ONLY       NO 
         3         PROD            READ WRITE      NO 

     So above two databases are pluggable database under root container.
     Now we can confirm PROD is pluggable database and we have connected to PROD pluggable database.


     We can use alter session command to change the container as alter session set container=name of the conatiner
               
    e.g: I’m in PROD,
   
    SQL> show CON_ID

    CON_ID
    ------------------------------
    3

    SQL> sho CON_NAME

    CON_NAME
    ------------------------------
    PROD

    Now I would like to connect to DBCONT database which can be accomplished by

    alter session set container=DBCONT

    Under ROOT container there will be one seed container and atleast one pluggable database and seed container database always in READ-ONLY mode.

     SQL> select CON_ID,NAME,OPEN_MODE,RESTRICTED from v$pdbs;

    CON_ID  NAME          OPEN_MODE     RES 
     ---------- ----------------         ------------------   --------
         2         PDB$SEED   READ ONLY       NO 


      Alertlog Location is $ORACLE_BASE/diag/rdbms/sid/sid/trace. Here why I’m specifying is, If we issue sho parameter background or sho parameter dump it will point to $ORACLE_HOME/log not $ORACLE_BASE/diag/rdbms/sid/sid/trace. So in Oracle 12c it is good to use the path instead of sho parameter command to find the alertlog file location. $ORACLE_HOME/log  doesn’t contain alertlog file. The alertlog file is common for all the container and any number of pluggable databases.



  
       Thanks,
       v v

No comments:

Post a Comment