DBA

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 9

Database Administration

ASSIGNMENT 1
Aneeba Tanveer (Info,Tech-17057)
IT (7th)
1.
Connect to the database as user SYS and shut down the database.
SQL> CONNECT / AS SYSDBA Connected.
SQL>
SQL> SHUTDOWN IMMEDIATE Database closed.
Database dismounted. ORACLE instance shut down.

2.
With the database shut down, create an SPFILE from the PFILE.
The SPFILE will be created in $ORACLE_HOME/dbs.
SQL> CONNECT / AS SYSDBA Connected to an idle instance. SQL> CREATE SPFILE
FROM PFILE; File created.

3.
From the operating system, view the SPFILE.
SQL> !more $ORACLE_HOME/dbs/spfileU481.ora
*.background_dump_dest=’/home1/user481/ADMIN/BDUMP’ *.compatible=’9.2.0’
*.control_files=’/home1/user481/ORADATA/u01/ctrl01.ctl’
*.core_dump_dest=’/home1/user481/ADMIN/CDUMP’ *.db_block_size=4096
*.db_cache_size=16M
*.db_domain=’world’
*.db_name=’U481’
*.global_names=TRUE
*.job_queue_processes=2
*.log_buffer=64000 *.max_dump_file_size=’10240’ *.shared_pool_size=48M
*.undo_management=’AUTO’ *.undo_tablespace=’UNDOTBS’
*.user_dump_dest='/home1/user481/ADMIN/UDUMP‘ ...

4.
Connect as user SYS, and start the database using the SPFILE.
SQL> CONNECT / AS SYSDBA Connected to an idle instance. SQL> STARTUP
ORACLE instance started.
Total System Global Area
Fixed Size
Variable Size
Database Buffers
Redo Buffers
Database mounted.
26706720 bytes
729888 bytes
20971520 bytes
4194304 bytes
811008 bytes

5 A).
Shut down the database and open it in read-only mode.
SQL> SHUTDOWN IMMEDIATE Database closed.
Database dismounted. ORACLE instance shut down. SQL> STARTUP MOUNT
Total System Global Area
Fixed Size
Variable Size
Database Buffers
26706720 bytes
729888 bytes
20971520 bytes
4194304 bytes
811008 bytes
Redo Buffers
Database mounted.
SQL> ALTER DATABASE OPEN READ ONLY; Database altered.

B).
Connect as user HR password HR and insert a row into the REGIONS table as follows:
INSERT INTO regions VALUES (5, ’Mars’);
What happens?
SQL> CONNECT HR/HR
Connected.
SQL> INSERT INTO regions VALUES (5, ’Mars’); INSERT INTO regions VALUES
(5,’Mars’);
ERROR at line 1:
ORA-01552: cannot use system rollback segment for non-system tablespace
’SAMPLE’

C).
Put the database back in read-write mode.
SQL> CONNECT / AS SYSDBA Connected.
SQL> SHUTDOWN IMMEDIATE Database closed.
Database dismounted. ORACLE instance shut down. SQL> STARTUP
ORACLE instance started.
Total System Global Area
Fixed Size
Variable Size
Database Buffers
Redo Buffers
Database mounted.
Database opened.
26706720 bytes
729888 bytes
20971520 bytes
4194304 bytes
811008 bytes

6 A).
Connect as user HR password HR and insert the following row into the REGIONS table;
do not commit or exit.
INSERT INTO regions VALUES (5, ’Mars’);
HR SESSION
SQL> CONNECT HR/HR
Connected.
SQL> INSERT INTO regions VALUES (5, ’Mars’); 1 row created.

B).
In a new telnet session start SQL*Plus. Connect user SYS and perform
SYS SESSION
SQL> CONNECT / AS SYSDBA Connected.
SQL> SHUTDOWN TRANSACTIONAL

C).
Roll back the insert in the HR session and exit. What happens to the HR Session?
HR SESSION
SQL> ROLLBACK; Rollback complete. SQL> EXIT;
ERROR:
ORA-01089: immediate shutdown in progress - no operations are permitted
JServer Release 9.0.0.0.0 - Beta (with complications)
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.1.0 - 64bit Productn
With the Partitioning, Oracle Label Security, OLAP and Oracle Data Mining optios
JServer Release 9.2.0.1.0 - Production
WhathappenstotheHRsession? AnORA-01089messageisreceived.TheHR user cannot EXIT
because the SYS user has issued a SHUTDOWN TRANSACTIONAL. No other operations are
allowed.
WhathappenstotheSYSsession? OncetheHRsessioncompletesaROLLBACK, the SYS session
will shut down the database.
The HR session will be disconnected based on its EXIT command.
SYS SESSION
Database closed.
Database dismounted.
ORACLE instance shut down.
HR SESSION
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.1.0 - 64bit Productn
With the Partitioning, Oracle Label Security, OLAP and Oracle Data Mining optios
JServer Release 9.2.0.1.0 - Production

7 A).
In the user SYS session start the database.
SYS SESSION
SQL> STARTUP
ORACLE instance started. Total System Global Area Fixed Size
Variable Size
Database Buffers
Redo Buffers
Database mounted. Database opened.
26706720 bytes
729888 bytes
20971520 bytes
4194304 bytes
811008 bytes

B).
In the open telnet session start SQL*Plus and connect as user HR.
Note: Keep the two SQL*Plus sessions open, one session as user SYS and one as
user HR.
HR SESSION
$ sqlplus /nolog
SQL*Plus: Release 9.2.0.1.0 - Production on Wed Jul 24
16:52:51 2002
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
SQL> CONNECT HR/HR Connected.

C).
As user SYS enable restricted session.
SYS SESSION
SQL> ALTER SYSTEM ENABLE RESTRICTED SESSION; System altered.

7 A).
As user HR, SELECT from the REGIONS table. Is the SELECT successful?
Yes
HR SESSION
SQL> SELECT * FROM regions; REGION_ID REGION_NAME
---------- -------------------------
1 Europe
2 Americas
3 Asia
4 Middle East and Africa

E).
Exit the session, then reconnect as HR. What happens? The user HR does not have
RESTRICTED SESSION privilege, and therefore, cannot log in.
HR SESSION
SQL> EXIT
Disconnected from Oracle9i Enterprise Edition Release
9.2.0.1.0 - 64bit Productn
With the Partitioning, Oracle Label Security, OLAP and Oracle Data Mining optios
JServer Release 9.2.0.1.0 - Production $ sqlplus /nolog
SQL*Plus: Release 9.2.0.1.0 - Production on Wed Jul 24 17:00:35 2002
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
SQL> CONNECT HR/HR ERROR:
ORA-01035: ORACLE only available to users with RESTRICTED SESSION privilege
Warning: You are no longer connected to ORACLE.

F).
As user SYS disable restricted session.
Exit HR telnet session.
SYS SESSION
SQL> ALTER SYSTEM DISABLE RESTRICTED SESSION; System altered.
HR SESSION
$ EXIT
This session is no longer connected.

You might also like