Where to find oracle database installers ?



Oracle database installers can be found and installed from official oracle website.
Below are the links to download oracle database

  • From Oracle 11g Release2,  database installers can be found at below location http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html
  • Oracle Database 10.2 and 11.1 are no longer available for download from oracle website. The software is available as a media or FTP request for those customers who own a valid Oracle Database product license for any edition
  • These previously release version of database can be found on My Oracle Support
All the downloads of oracle database are on license basis so adhere to oracle licensing policy and contact oracle database sales group.





Read More Add your Comment 0 comments

What are triggers in oracle ?





Oracle lets us define procedures called triggers that run implicitly when an INSERTUPDATE, or DELETE statement is issued against the associated table or, in some cases, against a view, or when database system actions occur. These procedures can be written in PL/SQL or Java and stored in the database

Triggers are procedures that are stored in the database and implicitly run, or fired, when some event occurs.
SQL Statements Allowed in Trigger Bodies
The body of a trigger can contain DML SQL statements. It can also contain SELECT statements, but they must be SELECT... INTO... statements or the SELECT statement in the definition of a cursor.
DDL statements are not allowed in the body of a trigger. Also, no transaction control statements are allowed in a trigger. ROLLBACKCOMMIT, and SAVEPOINT cannot be used.For system triggers, {CREATE/ALTER/DROPTABLE statements and ALTER...COMPILE are allowed.

Types of Triggers
  • Row Triggers and Statement Triggers
  • BEFORE and AFTER Triggers
  • INSTEAD OF Triggers
  • Triggers on System Events and User Events

Sample script of triggers:

create or replace trigger trigchk
before insert or update or delete 
on emp
begin
if(to_char(sysdate,'DY') in ('SAT','SUN')) then
raise_application_error(-20101,'u r not allowed to do any transaction on weekend');

end if;


end;

-------------------------------------------------------------------------------------------------------

create or replace trigger trigsal
before update
on emp for each row
begin
if(:old.sal>:new.sal) then
raise_application_error(-20103,'nat a valid action');
end if;



end;

----------------------------------------------------------------------------
Create or replace trigger trigview
INSTEAD OF INSERT on vwempdept
for each row
begin
insert into dept(deptno,dname)  values (seq.nextval,new.dname);
insert into emp(empno,ename,sal,deptno) values(:new.empno,:new.ename,
:new.sal,:new.deptno); 

end;


Read More Add your Comment 0 comments

How to stop oracle database ?



Stopping/Shutdown the Oracle Database

There are certain ways to start oracle database like:

  • Using SQLPLUS
  • Using Oracle Enterprise manager (If DB is configured with EM)
  • Using Oracle Grid/cloud control (If DB is configured with GC)
Windows Database Shutdown

1. Logon to the database server as the administrator/OS user 2. To start the database instance, go to Start -> Settings -> Control Panel -> Administrative Tools -> Services.
3. Scroll down to the service for the database, for example: OracleServiceORCL
4. Right click and select Stop. A dialog box appears showing the progress of the shut-donw and after a few seconds it will disappear.
The database instance service is now stopped



Linux Database Shutdown


1. Logon to the database server as the administrator/OS user
2. To start the database instance, go to Terminal and set below environment variable if already not.
 On Bash shell,

export  ORACLE_HOME=<ORACLE_HOME value like /u01/app/oracle/product/11.2/db_1>
export PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_SID=<DB Name like orcl>
3. Connect to the database:
sqlplus / as sysdba OR Sqlplus sys/<pwd>@<TNS> as sysdba
4.enter the following command:
shutdown;
OR
Shutdown immediate;
OR
Shutdown abort; (for instant DB shutdown)


Read More Add your Comment 0 comments

How to start oracle database ?



Starting the Oracle Database

There are certain ways to start oracle database like:
  • Using SQLPLUS
  • Using Oracle Enterprise manager (If DB is configured with EM)
  • Using Oracle Grid/cloud control (If DB is configured with GC)
Windows Database Start Up

1. Logon to the database server as the administrator/OS user2. To start the database instance, go to Start -> Settings -> Control Panel -> Administrative Tools -> Services.
2. Scroll down to the service for the Listener and start listener on right click
3. Scroll down to the service for the database, for example: OracleServiceORCL
4. Right click and select Start. A dialog box appears showing the progress of the start-up and after a few seconds it will disappear.
The database instance service is now started.
5. Start a command window (Start -> Run -> type cmd) from which to start the database itself.
6. Issue the command to check that the ORACLE_SID is set to the correct value:
echo %ORACLE_SID% (If not then set correct ORACLE_HOME value)
NOTE: Expected output is ―ORCL
7. Connect to the database:
sqlplus / as sysdba
8. Typically the database will start automatically when the instance service is started .
If for some reason the database is not started, enter the following command:
startup;

Linux Database Start Up

1. Logon to the database server as the administrator/OS user
2. To start the database instance, go to Terminal and set below environment variable if already not.
 On Bash shell,
export  ORACLE_HOME=<ORACLE_HOME value like /u01/app/oracle/product/11.2/db_1>
export PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_SID=<DB Name like orcl>
3. Start listener
lsnrctl start <Listerner_name> (not requiered if listener name is LISTENER
4. Then connect to database
sqlplus / as sysdba OR Sqlplus sys/<pwd>@<TNS> as sysdba
4.enter the following command:
startup;

Then it will connect you to SQL> prompt after database is in OPEN mode.


Read More Add your Comment 0 comments

Oracle RMAN Commands and Scripts Examples



Full Backup

Full database plus archivelog backup  on file system
 
RMAN> configure retention policy to recovery window of 7 days;
RMAN> configure default device type to disk;
RMAN> configure controlfile autobackup on;
RMAN> configure channel device type disk format 'D:\Oracle\Admin\db2\Backup%d_DB_%u_%s_%p';
 
RMAN> run {
2>   backup database plus archivelog;
3>   delete noprompt obsolete;
4> }
 
 
#*** Weekly full database plus archivelog backup Script on disk
BACKUP CHECK LOGICAL
AS COMPRESSED BACKUPSET
INCREMENTAL LEVEL = 0
DEVICE TYPE DISK
TAG = 'WEEKLY_DATABASE'
FORMAT '/srv/oradata/backups/weekly_database_%d_t%t_s%s_p%p'  or ’Path’
DATABASE;

#*** Daily full database backup Script on disk
BACKUP CHECK LOGICAL
AS COMPRESSED BACKUPSET
INCREMENTAL LEVEL = 1 CUMULATIVE
DEVICE TYPE DISK
TAG = 'DAILY_COMULATIVE_DATABASE'
FORMAT '/srv/oradata/backups/daily_comulative_database_%d_t%t_s%s_p%p' or ‘Path’
DATABASE;

#*** Maintenance steps
CROSSCHECK COPY;
CROSSCHECK BACKUP;
CROSSCHECK ARCHIVELOG ALL;
DELETE NOPROMPT OBSOLETE;
DELETE NOPROMPT EXPIRED COPY;
DELETE NOPROMPT EXPIRED BACKUP;
DELETE NOPROMPT EXPIRED ARCHIVELOG ALL;

Restore & Recover The Whole Database


If the control files and online redo logs are still present a whole database recovery can be achieved by running the following script:
run {
  shutdown immediate; # use abort if this fails
  startup mount;
  restore database;
  recover database;
  alter database open;
}


 

SAMPLE RMAN SCRIPTS
run
{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
set newname for datafile 1 to 
'/extracts1/DB01_temp/system_01a.dbf';
set newname for datafile 2 to 
'/extracts1/DB01_temp/rbslrg01.dbf';
set newname for datafile 3 to 
'/extracts1/DB01_temp/tools01.dbf';
set newname for datafile 4 to 
'/extracts1/DB01_temp/temp01.dbf';
set newname for datafile 5 to 
'/extracts1/DB01_temp/usersdata01.dbf';
set newname for datafile 6 to 
'/extracts1/DB01_temp/usersidx01.dbf';
set newname for datafile 7 to 
'/extracts1/DB01_temp/oem_repository.dbf';
set newname for datafile 8 to 
'/extracts1/DB01_temp/users01.dbf';
restore database ;
switch datafile all;
}


-- If archivelogs are backed up by RMAN, use RMAN to restore them:
 rman target / nocatalog
 allocate channel ch1 type disk;
 run {
 restore archivelog from time = 'date-of-start-of-backup';
 }
 exit


rman target / nocatalog
allocate channel ch1 type disk;
run {
restore database;
}
exit

Hot Backup
Hot backups using RMAN are very simple. There is no need to alter the tablespace or database mode.
run {
  allocate channel ch1 type disk format 'd:\oracle\backup%d_DB_%u_%s_%p';
  backup database;
  backup archivelog all;
  release channel ch1;
}


Read More Add your Comment 0 comments

Steps to create oracle RMAN Recovery catalog



Recovery catalog

A recovery catalog is a database schema used by RMAN to store metadata about Oracle databases. Generally, we store the catalog in a separate database. 

Benefits of Recovery catalog are: 

  • A recovery catalog creates redundancy for the RMAN repository stored in the control file of each target database. If the target control file and all backups are lost, then the RMAN metadata still exists in the recovery catalog.
  • A recovery catalog centralizes metadata for all target databases. simpler reporting and administration of backups.
  • A recovery catalog can store metadata history much longer than the control file.

    The catalog includes the following types of metadata:
    • Datafile and archived redo log backup sets and backup pieces
    • Datafile copies
    • Archived redo logs and their copies
    • Database structure (tablespaces and datafiles)
    • Stored scripts, which are named user-created sequences of RMAN commands
    • Persistent RMAN configuration settings

Step 1. Create Recovery  Catalog

-- Create tablepsace to hold repository
SQL>CREATE TABLESPACE "RMAN" 
DATAFILE 'D:\ORACLE \ORADATA\DB1\RMAN01.DBF' SIZE 1000K REUSE
AUTOEXTEND ON;
 
-- Create rman schema owner
SQL>CREATE USER rman IDENTIFIED BY rman
TEMPORARY TABLESPACE temp 
DEFAULT TABLESPACE rman 
QUOTA UNLIMITED ON rman;
 
SQL>GRANT connect, resource, recovery_catalog_owner TO rman;

C:>rman catalog=rman/rman@db1
 
Recovery Manager: Release 9.2.0.1.0 - Production
 
Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.
 
connected to recovery catalog database
recovery catalog is not installed
 
RMAN> create catalog tablespace "RMAN";
 
recovery catalog created
 
RMAN> exit
 
Recovery Manager complete.
 

Step 2. Register Database

C:>rman catalog=rman/rman@db1 target=sys/password@db2
 
Recovery Manager: Release 9.2.0.1.0 - Production
 
Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.
 
connected to target database: db2 (DBID=1371963417)
connected to recovery catalog database
 
RMAN> register database;
 
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
 
RMAN>


Read More Add your Comment 0 comments

What are different modes of Backup in Oracle RMAN ?



Backup Modes in Oracle RMAN:

Backup Type
Definition
Full
This is method in which backup of a datafile that includes every allocated block in the file being backed up. A full backup of a datafile can be an image copy, in which every data block is backed up. It can also be stored in a backup set, in which case datafile blocks not in use may be skipped. 

A full backup cannot be part of an incremental backup strategy; that is, it cannot be the parent for a subsequent incremental backup.
Incremental
An incremental backup is either a level 0 backup, which includes every block in the file except blocks compressed out because they have never been used, or a level 1 backup, which includes only those blocks that have been changed since the parent backup was taken. 

A level 0 incremental backup is physically identical to a full backup. The only difference is that the level 0 backup is recorded as an incremental backup in the RMAN repository, so it can be used as the parent for a level 1 backup.


Read More Add your Comment 0 comments
 

© 2010 Codes & Concepts All Rights Reserved Thesis WordPress Theme Converted into Blogger Template by Hack Tutors.info