Administration, Backup Recovery, Oracle »

[23 Nov 2009 | No Comment | 653 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, Tips Scripts »

[23 Nov 2009 | No Comment | 501 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 …

ORA-HOWTO, Oracle, Oracle Code »

[23 Nov 2009 | No Comment | 954 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

MySql Error, Mysql »

[23 Nov 2009 | No Comment | 666 views]

1000 SQLSTATE: HY000 (ER_HASHCHK)

 

Message: hashchk

ORA-HOWTO, Oracle Code »

[23 Nov 2009 | No Comment | 603 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 | 629 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 | 818 views]

 

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

Administration, Backup Recovery, Oracle »

[23 Nov 2009 | No Comment | 434 views]

This script will perform datafile recovery
Code:
RMAN> run {
2> allocate channel d1 type disk;
3> sql “alter tablespace users offline immediate”;
4> restore datafile 5;
5> recover datafile 5;
6> sql “alter tablespace users online”;
7> release channel d1;
8> }

Backup Recovery »

[23 Nov 2009 | No Comment | 2,536 views]

rman target sys/change_on_install nocatalog
  run {
     allocate channel t1 type disk;
     # set until time ‘Apr 17 2004 22:11:51′;
     restore tablespace user;
     recover tablespace user;
     release channel t1;
  }

Administration, MS SqlServer, MS SqlServer Code, Tips Scripts »

[23 Nov 2009 | No Comment | 1,058 views]

These scripts have been created to set up a peer to peer system.
The settings I’ve used:

Login:
PAULSDOMAIN\Administrator

Password:
password

Database name:
peertopeerPublisher

Table with PK:
PITest

Server1
HOME-SERVER

Server2 
HOME-SERVER\FIRSTINSTANCE

You’ll need to create an identically named database on 2 servers (called peertopeerPublisher for me) or on a default and a named instance (this is because the publication names must be identical, so we can’t do this on the same instance). After that you’ll need to enable distribution on each server and publishing of the database. This is much the same as before, albeit in a different part of the GUI. There …