Professional Documents
Culture Documents
Workshop Scenarios
Workshop Scenarios
Practice 3 Solutions
1. Create a listener listenernn (nn will be a two digit number assigned to you by your
instructor) using Oracle Net Manager. The listener must be configured for the server as
provided by the instructor; this server contains an Oracle database Unn. The listener must
be configured for the TCP/IP protocol only and must listen for incoming connections on
the port provided by the instructor.
Note: If Oracle9i Oracle Net software is loaded on the student PC’s, the listener
configuration file will be created on the client PC using Oracle Net Manager and, in later
steps, transferred via FTP or similar file transfer application on the server.
For this practice and successive network practices, the TNS_ADMIN environment variable
must point to $HOME/NETWORK/ADMIN on the host where your Unix account resides.
Look in your .profile (located in your home directory) and search for an entry like this:
TNS_ADMIN=$HOME/NETWORK/ADMIN
export TNS_ADMIN
Edit the file and add the lines above if they don’t already exist. Log out and log back in
again for the changes to take effect.
If Oracle9i client software is not available on your workstation, the listener.ora must be
edited by hand. Sample networking files can be found in your $HOME/network/admin
directory. The sample files will all have .sam extensions. Copy listener.sam to
listener.ora and edit by hand using vi.
$ cd $TNS_ADMIN
$ cp listener.sam listener.ora
a. If Oracle9i is available on the PC, go to the NT Start menu on the client PC, select
Programs—>Oracle - Oracle Home—>Network Administration—>Oracle Net
Manager.
b. Click on the “Local” icon in the Net Configuration tree then click the Listeners
folder. Select “Create” from the Edit menu item, or click the “+” icon.
c. Enter a name for your listener (listenernn) in the Choose Listener Name dialog box
that appears and click OK. The name of the new listener will appear below the
Listeners folder in the left-hand pane of Net Manager.
d. Click the new listener name and select Listening Locations from the pull-down menu
on the right-hand pane in Net Manager if not already selected.
e. Click the Add Address button. A tab for the address details of the listener will
appear.
f. Select TCP as the protocol, if not already selected.
g. Enter the name of the server in the Host field, and the port number assigned for your
listener in the Port field (the port number is provided by your instructor). Leave TCP
as the default value for the Protocol.
h. Select Database Services from the pull-down menu on the right side of the screen in
Net Manager.
i. Click the Add Database button. A tab for the database on behalf of which the listener
will listen for incoming connections will appear.
10. Stop automatic archiving by executing the ALTER SYSTEM ARCHIVE LOG STOP
command.
SQL> alter system archive log stop;
System altered.
11. Execute the ALTER SYSTEM SWITCH LOGFILE command enough times to cycle
through all the online redo log groups. What happened and why?
SQL> alter system switch logfile;
System altered.
SQL> alter system switch logfile;
The database is in Archivelog mode. Automatic archiving is disabled the next redo log file
cannot be used since it has not been archived.
12. Establish a second telnet session and invoke SQL*Plus. Connect as sysdba.
13. Enable automatic archiving by using the ALTER SYSTEM ARCHIVE LOG START
command.
SQL> alter system archive log start;
System altered.
14. Return to your first session. What happened and why? You now have the “System
Altered” message followed by the SQL prompt. The archiver process has been restarted.
The log switch is now possible because the redo log files were archived when automatic
archiving was restarted.
5. Use the RECOVER TABLESPACE command to apply the redo logs to the datafile.
SQL > RECOVER TABLESPACE new_users;
6. When recovery is complete, bring the tablespace online.
SQL > ALTER TABLESPACE new_users ONLINE;
All data is now recovered. Include the file in the backup strategy and notify users that the
tablespace is ready to be used again.
7. Try again to update the rows in the HR.NEW_EMP table as follows:
SQL> UPDATE new_emp
2> SET salary = salary * 1.1;
8. Drop the NEW_USERS tablespace and associated datafiles in preparation for later
practices.
SQL > DROP TABLESPACE new_users
2 > INCLUDING CONTENTS AND DATAFILES;
U01.us.oracle.com =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = stc-
sun02.us.oracle.com)(PORT = 17DD))
...
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = stc-sun02)(PORT =
1701))
)
CONNECT_DATA = {Replace the left parenthesis: (CONNECT_DATA }
(SERVICE_NAME = U01.us.oracle.com)
...
U01.us.oracle.com =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = )(HOST = stc-sun02)(PORT = 1701))
Should be: (PROTOCOL = TCP)
...
U01.us.oracle.com =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = )(HOST = stc-sun02)(PORT = 1701))
)
(CONNECT_DATA =
# (SERVVICE_NAME = U01.us.oracle.com)
...
NAMES.DEFAULT_DOMAIN = us.oracle.com
NAMES.DIRECTORY_PATH= (NAMES)
Should be (TNAMAMES)
...
LISTENER01=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = stc-sun02)(PRT = 1701))
Should be (PORT =
...
SID_LIST_LISENER01 =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = U01.us.oracle.com)
...
LISTENERX=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = stc-sun02)(PORT = 1701))
)
In either case, the easiest way is to drop the entire tablespace that contains the data file. The
steps to be executed from within SQL*DBA are:
1. STARTUP MOUNT
2. For each deleted data file, issue the command
ALTER DATABASE DATAFILE ’full path of filename’ OFFLINE
[DROP];
Note: You must use the DROP option if the database is in NOARCHIVELOG mode,
because you cannot recover this file if you apply incomplete media recovery on it via
the command ALTER DATABASE OPEN RESETLOGS. See the SQL Reference
Manual for details.
3. ALTER DATABASE OPEN;
4. DROP TABLESPACE <tablespace> INCLUDING CONTENTS [CASCADE
CONSTRAINTS];