Oracle 12c creates pluggable database (PDB) and users
Because oracle 12c uses the CDB-PDB architecture, similar to docker, multiple pluggable-db can be loaded within container-db, so additional configuration is required after installation.
1. Modify listener.ora and tnsnames.ora
# listener.ora###
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = localhost) (PORT = 1521))
(CONNECT_DATA = (SERVICE_NAME = orcl))
)
# sid list lists the database names of cdb and all pdb, and all sid are consistent with oracle environment variables #
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orcl) # cdb db_name
(SID_NAME = orcl)
)
(SID_DESC =
(GLOBAL_DBNAME = pdborcl) # pdb db_name
(SID_NAME = orcl)
)
)
# listener.ora###
# # tnsnames.ora###
# cdb
Orcl =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP) (HOST = localhost) (PORT = 1521))
(CONNECT_DATA =
(SERVICE_NAME = orcl) # db_name of cdb
)
)
# pdb
Pdborcl =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP) (HOST = localhost) (PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = pdborcl) # db_name of pdb
)
)
# # tnsnames.ora###
Use the "service_name+domain_name" connection when the client connects. If there is an ora-01017, it is most likely
Second, create a pdb
Cdb is equivalent to the operating system, calling and managing each pdb. Pdb is the equivalent of a database instance that actually provides business requirements. After oracle 12c is installed, only cdb is created, and you need to generate the corresponding pdb yourself.
1. Create a pdb
Under sqlplus:
Create pluggable database pdborcl
Admin user pdbadmin identified by pdbadmin
Role= (resource)
File_name_convert= ('PDB$SEED's directory',' PDBOrcl's directory')
2. Synchronize files
Select pdb_name,status from cdb_pdbs
If the pdb status is need sync, you need to:
Alter sesseion set container=pdborcl
Shutdown immediate or alter pluggable database pdborcl close immediate
Alter pluggable database pdborcl open restricted
Exec dbms_pdb.sync_pdb; # call dbms_pdb for pdb
3. Add new users
Create user scott account unlock identified by tiger
Grant resource to scott
If a user is created according to the above method, if an ora-01017 occurs, it is likely that 1, no connected service_name is specified to a specific pdb, or the oracle is case-sensitive. The former checks whether the sid_list in the listener.ora has listed the pdb and checks whether the connection string is specified in the tnsnames.ora. If the latter cannot modify the front-end program, you can use the
Alter system set SEC_CASE_SENSITIVE_LOGON = false
Forces the case check of oracle to be turned off for confirmation.
III. Common commands
Show pdbs: see how many pdb are contained in the current database container. If the session is in a pdb, you can view the current pdb.
Alter session set container=PDBNAME
Switch the current session to a pdb. You can use the private users of the current pdb for operation only after switching.
Startup/shutdown immediate
Close the cdb/pdb where the current session is located
Alter pluggable database PDBNAME open
Opens the specified pdb
Alter pluggable database PDBNAME close immediate
Closes the specified pdb