Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Table of Contents
Reviews of this document ............................................................................................................... 1
Previous tasks to perform before start practicing with Oracle Spatial Training material .................. 2
1.
2.
Creating an after startup trigger (Only if you have a Multi-Tenant Container DB)* .............. 2
Steps ............................................................................................................................................ 3
3.
Create the Oracle database users and grant appropriate privileges. Mandatory .................. 5
6.
7.
Author
MTI Francisco Javier Rojas Durn
Date
April 2nd 2016
ORACLE_HOSTNAME=db.oracledemo.com
ORACLE_UNQNAME=cdborcl
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=$ORACLE_BASE/product/12.1.0.2/db_1
ORACLE_SID=cdborcl
export PATH=/usr/sbin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
stty erase ^H
2. Creating an after startup trigger (Only if you have a Multi-Tenant Container DB)*
In a CDB environment, the default behavior when a CDB is started is that all user-defined PDBs are
in MOUNTED state i.e. closed. The only way to change this behavior is by using an AFTER STARTUP
trigger on the database.
In this exercise, you will create AFTER STARTUP trigger to open all PDBs of a CDB. The AFTER
MTI FRANCISCO JAVIER ROJAS DURN
STARTUP trigger is a database event trigger, which means that the user creating the trigger should
have ADMINISTER DATABASE TRIGGER system privilege. The trigger will only fire after the startup
event on the database.
Steps
1. Connect to the Root container of CDBORCL as a SYSDBA user.
. oraenv
[Enter cdborcl at the prompt]
sqlplus / as SYSDBA
5. Create the Oracle database users and grant appropriate privileges. Mandatory
Assuming you are still logged in as system/Manager1 either in the Non-container single-instance
or into the Pluggable DB (PDBORCL)
In Single-Tenant Container instance:
ALTER SESSION SET CONTAINER=PDBORCL;
Be sure your current container is PDBORCL and also it is open:
SHOW CON_ID;
SHOW CON_NAME;
ALTER PLUGGABLE DATABASE OPEN;
Execute the following:
$sqlplus student/student@//[HOSTNAME|IP]:1521/pdborcl
This is the expected output:
Do not use this default PDB service for applications. Always use user-defined services for
applications because you can customize user-defined services to fit the requirements of your
applications.
MTI FRANCISCO JAVIER ROJAS DURN
You can create, modify, or remove a service with a PDB property in the following ways:
If the database is not being managed by Oracle Restart or Oracle Clusterware, then use
the DBMS_SERVICE package to create or remove a database service. This is the
method you will follow in this task.
Note: Each database service name must be unique in a CDB, and each database service
name must be unique within the scope of all the CDBs whose instances are reached through a
specific listener.
Steps
1. When you create a service using the DBMS_SERVICE package, the PDB property of the new
service is set to the current container. Therefore, login to the PDB that you want to
create/modify/delete the user-defined services before running the DBMS_SERVICE procedures.
If you run DBMS_SERVICE.CREATE_SERVICE in the root container then the service is associated
with the root.
Connect as SYS to PDBORCL with the SYSDBA role.
CONNECT SYS/Manager1@//127.0.0.1:1521/PDBORCL AS
SYSDBA;
SELECT CON_ID, NAME, OPEN_MODE FROM V$PDBS;
2. Create the service by the name PORCL using the DBMS_SERVICE.CREATE_SERVICE procedure.
EXEC DBMS_SERVICE.CREATE_SERVICE (SERVICE_NAME=>'PORCL',
NETWORK_NAME=>'PORCL');
5. Reconnect to PDBORCL using the PORCL service. Verify that you are reconnected back to
PDB PDBORCL.
CONNECT SYS/oracle@//127.0.0.1:1521/PORCL AS SYSDBA;
SELECT CON_ID, NAME, OPEN_MODE FROM V$PDBS;
sqlplus student/student@//127.0.0.1:1521/PORCL;
Once he have configured the SERVICE , we must configure clients to use this SERVICE.
In our VM we must run NETCA in order to create a SERVICE entry within TNSNAMES.ORA
In a terminal window logged with the user oracle , run the command NETCA.
1
0
1
1
1
2
1
3
1
4
1
5
1
6
Now we should close NETCA window, and connect from SQLPLUS with the user student as shown
below:
From now we can connect to PDBORCL as if we were using a Pre-12c Non-Container DB.
1
7