Search This Blog
Wednesday, August 31, 2011
Flashback table is not working with Materialized views
alter table t enable row movement;
insert into t values (1);
insert into t values (1);
insert into t values (1);
commit;
select sys.dbms_flashback.get_system_change_number,min(id), max(id), count(*) from t;
GET_SYSTEM_CHANGE_NUMBER MIN(ID) MAX(ID) COUNT(*)
------------------------ ---------- ---------- ----------
799014346 1 1 3
update t set id=2;
commit;
select sys.dbms_flashback.get_system_change_number,min(id), max(id), count(*) from t;
GET_SYSTEM_CHANGE_NUMBER MIN(ID) MAX(ID) COUNT(*)
------------------------ ---------- ---------- ----------
799014354 2 2 3
create materialized view t_mv
as
select id from t;
ORA-08194: Flashback Table operation is not allowed on materialized views
flashback table t to scn 799014346;
drop materialized view t_mv
flashback table t to scn 799014346;
How to flashback MVs and MV referred tables [ID 781112.1]
Friday, August 26, 2011
Bulk load insert - Example
PROCEDURE MIKE_BULK_EXAMPLE
AS
/* Fetch into user defined PL/SQL table */
TYPE CC IS TABLE OF TAB1%ROWTYPE INDEX BY BINARY_INTEGER;
plsql_tab_TAB1 CC;
BEGIN
DBMS_MVIEW.REFRESH('TAB1','C');
delete ccinfo;
commit;
SELECT
a,
b,
c,
d
BULK COLLECT INTO plsql_tab_TAB1
FROM TAB1;
FOR ALL i IN plsql_tab_tab1.FIRST .. plsql_tab_tab1.LAST
INSERT MAIN_TABLE VALUES plsql_tab_tab(i);
COMMIT;
commit;
END MIKE_BULK_EXAMPLE;
Thursday, August 25, 2011
Database high availability best practices 10g-11g
Database high availability best practices , for single-instance,RAC databases and data guard standby database.
- Always use spfile
- Multiplex control files
- Set control_file_record_keep_time long enough
- Multiplex production and standby redo log
- Log checkpoint to the alert
- Use auto tune checkpoints
- Enable archive mode and use flash recovery area
- Enable flashback database
- Enable block checking (db_block_checksum=true)
- Use automatic undo management
- Use locally managed tablespace
- Use segment space management auto
- Use re-sumable space allocation
- Use database resource manager
- Register all instances with remote Listeners
- Use Temporary tablespaces
Reference: Oracle database 10g : Real Application clusters (d17276gc10) p.11-16
Monday, August 22, 2011
Evaluating 1Z0-007: Introduction to Oracle9i SQL® Prepkits by ucertify
1. Simple, intuitive, user-friendly interface
2. One click dashboard makes it easy to find what you need
3. Guided learning steps you through the process of learning and test preparation, including crucial information about the exam format and test preparation tips
4. Reference Notes and Study Guides organized according to the actual test objectives
5. Numerous study aids, including study notes, flash cards,pop quizzes and more
6. Useful Technical Articles section contains information
written by industry experts and How To’s that help for easy look up to specific questions
7. Collaboration
8. Exhaustive practice questions and tests, starting with Diagnostic tests to determine your initial level
9. Learning and test modes
10. Customize your tests – decide how many questions,
combine one or more topics of your choice, quiz yourself
on a study note, increase the level of difficulty based on
your performance at any point in time, even create a test
based on the amount of time you have to take a test!
11. Feedback and assessment when you need it, including Gap Analysis that clearly indicate your areas of strength and weakness
12. Full length Final Practice test that closely simulates those on the certification exam to gauge your preparation level for the actual exam
See more at http://www.ucertify.com
Saturday, August 20, 2011
Managing OCR and Voting disk in Oracle 10gR2 RAC Database
Both files are managed by the crsd daemon. Voting disk is used for monitoring information for the members of the cluster. OCR is the cluster configuration file and contains everything about the cluster such as list of nodes , mapping between nodes and instances, application profiles and etc.Both file must be located on share device with RAW,CFS,OCFS filesystems. In 10gR2 RAC Database these files can not be hosted in ASM.
Manage OCR files
First determine the ocr and ocrmirror location
Way 1:
[oracle@rac1 crs]$ ocrcheck
Status of Oracle Cluster Registry is as follows :
Version : 2
Total space (kbytes) : 262120
Used space (kbytes) : 4644
Available space (kbytes) : 257476
ID : 1900957196
Device/File Name : /ocfs-disk/ocr0.ora
Device/File integrity check succeeded
Device/File Name : /ocfs-disk/ocr1.ora
Device/File integrity check succeeded
Cluster registry integrity check succeeded
Way 2:
[oracle@rac1 ocfs-disk]$ cat /etc/oracle/ocr.loc
ocrconfig_loc=/ocfs-disk/ocr0.ora
ocrmirrorconfig_loc=/ocfs-disk/ocr1.ora
local_only=FALSE
Ensure you have backup
[oracle@rac1 crs]$ ocrconfig -showbackup
rac1 2011/07/07 22:00:25 /oracle/crs/oracle/product/10.2.0/crs/cdata/crs
rac1 2011/07/07 18:00:11 /oracle/crs/oracle/product/10.2.0/crs/cdata/crs
rac1 2011/07/07 14:00:10 /oracle/crs/oracle/product/10.2.0/crs/cdata/crs
rac1 2011/07/06 01:59:58 /oracle/crs/oracle/product/10.2.0/crs/cdata/crs
rac1 2011/06/27 02:43:25 /oracle/crs/oracle/product/10.2.0/crs/cdata/crs
Move OCR and OCR mirror in a new Location
The cluster is UP
*** su - oracle ***
cp /dev/null /ocfs-disk/OCR-DISKS/ocr1.ora
cp /dev/null /ocfs-disk/OCR-DISKS/ocr2.ora
*** su root ( using oracle's profile) ****
ocrconfig -replace ocr /ocfs-disk/OCR-DISKS/ocr1.ora
ocrconfig -replace ocrmirror /ocfs-disk/OCR-DISKS/ocr2.ora
chown root /ocfs-disk/OCR-DISKS/ocr1.ora
chown root /ocfs-disk/OCR-DISKS/ocr2.ora
[oracle@rac2 ~]$ ocrcheck
Status of Oracle Cluster Registry is as follows :
Version : 2
Total space (kbytes) : 262120
Used space (kbytes) : 4644
Available space (kbytes) : 257476
ID : 1900957196
Device/File Name : /ocfs-disk/OCR-DISKS/ocr1.ora
Device/File integrity check succeeded
Device/File Name : /ocfs-disk/OCR-DISKS/ocr2.ora
Device/File integrity check succeeded
Cluster registry integrity check succeeded
Post Actions after file Remove
- Remove the old files manually
- Export the new ocr
*** su root ( using oracle's profile) ****
ocrconfig -export /ocfs-disk/OCR-EXPORTS/ocrExp.dmp
Manage Voting files
First determine the current voting disks location
[root@rac2 OCR-EXPORTS]# crsctl query css votedisk
0. 0 /ocfs-disk/vot0.ora
1. 0 /ocfs-disk/vot1.ora
2. 0 /ocfs-disk/vot2.ora
located 3 votedisk(s).
Backup the voting disks
*** su - oracle ***
dd if=/ocfs-disk/vot0.ora of=/ocfs-disk/VOT-BACKUP/vot0.ora.dmp bs=4k
dd if=/ocfs-disk/vot1.ora of=/ocfs-disk/VOT-BACKUP/vot1.ora.dmp bs=4k
dd if=/ocfs-disk/vot2.ora of=/ocfs-disk/VOT-BACKUP/vot2.ora.dmp bs=4k
Stop your rac system (databases,services, listener etc) using srvctl
Stop your crs as root
crsctl stop crs
as oracle
touch /ocfs-disk/VOT-DISKS/vdisk1.ora
touch /ocfs-disk/VOT-DISKS/vdisk2.ora
Use the touch since the file system is OCFS2
crsctl add css votedisk /ocfs-disk/VOT-DISKS/vdisk1.ora -force
Now formatting voting disk: /ocfs-disk/VOT-DISKS/vdisk1.ora
successful addition of votedisk /ocfs-disk/VOT-DISKS/vdisk1.ora.
crsctl add css votedisk /ocfs-disk/VOT-DISKS/vdisk2.ora -force
Now formatting voting disk: /ocfs-disk/VOT-DISKS/vdisk2.ora
successful addition of votedisk /ocfs-disk/VOT-DISKS/vdisk2.ora.
crsctl delete css votedisk /ocfs-disk/vot0.ora
crsctl delete css votedisk /ocfs-disk/vot1.ora
crsctl delete css votedisk /ocfs-disk/vot2.ora
[oracle@rac2 ~]$ crsctl query css votedisk
0. 0 /ocfs-disk/VOT-DISKS/vdisk1.ora
1. 0 /ocfs-disk/VOT-DISKS/vdisk2.ora
crsctl start crs
Metalink References
OCR / Vote disk Maintenance Operations: (ADD/REMOVE/REPLACE/MOVE) [ID 428681.1]
Failed to Start CRS stack After Adding a New Voting Disk [ID 460874.1]
Web Reference
Thursday, August 4, 2011
Remove or delete virtual disk from Virtual box
Monday, August 1, 2011
PL/SQL examples
Transportable tablespaces in Oracle 10g
Partitioning in 10g
Explain Data Block Addres
| |
| Explain Data Block Address |
| |
+-------------------------------------------------------------------------------------------+
| Techonology : Oracle database 10.2.0 |
+-------------------------------------------------------------------------------------------+
| Created : 29/7/2007 |
+-------------------------------------------------------------------------------------------+
| Document Scope: |
The scope of the document is to understand and use Data Block Address .
The Second argument of ORA-600 [3374] corresponds to the expected Data Block Address.
They are 11206682 and 2617431000. The blocks in these DBA are corrupted.
Let's convert DBA to corresponding (file#,block#)
Example1 :ORA-00600: internal error code, arguments: [3374], [16777298], [825371952],[875376697], [11824], [], [], []
SQL> SELECT dbms_utility.data_block_address_block(16777298)
2 FROM dual;
DBMS_UTILITY.DATA_BLOCK_ADDRESS_BLOCK(16777298)
-----------------------------------------------
82
SQL>
SQL> SELECT dbms_utility.data_block_address_file(16777298)
2 FROM dual;
DBMS_UTILITY.DATA_BLOCK_ADDRESS_FILE(16777298)
----------------------------------------------
4
The corruption block is the block_id 82 in file_id 4. To find which database objects
belong the corrupted block,use the following query.
SELECT tablespace_name, segment_type, owner, segment_name
FROM dba_extents
WHERE file_id = 4
and 82 between block_id AND block_id + blocks - 1;
TABLESPACE_NAME SEGMENT_TYPE OWNER
------------------------------ ------------------ ------------------------------
SEGMENT_NAME
--------------------------------------------------------------------------------
USERS TABLE SYS
T3
The example below , shows how to find the data block addreess base on file_id and some block_id.
SQL> select block_id,block_id + blocks - 1,relative_fno,file_id from dba_extents where segment_name='T3';
BLOCK_ID BLOCK_ID+BLOCKS-1 FILE_ID
---------- ----------------- ----------
81 88 4
SQL> SELECT dbms_utility.make_data_block_address(4,82)
2 FROM dual;
DBMS_UTILITY.MAKE_DATA_BLOCK_ADDRESS(4,82)
------------------------------------------
16777298
Relate Note :
Ref : http://sysdba.wordpress.com/2006/04/05/how-to-check-for-and-repair-block-corruption-with-rman-in-oracle-9i-and-oracle-10g/