Where is 12.1.0.2 Oracle Clusterware Diagnostic and Alert Logs ?

From 12.1.0.2, Clusterware Diagnostic and Alert Logs are relocated from $GI_HOME/log/ to GI $ORACLE_BASE/diag/

We’ve just upgraded Oracle 12.1.0.1 GI to 12.1.0.2, and found clusterware logs have been relocated from $GI_HOME/log/.

According to Oracle support Doc (ID 1915729.1), from Oracle 12.1.0.2 on Oracle clusterware (part of Grid Infrastructure) uses Oracle database fault diagnosability infrastructure to manage diagnostic data and its alert logs. As a result, most diagnostic data resides in the Automatic Diagnostic Repository (ADR).

Please note :

1)More space is required for GI $ORACLE_BASE in case of file system full , because Clusterware logs are moved to ADR which is part of ORACLE_BASE.

2)When opening SR, instead of diagcollection.pl, TFA should be used to collect diagnostics:
$/u01/app/12.1.0.2/grid/bin/tfactl diagcollect -from “Jan/20/2015 08:00:00” -to “Jan/23/2015 13:00:00”

Collecting data for all nodes
Scanning files from Jan/20/2015 08:00:00 to Jan/23/2015 13:00:00

Repository Location in hx415 : /u01/app/grid/tfa/repository
2015/01/23 14:42:55 EST : Running an inventory clusterwide …
2015/01/23 14:42:55 EST : Collection Name : tfa_Fri_Jan_23_14_42_49_EST_2015.zip
……
……
……

CHILD TABLE DOESN’T INHERIT PARENT’S COMPRESSION ATTRIBUTE AFTER SPLITTING PARENT PARTITION

set “_force_oltp_compress”=true for CHILD TABLE to INHERIT PARENT’S COMPRESSION ATTRIBUTE AFTER SPLIT PARTITION

ISSUES

When split a partition of a reference parent table, the compression attribute “compress for OLTP” is not inherited by child partitions. Instead,it changes into “compress for BASIC’ by default.

The following test case is on 11.2.0.4 database. We have two tables named “parent” and “child”, here parent is partitioned by range of a date column, and child table is a partitioned by foreign key reference to parent table.

1) Create two tables.

SQL>CREATE TABLE Parent
    (
     pk_p_id number primary key ,
     P_Date DATE,
     P_cost NUMBER
    ) compress for oltp
    PARTITION BY RANGE (P_Date)
   (PARTITION P_First VALUES LESS THAN (TO_DATE('01-01-2014', 'DD-MM-YYYY')) COMPRESS for OLTP,
    PARTITION P_2014_11_01 VALUES LESS THAN (TO_DATE('02-11-2014', 'DD-MM-YYYY')) COMPRESS for OLTP,
    PARTITION P_MAXIMUM VALUES LESS THAN (MAXVALUE) COMPRESS for OLTP
   );

Table created.

SQL> CREATE TABLE Child(
pk_c_id number primary key ,
fk_c_id number not null,
c_total NUMBER,
CONSTRAINT Child_FK FOREIGN KEY ( fk_c_id ) REFERENCES parent ( pk_p_id)
) compress for oltp
partition by reference ( Child_FK ) ;

Table created.

2) All partitions are “compress for oltp”

SQL> select TABLE_NAME,PARTITION_NAME,COMPRESSION,COMPRESS_FOR 
from user_tab_partitions
where TABLE_NAME in ('PARENT','CHILD')
order by TABLE_NAME,PARTITION_POSITION; TABLE_NAME PARTITION_NAME COMPRESS COMPRESS_FOR ----------- ---------------- --------- ------------
CHILD P_FIRST ENABLED OLTP CHILD P_2014_11_01 ENABLED OLTP CHILD P_MAXIMUM ENABLED OLTP PARENT P_FIRST ENABLED OLTP PARENT P_2014_11_01 ENABLED OLTP PARENT P_MAXIMUM ENABLED OLTP 6 rows selected.

3) split parent P_MAXIMUM partition:

SQL> alter table PARENT split partition P_MAXIMUM at (TO_DATE('03-11-2014', 'DD-MM-YYYY')) into ( partition P_2014_11_02, partition P_MAXIMUM) update indexes;

Table altered.

4) New child partitions compression attribute is “compress for BASIC”

SQL>select TABLE_NAME,PARTITION_NAME,COMPRESSION,COMPRESS_FOR 
from user_tab_partitions
where TABLE_NAME in ( 'PARENT','CHILD')
order by TABLE_NAME,PARTITION_POSITION; TABLE_NAME PARTITION_NAME COMPRESS COMPRESS_FOR ------------ --------------- --------- ------------ CHILD P_FIRST ENABLED OLTP CHILD P_2014_11_01 ENABLED OLTP CHILD P_2014_11_02 ENABLED BASIC CHILD P_MAXIMUM ENABLED BASIC PARENT P_FIRST ENABLED OLTP PARENT P_2014_11_01 ENABLED OLTP PARENT P_2014_11_02 ENABLED OLTP PARENT P_MAXIMUM ENABLED OLTP 8 rows selected.

5) This issue still exists in 12c.

$ sqlplus / as sysdba
SQL*Plus:Release 12.1.0.2.0 Production on Mon Nov 17 07:31:31 2014
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, Real Application Testing and Unified Auditing options

SQL> connect system
Enter password: 
Connected.

SQL> CREATE TABLE Parent 
 ( 
 pk_p_id number primary key , 
 P_Date DATE, 
 P_cost NUMBER 
 ) compress for oltp 
 PARTITION BY RANGE (P_Date) 
 (PARTITION P_First 
 VALUES LESS THAN (TO_DATE('01-01-2014', 'DD-MM-YYYY')) COMPRESS for OLTP,
 PARTITION P_2014_11_01 
 VALUES LESS THAN (TO_DATE('02-11-2014', 'DD-MM-YYYY')) COMPRESS for OLTP, 
 PARTITION P_MAXIMUM VALUES LESS THAN (MAXVALUE) COMPRESS for OLTP
 );
Table created.
SQL> CREATE TABLE Child 
( 
pk_c_id number primary key , 
fk_c_id number not null, 
c_total NUMBER, 
CONSTRAINT Child_FK FOREIGN KEY ( fk_c_id ) REFERENCES parent ( pk_p_id)
) compress for oltp 
partition by reference ( Child_FK ) ;

Table created.
SQL> col PARTITION_NAME format a18
SQL> col table_name format a15
SQL> set pagesize 120
SQL> set linesize 160
SQL>select TABLE_NAME,PARTITION_NAME,COMPRESSION,COMPRESS_FOR 
from user_tab_partitions
where TABLE_NAME in ( 'PARENT','CHILD')
order by TABLE_NAME,PARTITION_POSITION;

TABLE_NAME PARTITION_NAME COMPRESS COMPRESS_FOR ----------- -------------- -------- ------------ CHILD P_FIRST ENABLED ADVANCED CHILD P_2014_11_01 ENABLED ADVANCED CHILD P_MAXIMUM ENABLED ADVANCED PARENT P_FIRST ENABLED ADVANCED PARENT P_2014_11_01 ENABLED ADVANCED PARENT P_MAXIMUM ENABLED ADVANCED 6 rows selected.
SQL> alter table PARENT split partition P_MAXIMUM at (TO_DATE('03-11-2014', 'DD-MM-YYYY')) into ( partition P_2014_11_02, partition P_MAXIMUM) update indexes;
Table altered.
SQL> select TABLE_NAME,PARTITION_NAME,COMPRESSION,COMPRESS_FOR
from user_tab_partitions
where TABLE_NAME in ( 'PARENT','CHILD')
order by TABLE_NAME,PARTITION_POSITION;
TABLE_NAME PARTITION_NAME COMPRESS COMPRESS_FOR ---------- --------------- -------- --------------- CHILD P_FIRST ENABLED ADVANCED CHILD P_2014_11_01 ENABLED ADVANCED CHILD P_2014_11_02 ENABLED BASIC CHILD P_MAXIMUM ENABLED BASIC PARENT P_FIRST ENABLED ADVANCED PARENT P_2014_11_01 ENABLED ADVANCED PARENT P_2014_11_02 ENABLED ADVANCED PARENT P_MAXIMUM ENABLED ADVANCED 8 rows selected.

Workaround:

set “_force_oltp_compress”=true in session level or system level.

Bug:

Bug 20081931 has been raised by Oracle Support to Oracle Development

Bug 20081931 – CHILD TABLE DOESN’T INHERIT PARENT’S COMPRESSION ATTRIBUTE AFTER SPLIT PARTITION

ORA-00959 tablespace does not exist by revoking user quota on a dropped tablespace

It is a bug? Tablespace has been dropped, but this tablespace information still exists in database data dictionary.

User has quotas on two tablespaces. One tablespace needs to be dropped. After dropping this tablespace, the quota on this tablespace can not be manually revoked from this user.

To fix this, we have to create and add a dummy tablespace with same name back again, then revoke user quota on this tablespace, drop the tablespace finally.

Here are the steps to show this issue plus how to fix it most importantly.

1) User has quotas on two tablespaces.

SQL>select tablespace_name,username,max_bytes,dropped 
from dba_ts_quotas
where username='TESTUSER';
TABLESPACE_NAME USERNAME MAX_BYTES DRO ---------------- ---------- ---------- --- USERS_OLD TESTUSER -1 NO USERS TESTUSER -1 NO

2) Drop tablespace “USERS_OLD”.

SQL> drop tablespace USERS_OLD including contents and datafiles;
Tablespace dropped.

3) Quota on tablespace still exists.

SQL> select tablespace_name,username,max_bytes,dropped 
from dba_ts_quotas
where username='TESTUSER';
TABLESPACE_NAME USERNAME MAX_BYTES DRO ---------------- --------- ---------- --- USERS_OLD TESTUSER -1 YES USERS TESTUSER -1 NO

4) Revoke quota on tablespace “USERS_OLD”

SQL> alter user TESTUSER quota 0 on USERS_OLD;
alter user TESTUSER quota 0 on USERS_OLD
*
ERROR at line 1:
ORA-00959: tablespace 'USERS_OLD' does not exist

5) Create a dummy tablespace with  same name.

SQL> create tablespace USERS_OLD datafile '+dg1' size 10m;
Tablespace created.

6) Revoke quota on tablespace USERS_OLD.

SQL> alter user TESTUSER quota 0 on USERS_OLD;
User altered.

7) To confirm quota on tablespace “USERS_OLD” revoked.

SQL> select tablespace_name,username,max_bytes,dropped 
from dba_ts_quotas
where username='TESTUSER'; TABLESPACE_NAME USERNAME MAX_BYTES DROPPED ---------------- ---------- ---------- ------ USERS TESTUSER -1 NO

8) Drop the dummy tablespace. 

SQL> drop tablespace USERS_OLD including contents and datafiles;
Tablespace dropped.

How to Install Example Schemas in 12c by Using Templates and Creating a New PDB

Install examples schemas into a dedicated PDB

In another post “How to Install Example Schemas in 12c Database?“, It shows detail steps of how to install example schemas manually through SQL command line.

Here we use another way to install example schemas by creating a PDB with example schemas and plug this PDB into a current CDB .

1) Start up DBCA, select “Manage Pluggable Databases”.

2) Select “Create a Pluggable Database”.

3)Select CDB database to create a PDB in.

4)Select “Create pluggable database using PDB file set”.

5) Select example schemas file set under $ORACLE_HOME/assitants/dbca/templates/

6) Specify PDB name and PDB datafiles location.

   7)Review the template summary.

8) Start to create PDB of example schemas.

9) PDB creation is complete.

Verify PDB Creation and Connect to Example Schemas

1) Connect to CDB.

$ sqlplus sys as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Sat Dec 6 22:47:48 2014
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, OLAP, Advanced Analytics, Real Application Testing
and Unified Auditing options

SQL> select CON_ID,NAME,OPEN_MODE 
from v$pdbs
where name='PDB_SAMPLES';
CON_ID NAME OPEN_MODE ------- ------------ ---------- 7 PDB_SAMPLES READ WRITE

2) Create an entry in TNSNAMES.ora for PDB_SAMPLES.

PDB_SAMPLES =
 (DESCRIPTION =
 (ADDRESS_LIST =
 (ADDRESS = (PROTOCOL = TCP)(HOST =CDBSERVER)(PORT = 1521))
 )
 (CONNECT_DATA =
 (SERVICE_NAME = pdb_samples)
 )
 )

3) Connect to PDB , unlock example schemas and reset passwords.

SQL> connect sys@pdb_samples as sysdba
Enter password: 
Connected.


SQL> alter user hr account unlock identified by hr;
User altered.

SQL> connect hr/hr@pdb_samples
Connected.

SQL> select table_name from user_tables;

TABLE_NAME
-------------
REGIONS
COUNTRIES
LOCATIONS
DEPARTMENTS
JOBS
EMPLOYEES
JOB_HISTORY

7 rows selected.

How to Configure 32K VARHAR2 Data Type in 12c

Configure 32k VARCHAR2, NVARCHAR2 and RAW data type by setting max_string_size=extended, and be aware this parameter can no long be able to change back, like setting max_string_size=standard.

Overview

In 12c database, you can define a maximum size of 32767  bytes for VARCHAR2, NVARCHAR2 and RAW data type column.

Before 12c database, the maximum size was 4000 bytes for VARHAR2 and NVARHAR2 and 2000 bytes for RAW data type.

The declared column length for VARHAR2,NVARHAR2 and RAW data type decides how the column is stored internally in database.

  • If VARCHAR2 and NVARCHAR2 are declared with column length of 4000 bytes or less, and RAW data type column is declared with length 2000 bytes or less, the data is store in-line.
  • If VARCHAR2 and NVARCHAR2 are declared with column length of greater than 4000 bytes, and RAW data type column is declared with length of greater than 2000 bytes, the data is store out-of-line. The column is called “extended character data type column”.

Configure Database for Extended Data Type

  • Before configuring extended data type feature for database.
$ sqlplus / as sysdba
SQL*Plus:Release 12.1.0.2.0 Production on Mon Nov 17 21:54:47 2014Copyright (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, Real Application Testing
and Unified Auditing options

SQL> create table test_table(longvar varchar2(32767));
create table long_varchar(id number,vc varchar2(32767))
 *
ERROR at line 1:
ORA-00910: specified length too long for its datatype
SQL> alter system set max_string_size=extended; system set max_string_size=extended * ERROR at line 1: ORA-02097: parameter cannot be modified because specified value is invalid ORA-14694: database must in UPGRADE mode to begin MAX_STRING_SIZE migration
  • Shutdown Database
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
  • Start database in upgrade mode
SQL> startup upgrade
ORACLE instance started.
TotalSystem Global Area 1073741824 bytes
Fixed Size 2932632 bytes
Variable Size 675283048 bytes
Database Buffers 390070272 bytes
Redo Buffers 5455872 bytes
Database mounted.
Database opened.
  • Change MAX_STRING_SIZE setting
SQL> alter system set max_string_size=extended;
System altered.
  • Run utl32k.sql script
SQL> @ $ORACLE_HOME/rdbms/admin/utl32k.sql
Session altered.
DOC>##############################################################
DOC>##############################################################
DOC> The following statement will cause an "ORA-01722: invalid number"
DOC> error if the database has not been opened for UPGRADE.
DOC>
DOC> Perform a "SHUTDOWN ABORT" and
DOC> restart using UPGRADE.
DOC>##############################################################
DOC>##############################################################
DOC>#
no rows selected
DOC>##############################################################
DOC>##############################################################
DOC> The following statement will cause an "ORA-01722: invalid number"
DOC> error if the database does not have compatible >= 12.0.0
DOC>
DOC> Set compatible >= 12.0.0 and retry.
DOC>##############################################################
DOC>##############################################################DOC>#
PL/SQL procedure successfully completed.
Session altered.
1393 rows updated.
Commit complete.
System altered.
PL/SQL procedure successfully completed.
Commit complete.
System altered.
Session altered.
PL/SQL procedure successfully completed.
No errors.
Session altered.
PL/SQL procedure successfully completed.
Commit complete.
Package altered.
Package altered.
SQL>
  • Shutdown and Startup database
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 1073741824 bytes
Fixed Size 2932632 bytes
Variable Size 675283048 bytes
Database Buffers 390070272 bytes
Redo Buffers 5455872 bytes
Database mounted.
Database opened.
  • Check parameter setting and create table with extended data type column
SQL> show parameter max_string
NAME TYPE VALUE ---------------- ------- -------- max_string_size string EXTENDED SQL> create table test_table(longvar varchar2(32767)); Table created.

Please note you can not change parameter MAX_STRING_SIZE from EXTENDED  to STANDARD.