Home » Archive

Articles in the Oracle Category

ORA-HOWTO, Oracle, Oracle Code »

[23 Nov 2009 | No Comment | 515 views]

Accessible Cursors

SELECT oc.user_name, st.sql_text
  FROM v$open_cursor oc,v$sqltext st
 WHERE oc.address    = st.address
      AND oc.hash_value = st.hash_value
 ORDER BY oc.user_name, st.piece
 
For performance reasons, pl/sql cursors are cached for future reuse. So once you use them up they will be added to LRU list of cursor table. Hence you can see them in v$open_cursor.          
Actual Open Cursors
select sum(a.value), b.name
  from v$sesstat a,v$statname b
 where a.statistic# = b.statistic#
   and b.name = ‘opened cursors current’
 group by b.name

ORA-HOWTO, Oracle, Tips Scripts »

[23 Nov 2009 | No Comment | 244 views]

There are lot of ways in which files are copied from one database to the other during database cloning or transporting tablespaces.
File transfers can be done using oracle package called “DBMS_FILE_TRANSFER”.
Let us assume we need to transfer a file x.dbf from database SOURCE_DB to database DEST_DB
Do the following :
AT SOURCE_DB:
==============
1)Create directory source_dir as ‘/u01/dbdata’;
2)Create database link remote_db
connect to system identified by manager
using ‘remmote_db’;
Make sure to add this entry in TNSNAMES.ORA file.
Check if the database link works by
select count(1) from dba_tables@remote_db;
AT DEST_DB:
============
create directory dest_dir as ‘/u02/dbdata’;
Now back to SOURCE_DB:
exec dbms_file_transfer.put_file(‘SOURCE_DIR’,’x.dbf’,’DEST_DIR’,’x.dbf’,’REMOTE_DB’);
Now the …

Administration, Backup Recovery, Oracle »

[23 Nov 2009 | No Comment | 240 views]

Your database has to be in archive log mode for this script to work.
Code:

RMAN> run {
2> # backup the database to disk
3> allocate channel d1 type disk;
4> backup
5> full
6> tag full_db
7> format ‘/backups/db_%t_%s_p%p’
8> (database);
9> release channel d1;
10> }

ORA-HOWTO, Oracle Code »

[23 Nov 2009 | No Comment | 298 views]

1. Enable tracing and set the maxiumum dump file size to unlimited:

SQL> ALTER SYSTEM SET timed_statistics = true;
SQL> ALTER SYSTEM SET max_dump_file_size = unlimited;

2. find sid and serial for session you want to trace:

SQL> SELECT sid, serial#, username from v$session;

3. start tracing:

SQL> execute dbms_system.set_sql_trace_in_session(sid, serial, true);

Now, all query and operation from the session are traced.
4. stop tracing:

SQL> execute dbms_system.set_sql_trace_in_session(sid, serial, false);

Read the trace file:
You can find trace files in user dump file destination (UDUMP):

SQL> SHOW parameter user_dump_dest
 
NAME …

Administration, Backup Recovery, Oracle »

[23 Nov 2009 | No Comment | 241 views]

This script will backup all the datafiles using the RMAN utility reducing the cost of resources.
Code:
resync catalog;
run {
allocate channel c1 type disk;
copy datafile 1 to ‘C:\rman1.dbf’;
copy datafile 2 to ‘C:\rman2.dbf’;
copy datafile 3 to ‘C:\rman3.dbf’;
copy datafile 4 to ‘C:\rman4.dbf’;
copy datafile 5 to ‘C:\rman5.dbf’;
}
exit
echo exiting after successful hot backup using RMAN

Oracle Code »

[23 Nov 2009 | No Comment | 402 views]

 

ALTER tablespace TABLESPACE ADD datafile ‘/path/datafile1.dbf’ size 512M;