Friday, August 30, 2013

clean up a dropped database from RMAN catalog

RMAN> list db_unique_name all;


List of Databases
DB Key  DB Name  DB ID            Database Role    Db_unique_name
------- ------- ----------------- ---------------  ------------------
68262   DGLOGI   1084485603       PRIMARY          DGLOGI
68262   DGLOGI   1084485603       STANDBY          DG
68262   DGLOGI   1084485603       STANDBY          DGS
1       ORCL     1330909046       PRIMARY          ORCL
261     DG       1716975309       PRIMARY          DG
261     DG       1716975309       STANDBY          DGS
192555  TTS      1769654909       PRIMARY          TTS


#DGLOGI  database was dropped

orarac2poc:DGS:/home/oracle> rcat
orarac2poc:RCAT:/home/oracle> sqlplus / as sysdba

SQL*Plus: Release 11.2.0.2.0 Production on Fri Aug 30 09:54:18 2013

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management,
Data Mining and Real Application Testing options

SYS@RCAT> desc dbms_rcvcat
ERROR:
ORA-04043: object dbms_rcvcat does not exist

# SYS can't access to the package , and it is mentioned in oracle document of PL/SQL package reference.

SYS@RCAT> conn rman
Enter password:
Connected.
RMAN@RCAT> select db_key, dbinc_key, dbid, name from rc_database;

    DB_KEY  DBINC_KEY       DBID NAME
---------- ---------- ---------- --------
    192555     220486 1769654909 TTS
       261       8447 1716975309 DG
     68262      68263 1084485603 DGLOGI
         1          2 1330909046 ORCL

RMAN@RCAT> desc dbms_rcvcat
PROCEDURE ADDDBIDTOIMPORT
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 FIRST                          BINARY_INTEGER          IN
 IDB                            VARCHAR2                IN
 IDBINC                         VARCHAR2                IN
 DBID                           NUMBER                  IN     DEFAULT
 DBNAME                         VARCHAR2                IN     DEFAULT
FUNCTION BEGINARCHIVEDLOGRESYNC RETURNS NUMBER
FUNCTION BEGINBACKUPCORRUPTIONRESYNC RETURNS NUMBER
FUNCTION BEGINBACKUPDATAFILERESYNC RETURNS NUMBER
FUNCTION BEGINBACKUPPIECERESYNC RETURNS NUMBER
FUNCTION BEGINBACKUPREDOLOGRESYNC RETURNS NUMBER
FUNCTION BEGINBACKUPSETRESYNC RETURNS NUMBER
FUNCTION BEGINBACKUPSPFILERESYNC RETURNS NUMBER
FUNCTION BEGINBLOCKCORRUPTIONRESYNC RETURNS NUMBER
...

#but catalog owner can "see" it.

@> conn rman
Connected.
RMAN@RCAT> select db_key, dbid, name from rc_database;

    DB_KEY       DBID NAME
---------- ---------- --------
    192555 1769654909 TTS
       261 1716975309 DG
     68262 1084485603 DGLOGI
         1 1330909046 ORCL

RMAN@RCAT> !ps -ef |grep pmon
grid      2247     1  0 Aug01 ?        00:03:01 asm_pmon_+ASM2
oracle    2798     1  0 Aug01 ?        00:04:51 ora_pmon_ORCL2
oracle    2802     1  0 Aug01 ?        00:04:15 ora_pmon_RCAT
oracle    8553     1  0 Aug21 ?        00:00:38 ora_pmon_DGS
oracle    8974     1  0 Jul30 ?        00:02:14 ora_pmon_TTS
oracle   11882 20904  0 14:58 pts/2    00:00:00 /bin/bash -c ps -ef |grep pmon
oracle   11884 11882  0 14:58 pts/2    00:00:00 grep pmon



RMAN@RCAT> exec dbms_rcvcat.unregisterdatabase(68262,1084485603);

PL/SQL procedure successfully completed.

RMAN@RCAT> select db_key, dbid, name from rc_database;

    DB_KEY       DBID NAME
---------- ---------- --------
    192555 1769654909 TTS
       261 1716975309 DG
         1 1330909046 ORCL

Thursday, August 29, 2013

change default tablespace of db setting

COLUMN property_name FORMAT A30
COLUMN property_value FORMAT A30
COLUMN description FORMAT A50
SET LINESIZE 200

SELECT *
FROM database_properties
WHERE property_name like '%TABLESPACE';


PROPERTY_NAME                  PROPERTY_VALUE                 DESCRIPTION
------------------------------ ------------------------------ --------------------------------------------------
DEFAULT_TEMP_TABLESPACE        TEMP                           Name of default temporary tablespace
DEFAULT_PERMANENT_TABLESPACE   SYSTEM                         Name of default permanent tablespace



SYS@cust1> create user liqy identified by liqyliqy;

User created.

SYS@cust1> select * from dba_users where username='LIQY';

USERNAME                          USER_ID PASSWORD                       ACCOUNT_STATUS                   LOCK_DATE           EXPIRY_DATE         DEFAULT_TABLESPACE
------------------------------ ---------- ------------------------------ -------------------------------- ------------------- ------------------- ------------------------------
TEMPORARY_TABLESPACE           CREATED             PROFILE                        INITIAL_RSRC_CONSUMER_GROUP
------------------------------ ------------------- ------------------------------ ------------------------------
EXTERNAL_NAME
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
PASSWORD E AUTHENTI
-------- - --------
LIQY                                   58                                OPEN                                                                     SYSTEM
TEMP                           2013-08-26 14:43:47 DEFAULT                        DEFAULT_CONSUMER_GROUP

10G 11G  N PASSWORD



SYS@rcat> desc database_properties
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 PROPERTY_NAME                             NOT NULL VARCHAR2(30)
 PROPERTY_VALUE                                     VARCHAR2(4000)
 DESCRIPTION                                        VARCHAR2(4000)

SYS@rcat> select * from database_properties where PROPERTY_NAME like 'DEFAULT%';

PROPERTY_NAME
------------------------------
PROPERTY_VALUE
--------------------------------------------------------------------------------
DESCRIPTION
--------------------------------------------------------------------------------
DEFAULT_TEMP_TABLESPACE
TEMP
Name of default temporary tablespace

DEFAULT_PERMANENT_TABLESPACE
SYSTEM
Name of default permanent tablespace

DEFAULT_EDITION
ORA$BASE
Name of the database default edition

DEFAULT_TBS_TYPE
SMALLFILE
Default tablespace type


SYS@rcat> ALTER database default tablespace users;

Database altered.

SYS@rcat> select * from database_properties where PROPERTY_NAME like 'DEFAULT%';

PROPERTY_NAME
------------------------------
PROPERTY_VALUE
--------------------------------------------------------------------------------
DESCRIPTION
--------------------------------------------------------------------------------
DEFAULT_TEMP_TABLESPACE
TEMP
Name of default temporary tablespace

DEFAULT_PERMANENT_TABLESPACE
USERS
Name of default permanent tablespace

DEFAULT_EDITION
ORA$BASE
Name of the database default edition

DEFAULT_TBS_TYPE
SMALLFILE
Default tablespace type

Tuesday, August 27, 2013

what decides number of records in v$log_history

V$log_history retention is defined by MAXLOGHISOTRY when you create the database (or recreate the controlfile)

MAXLOGHISTORY Clause
This parameter is useful only if you are using Oracle Database in archivelog mode with Real Application Clusters. Specify the maximum number of archived redo log files for automatic media recovery of Real Application Clusters. The database uses this value to determine how much space to allocate in the control file for the names of archived redo log files. The minimum value is 0. The default value is a multiple of the MAXINSTANCES value and depends on your operating system. The maximum value is limited only by the maximum size of the control file.

SQL> SELECT min(first_time), max(first_time) from v$log_history;

MIN(FIRST MAX(FIRST
--------- ---------
08-AUG-13 26-AUG-13

SQL> SELECT count(*) from v$log_history;                       

  COUNT(*)
----------
      5445
SQL> select * from V$CONTROLFILE_RECORD_SECTION where type='LOG HISTORY';

TYPE                         RECORD_SIZE RECORDS_TOTAL RECORDS_USED FIRST_INDEX LAST_INDEX LAST_RECID
---------------------------- ----------- ------------- ------------ ----------- ---------- ----------
LOG HISTORY                           56          5445         5445        3462       3461     580177

Tuesday, June 18, 2013

Dangerous autoextensive tempfile

Developer feedback running a sql in a recently cloned database 11.2.0.2 ADMB2 and hit funny error ora-01114.

Error as follows.
ORA-01114: IO error writing block to file (block # )
ORA-01114: IO error writing block to file 201 (block # 2321408)
ORA-27072: File I/O error
Additional information: 4
Additional information: 2321408
Additional information: -1

Tested it in source database ,there is no such error.

Invoked oerr to lookup the error message, the file id complained is 201,  which is not found in dba_data_files.


dbsvr9:ADMB2:/software/oracle1/admin/scripts/performance> oerr ora 1114
01114, 00000, "IO error writing block to file %s (block # %s)"
// *Cause:  The device on which the file resides is probably offline. If the
//          file is a temporary file, then it is also possible that the device
//          has run out of space. This could happen because disk space of
//          temporary files is not necessarily allocated at file creation time.
// *Action: Restore access to the device or remove unnecessary files to free
//          up space.

Then focuse on checking temporary files.

However, the tempfile is about 18GB already and almost 100% free as show below.
and, the mount pointing of tempfile is 100% used.


SYS@ADMB2> select * from dba_temp_files;

FILE_NAME
------------------------------------------------------------------------------------------------------------------------------------
   FILE_ID TABLESPACE_NAME                     BYTES     BLOCKS STATUS  RELATIVE_FNO AUT   MAXBYTES  MAXBLOCKS INCREMENT_BY
---------- ------------------------------ ---------- ---------- ------- ------------ --- ---------- ---------- ------------
USER_BYTES USER_BLOCKS
---------- -----------
/admadm/ADMB2/temp01.dbf
         1 TEMP                           1.9018E+10    2321536 ONLINE             1 YES 3.4360E+10    4194302           80
1.9017E+10     2321408


SYS@ADMB2> @chk_temp_by_user.sql
check tempoary space used by session

no rows selected


no rows selected

SYS@ADMB2> @chk_temp_usage.sql

percent used
------------
           0


TABLESPACE             MB_TOTAL    MB_USED    MB_FREE
-------------------- ---------- ---------- ----------
TEMP                      18137          0      18137



Funny.
What does file_id 201 stand for ?
No session is hogging the temp tablespace.


The next intuition  is why the tempfile is antoextensive.

Trying to turn id off, and shank it down.

SYS@ADMB2> alter database tempfile '/admadm/ADMB2/temp01.dbf' autoextend off;

Database altered.

SYS@ADMB2> alter database tempfile '/admadm/ADMB2/temp01.dbf' resize 2g;

Database altered.

At last, run the sql again. wow, 15429 rows selected, and right close 7pm, and luckily this is not a production database.



From this case, it seems to even when there is free space in temporary tablespace, Oracle database always acquires space from file system, although there is no more disk space in the file system, and can't look from existing tablespace.  Such behaviour is "silly" and dangerous.


Wednesday, June 12, 2013

How to Compare Two Versions of the Same Word 2010 Documents

useful link I found, mark here.

How to Compare Two Versions of the Same Word 2010 Document

 Compare documents side by side

Prerequisites of privilege needed for creating a view

re-read the oracle document and gain the following and highlight in bold for underlying base table owned another schema.

Prerequisites
To create a view in your own schema, you must have the CREATE VIEW system privilege. To create a view in another user's schema, you must have the CREATE ANY VIEW system privilege.
To create a subview, you must have the UNDER ANY VIEW system privilege or the UNDER object privilege on the superview.
The owner of the schema containing the view must have the privileges necessary to either select, insert, update, or delete rows from all the tables or views on which the view is based. The owner must be granted these privileges directly, rather than through a role.

Monday, May 06, 2013

Proud to be the first student from customer side

This morning , it is not until I enter the classroom of Oracle 12c database New Feature workshop, that I come to realize that I am the first student from customer's side to accept the training countrywide.

This is kind of proud to me. Thanks my boss and my company.  It is really fun with the biggest feature for the first day : CDB (Contain database) and PDB(pluggable database container).

Imaging the container is a real cargo ship's container, then the CDB can be looked as a seaport. This is easier to understand their relationship for me.

Meanwhile, recently a hot new from Beijing is that for those migrant worker lives inside a container can stay in cheaper price (due to sky-high property price), which only costs RMB 8 per day.  Hope Oracle 12c can do the same thing, to lower down the total cost.