Professional Documents
Culture Documents
PRACTICAL #
STEP # 1: Create a script file on note pad and write following SQL statement on notepad file
Select * from emp ;
Select * from emp where job=’SALESMAN’;
Select sum(sal), min(sal), max(sal) from emp;
Select * from emp
Where sal > (select sal from emp where ename=’SMITH’);
Update emp Set job=’SALESMAN’;
Select * from emp;
Rollback;
Select * from emp Where ename like ‘&\_%’ escape ‘\’;
Select * from emp Where job in ( select job from emp where empno=7788);
Insert into emp Values
(9999,’RAHEEL’,’SALESMAN’,’’,’’,’’,’’,’’);
Now save the notepad file with sql extension my_script.sql at any destination
STEP # 2: On Sqlplus or Isqlplus
@path of the file destination of the file you create above like
@ E:\PRACTICE\Raheel\my_script.sql
2 Prepared by: Syed Raheel-ur-Rehman
INITIALIZATION PARAMETER FILE
In order to start an instance and open the database, we must connect sysdba and enter the startup command. The
oracle server will then read the initialization parameter file and prepare the instance according to the
initialization parameters contained within. For this we must have sysdba privileges
There are two types of parameter files.
Static parameter file, PFILE, commonly referred as init<SID>.ora
Dynamic persistent server parameter file SPFILE, commonly referred as spfile<SID>.ora
ORDER OF PRECEDENCE:
When the command startup is used, the spfileSID.ora on the server side is used to start up the instance.
If the spfileSID.ora is not found the default Spfile.ora on the server side is used to start up the instance.
This work also be done without defining address and shutdown stage
SQL> Create spfile from pfile ;
AT NOMOUNT STAGE:
An instance is typically started only in NOMOUNT mode
During Database creation,
During Re-creation of control files,
Or During certain backup and recovery scenarios.
AT MOUNT STAGE:
Mounting a database includes the following tasks:
Associating a database with instance start at nomount stage.
Locating and opening the control file specified in the parameter file.
Reading the control file to obtain the name, status and destination of
DATA FILES AND ONLINE REDO LOG FILES
To perform special maintenance operations
Renaming data files
(data files for an offline tablespace can be renamed when the database is open)
Enabling and disabling online redo log file archiving, flashback options.
Performing full Database Recovery
We usually need to start up a database in mount mode when you’re doing activities such as performing a full
database recovery, changing the archive logging mode of the database, or renaming data files. Note that all
three of these operations require Oracle to access the data files but can’t accommodate any user operations in
the files.
AT OPEN STAGE:
4 Prepared by: Syed Raheel-ur-Rehman
The last stage of the startup process is opening the database. When the database is started in the open mode, all
valid users can connect to the database and perform database operations. Prior to this stage, the general users
can’t connect to the database at all. You can bring the database into the open mode by issuing the ALTER
DATABASE command as follows:
SQL> ALTER DATABASE OPEN;
Database altered.
More commonly, we simply use the STARTUP command to mount and open our database all at once:
SQL> STARTUP
To open the database, the Oracle server first opens all the data files and the online redo log files, and verify that
the database is consistent. If the database isn’t consistent—for example, if the SCNs in the control files don’t
match some of the SCNs in the data file headers—the background process will automatically perform an
instance recovery before opening the database. If media recovery rather than instance recovery is needed,
Oracle will signal that a database recovery is called for and won’t open the database until you perform the
recovery.
IN SHORT
Opening a database includes the following tasks:
Open online data files
Open online redo log files
NOTE If any of the data files or online redo log files are not present when you attempt to open the database,
then the oracle server returns an error.
STARTUP COMMAND use to start database
STARTUP NOMOUNT;
to move the database from NOMOUNT TO MOUNT or from
NOMOUNT TO OPEN use
ALTER DATABASE COMMAND
ALTER DATABASE MOUNT;
ALTER DATABASE OPEN;
PRACTICAL #
SQL> startup nomount
ORACLE instance started.
Total System Global Area 171966464 bytes
Fixed Size 787988 bytes
Variable Size 145750508 bytes
Database Buffers 25165824 bytes
Redo Buffers 262144 bytes
SQL>
SQL> alter database mount;
Database altered.
SQL> alter database open;
Database altered.
1- SHUTDOWN NORMAL:
No new connection can be made
Oracle server waits all users to disconnect
database and redo buffer written to the disk
7 Prepared by: Syed Raheel-ur-Rehman
Background process terminated and SGA remove from memory
Oracle closes and dismount database before shutdown
Next startup does not require recovery
2- SHUTDOWN TRANSACTIONAL:
No new connection can be made
User automatically disconnect after completing the transaction in progress
When all transaction finished shutdown occur immediately
Next startup does not require recovery
3- SHUTDOWM IMMEDIATE:
Current SQL statement being processed is not completed
Oracle server does not wait for the user who are currently connected to the database
Oracle closes and dismount database before shutdown.
Next startup does not require recovery
4- SHUTDOWN ABORT:
Oracle does not wait for user currently connected to the database
Database and redo buffers are not written to the disks
The instance terminated without closing the files
The database is not close or dismounts
Next startup requires instance recovery.