Database Administration IS4510 Lab Manual
Database Administration IS4510 Lab Manual
Database Administration IS4510 Lab Manual
IS4510
Compiled by:
Zafar Iqbal Khan
Lecturer, Dept of IS, CCES,
Salaman bin Abdul Aziz University
Lab Session - 1
Objective:- To be aware of various Oracle Database Startup & Shutdown options
Description:- After completion of this session you would be able start and shut down oracle
instance in various modes and test oracle listener
1. To start Oracle Instance do following, at command prompt
C:\Windows\System32>sqlplus
SQL*Plus: Release 11.2.0.2.0 Production on Mon Dec 29 08:32:43 2014
Copyright (c) 1982, 2014, Oracle.
Compiled and Tested by Zafar Iqbal Khan, IS, CCES, SAU @ Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Ed
835104768
2257800
499125368
331350016
2371584
bytes
bytes
bytes
bytes
bytes
835104768
2257800
499125368
331350016
2371584
bytes
bytes
bytes
bytes
bytes
Compiled and Tested by Zafar Iqbal Khan, IS, CCES, SAU @ Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Ed
10. To check the listener parameters and ping oracle server, do this
C:\Windows\System32>tnsping xe
TNS Ping Utility for 64-bit Windows: Version 11.2.0.2.0 Production on 29-DEC-2
014 09:06:58
Copyright (c) 1997, 2014, Oracle.
Compiled and Tested by Zafar Iqbal Khan, IS, CCES, SAU @ Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Ed
Lab Session - 2
Objective:- To Analyze various memory structures of Oracle Instance and its components.
1. To see various memory parameters
SQL> show parameter memory
NAME
-----------------------------------hi_shared_memory_address
memory_max_target
memory_target
shared_memory_address
TYPE
----------integer
big integer
big integer
integer
VALUE
------0
1G
1G
0
TYPE
----------string
big integer
VALUE
------ON
0
Compiled and Tested by Zafar Iqbal Khan, IS, CCES, SAU @ Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Ed
TYPE
----------big integer
big integer
VALUE
------7M
0
TYPE
----------integer
integer
integer
integer
big integer
big integer
integer
big integer
big integer
VALUE
----0
1440
0
0
800M
800M
64
0
0
Compiled and Tested by Zafar Iqbal Khan, IS, CCES, SAU @ Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Ed
Lab Session 3
Objective:- To manually manage various memory parameters of oracle instance.
Description:- SGA_TARGET , SGA_MAX_SIZE , Memory_Target and Memory_Max_Size are the
parameter used by Oracle Instance to allocate memory to various memory structures.
SGA_TARGET :- It specifies the total amount of SGA memory available to an instance. Setting
this parameter makes Oracle distribute the available memory among various components such as shared pool (for SQL and PL/SQL), Java pool, large_pool and buffer cache - as
required.
This new feature is called Automatic Shared Memory Management. With ASMM, the
parameters java_pool_size, shared_pool_size, large_pool_size and db_cache_size need not
be specified explicitely anymore.
* sga_target cannot be higher than sga_max_size.
Compiled and Tested by Zafar Iqbal Khan, IS, CCES, SAU @ Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Ed
Compiled and Tested by Zafar Iqbal Khan, IS, CCES, SAU @ Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Ed
Lab Session - 4
Objective:- To locate the oracle alert log file and then read the alert log file messages.
Exercise:On SQL, prompt issue command
SQL> show parameter background
NAME
TYPE
VALUE
------------------------------------ ----------- -----------------------------background_core_dump
string partial
background_dump_dest
string C:\oraclexe\app\oracle\diag\rdbms\xe\xe\trace
Inside trace folder alert_xe is the alert log file.
Alternatively, Oracle 11g also stores alert log in XML format which can be accessed at
SQL> select * from v$diag_info where name='Diag Alert';
INST_ID
NAME
VALUE
-----------------------------------------------------------------------------------------------------------------------1
Diag Alert
C:\ORACLEXE\APP\ORACLE\diag\rdbms\xe\xe\alert
Inside alert folder log.xml is the alert log in XML form.
Compiled and Tested by Zafar Iqbal Khan, IS, CCES, SAU @ Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Ed
Lab Session - 5
Objective:- To learn creation & manipulation of tablespaces, resizing them, reclaiming free
space, making them online/offline.
1. To know the name & no of tablespaces in any database, login with sys as sysdba
SQL> select * from V$TABLESPACE;
TS#
---------0
2
1
4
3
6
NAME
-----------------------------SYSTEM
UNDOTBS1
SYSAUX
USERS
TEMP
RMAN_TB
INC
--YES
YES
YES
YES
NO
YES
BIG
--NO
NO
NO
NO
NO
NO
FLA ENC
--- ----YES
YES
YES
YES
YES
YES
6 rows selected.
Compiled and Tested by Zafar Iqbal Khan, IS, CCES, SAU @ Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Ed
Compiled and Tested by Zafar Iqbal Khan, IS, CCES, SAU @ Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Ed
Lab Session - 6
Objective:- To create user & grant it privileges & revoke them.
1. To create a user demo with password demo1
SQL> create user demo identified by demo
2 default tablespace users
3 temporary tablespace temp;
User created.
* here users & temp are system tablespaces
2. Grant privileges to demo
SQL> grant connect, resource to demo;
Grant succeeded.
3. Now grant access to table employees from user HR to user demo
SQL> grant select on hr.employees to demo;
Grant succeeded.
4. Login to user demo
SQL> conn demo/demo
Connected.
5. Select some data from EMPLOYEES table of user HR
SQL> select email, salary from hr.employees where
first_name='William';
EMAIL
SALARY
------------------------- ---------WGIETZ
8300
WSMITH
7400
6. Again login to sys as sysdba
SQL> conn sys as sysdba
Enter password:
Connected.
Compiled and Tested by Zafar Iqbal Khan, IS, CCES, SAU @ Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Ed
Compiled and Tested by Zafar Iqbal Khan, IS, CCES, SAU @ Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Ed
Lab Session 7
Export & Import Datapump
Objective:- To create oracle logical backup by exportdp and then restore database from this
logical backup to original state by importdp
1. Create a folder C:\test
2. Login in oracle as sysdba
3. Create a directory in oracle with following command
Connected to: Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Pro
duction
Starting "HR"."SYS_EXPORT_TABLE_01":
file=demo.dmp logfile=demo.log;
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 64 KB
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . exported "HR"."EMP"
16.80 KB
107 rows
Compiled and Tested by Zafar Iqbal Khan, IS, CCES, SAU @ Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Ed
All rights
Connected to: Oracle Database 11g Express Edition Release 11.2.0.2.0 64bit Pro
duction
Master table "HR"."SYS_SQL_FILE_FULL_01" successfully loaded/unloaded
Starting "HR"."SYS_SQL_FILE_FULL_01":
dumpfile=demo.
hr/******** directory=demo
Compiled and Tested by Zafar Iqbal Khan, IS, CCES, SAU @ Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Ed
Lab Session - 8
Objective:- Creating backup of Oracle Database with Recovery Manager (RMAN)
Steps:- Since database backup can be done only when it is in Archive Log mode.
Normally database works in Non Archive Log mode, so we will first change
log_mode of database, then will take backup
1. First run following query to check database status
SQL>select log_mode from v$database;
2. If status is NonArchivelog mode then shutdown database from oracle
prompt
SQL>shutdown immediate
3. Now change database to archivelog mode
SQL>Alter database archivelog;
4. Now from another command window, run following query
C:\Windows\System32>rman target /
it will find database, and show you RMAN prompt
5. From rman prompt, run following query
RMAN>backup as backupsets database;
Compiled and Tested by Zafar Iqbal Khan, IS, CCES, SAU @ Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Ed
Lab Session - 9
Objective:- To Create a user for RMAN recovery, create Catalog and register database to catalog for
recovery operations
Procedure:- First we will create an schema for RMAN recovery. We will create a tablespace and an user
with administrative privileges, then we will grant all privileges required for creating backups to this user,
after this will create a catalog and register our target database with this catalog.
Steps:
1. Create a recovery tablespace, in this case we give it name rman_tb, before doing this create
directories(c:\rman\backup\+rman) in Windows file system
SQL> create tablespace rman_tb datafile
'c:\rman\backup\+rman\datafile01.dbf'size 10M autoextend on;
Tablespace created.
2. Now create user for recovery, we give it name rman and its password is also rman (to do this
login with sys as sysdba)
SQL> create user rman identified by rman
2 default tablespace rman_tb
3 temporary tablespace temp;
User created.
3. Now grant privileges to user rman necessary for creating catalog
SQL> grant resources, connect,
recovery_catalog_owner to rman;
Grant succeeded.
4. Now relogin from same window as user rman
SQL> conn rman/rman;
Connected.
5. Check for registered database
SQL> select * from rc_database;
no rows selected
(this means that no database has been registered to our recovery schema.)
Compiled and Tested by Zafar Iqbal Khan, IS, CCES, SAU @ Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Ed
All
Compiled and Tested by Zafar Iqbal Khan, IS, CCES, SAU @ Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Ed