Posts

Showing posts from February, 2015

Connecting to CDB and PDB - Oracle 12c

Image
Creation on a CDB (Container database) creates a service named is the CDB name. This is a side effect of creating a PDB (Pluggable Database) in the CDB, a service is created inside it with a property that identifies it as the initial current container. The service is also started as a side effect of creating the PDB. Although its metadata is recorded inside the PDB, the invariant is maintained so that a service name is unique within the entire CDB. Use the Easy Connect syntax to connect to the root unless a net service name is configured in the tnsnames for the root service. . oraenv [enter cdb1 at the prompt] sqlplus sys/oracle@localhost:1521/cdb1 as sysdba show con_name show con_id Connect to the...

Trigger to backup the data before delete or update on a table - Oracle

Lets create a table :  CREATE TABLE "ABC"     ( "EMPNO" NUMBER(4,0),  "ENAME" VARCHAR2(10 BYTE),  "JOB" VARCHAR2(9 BYTE),  "MGR" NUMBER(4,0),  "HIREDATE" DATE,  "SAL" NUMBER(7,2),  "COMM" NUMBER(7,2),  "DEPTNO" NUMBER(2,0)    ) TABLESPACE "USERS" ; Now we will insert some data into it : Insert into ABC (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO) values (7369,'SMITH','CLERK',7902,to_date('17-DEC-80','DD-MON-RR'),800,null,20); Insert into ABC (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO) values (7499,'ALLEN','SALESMAN',7698,to_date('20-FEB-81','DD-MON-RR'),1600,300,30); Insert into ABC (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO) values (7521,'WARD','SALESMAN',7698,to_date('22-FEB-81','DD-MON-RR'),1250,500,30); Insert into ABC (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO) values (...

DELETE OS AUDIT FILES IN ORACLE

[atoorpu@ORACLE1 adump]$ pwd /u01/app/oracle/admin/ORCL/adump [atoorpu@ORACLE1 adump]$ ls -1 /u01/app/oracle/admin/ORCL/adump | wc -l 22273 [atoorpu@ORACLE1 adump]$ ls -lrt *aud | wc -l 11363 [atoorpu@ORACLE1 adump]$ sqlplus /"As sysdba" SQL*Plus: Release 11.2.0.4.0 Production on Mon Feb 9 10:40:58 2015 Copyright (c) 1982, 2013, Oracle.  All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options If the audit files are in the database (sys.aud$). They can be cleaned up using: SQL> DBMS_AUDIT_MGMT.CLEAN_AUDIT_TRAIL (    audit_trail_type => SYS.DBMS_AUDIT_MGMT.AUDIT_TRAIL_OS,    use_last_arch_timestamp => TRUE); If the audit files are in the OS. They can be cleaned up using: SQL> BEGIN DBMS_AUDIT_MGMT.CLEAN_AUDIT_TRAIL (    audit_trail_type => DBMS_AUDIT_MGMT.AUDIT_TRAIL_OS,    use_last_arch_timestamp ...