Create pdb and table space in oracle of linux contos7

Preparation: Open the database

  1. Switch to the oracle user and prepare to start
  2.          su oracle
  3. --Run the oracle configuration file
  4.        source /home/oracle/.bash_profile
  5. --Start the listening service
  6.        lsnrctl start
  7. --Run the sqlplus command
  8.        sqlplus /nolog
  9. -- Login as administrator
  10.        conn / as sysdba
  11. --Start the database
  12.        Startup

view connection

SQL> show con_name

CON_NAME
------------------------------
CDB$ROOT
1. The premise of creation is to enable cdb, so check it below

 select name,cdb from v$database;

NAME      CDB
--------- ---
ORCL      YES

2: Specify the directory to create pdb. The directory is the installation directory of oracle
alter system set db_create_file_dest='/home/oracle/app/oracle/oradata';
 
3: The name of the tablespace used to create pdb is test
create tablespace test datafile '/home/oracle/app/oracle/oradata/orcl/test.dbf' size 2G autoextend on next 1G maxsize unlimited extent management local autoallocate; 
 
4: Create pdb and specify the default tablespace, the default is the system tablespace, it is better to create a pdb dedicated tablespace for management create pluggable database test admin user test identified by test roles=(dba) default tablespace test; 5: Check whether the creation is successful show pdbs --------Observation information-----MOUNTED means CON_ID CON_NAME is not open OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ----------
2
 
PDB
 $
 SEED
    READ
ONLY
     NO
     3 ORCLPDB              READ WRITE NO
     4 TEST                       MOUNTED

6: Directly open the database test
alter pluggable database test open;
  
6: Switch to a pdb such as test
alter session set container=test


7: Start pdb
startup

8:用户授权
GRANT DBA to test;
grant connect,resource,unlimited tablespace to test;
grant create any directory to test;
grant drop any directory to test;

 

-------------------------Another way------Create multiple spaces---------------------

1 create pdb 

create pluggable database pdbgeo admin user pdbuser identified by pass1234 roles=(dba);
 

2. Open pdb

alter pluggable database pdbgeo open
 

3: Switch to a certain pdb, such as pdbgeo
alter session set container=PDBGEO
 

-----------CREATE TABLESPACE----------------------

1: Create a connectable user
Create a user tablespace, the red part is your own directory, the end of dbf create tablespace ggsj datafile 

create tablespace ggsj datafile '/home/oracle/app/oracle/oradata/orcl/20/ggsj.dbf' size 2G autoextend on next 1G maxsize unlimited extent management local autoallocate

2 Create user-specified default tablespace
create user XSDTGGSJ identified by XSDTGGSJ default tablespace ggsj;
empower gei user
grant dba,connect,resource,create session,create table,create view,unlimited tablespace to XSDTGGSJ;
grant create any directory,drop any directory to XSDTGGSJ ;

------repeat-------------------------------

1

create tablespace wdsj datafile '/home/oracle/app/oracle/oradata/orcl/20/wdsj.dbf' size 2G autoextend on next 1G maxsize unlimited extent management local autoallocate

2 Create user-specified default tablespace
create user XSDTWDSJ identified by XSDTWDSJ default tablespace wdsj
empower gei user
grant dba,connect,resource,create session,create table,create view,unlimited tablespace to XSDTWDSJ;
grant create any directory,drop any directory to XSDTWDSJ;

------repeat-------------------------------

1

create tablespace xxsj datafile '/home/oracle/app/oracle/oradata/orcl/20/xxsj.dbf' size 2G autoextend on next 1G maxsize unlimited extent management local autoallocate

2 Create user-specified default tablespace
create user XSDTXXSJ identified by XSDTXXSJ default tablespace xxsj
empower gei user
grant dba,connect,resource,create session,create table,create view,unlimited tablespace to XSDTXXSJ;
grant create any directory,drop any directory to XSDTXXSJ;

 

 

 

 

 

 

 

 

3, 10: Use the tests user to connect remotely in qlsql.
11: Use sqlplus to connect
 sqlplus tests/tests@yourIP/test
 
 
#Change password (optional)
alter user ADMIN identified by "xag123";
#Unlock command after account is locked (optional) sys or system
alter user ADMIN account unlock;
#Set user password unlimited times to try to log in
alter profile default limit failed_login_attempts unlimited;
#Set user password No expiration:
alter profile default limit password_life_time unlimited;
#View configuration parameters
select profile,RESOURCE_NAME,resource_type,limit from dba_profiles where 
RESOURCE_NAME in('FAILED_LOGIN_ATTEMPTS','PASSWORD_LIFE_TIME') and profile='DEFAULT'; Uninstall   pdb; 1: Close pdb ;
 
 
alter pluggable database test close immediate; 2: Uninstall pdb


 
 

Use keep datafiles to preserve PDB8 data files. , You can also use including datafiles to completely delete the PDB data files.
drop pluggable database test including datafiles;

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin blog.csdn.net/qq_43289307/article/details/116752506