oracle pdb基本管理

1.创建PDB

sqlplus /nolog
conn / as sysdba

CREATE PLUGGABLE DATABASE pdb1 ADMIN USER pdb1_admin IDENTIFIED BY ora123 ROLES=(DBA)
	DEFAULT TABLESPACE USERS DATAFILE '/u01/app/oracle/oradata/orcl/pdb1/users01.dbf' SIZE 100M AUTOEXTEND ON NEXT 100M LOGGING
	FILE_NAME_CONVERT=('/u01/app/oracle/oradata/orcl/pdbseed/sysaux01.dbf','/u01/app/oracle/oradata/orcl/pdb1/sysaux01.dbf',
		'/u01/app/oracle/oradata/orcl/pdbseed/system01.dbf','/u01/app/oracle/oradata/orcl/pdb1/system01.dbf',
		'/u01/app/oracle/oradata/orcl/pdbseed/undotbs01.dbf','/u01/app/oracle/oradata/orcl/pdb1/undotbs01.dbf',
		'/u01/app/oracle/oradata/orcl/pdbseed/temp012018-01-17_12-29-25-103-PM.dbf','/u01/app/oracle/oradata/orcl/pdb1/temp01.dbf');

ALTER PLUGGABLE DATABASE pdb1 OPEN;

exit;

2.在$ORACLE_HOME/Network/admin/tnsnamses.ora中增加:

pdb1 =  
  (DESCRIPTION =  
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))  
    (CONNECT_DATA =  
      (SERVER = DEDICATED)  
      (SERVICE_NAME = pdb1)  
    )  
  ) 

完成编辑后,重启oracle监听

3.使用pdb1_admin连接pdb1:sqlplus pdb1_admin/ora123@localhost/pdb1

执行:

CREATE TABLESPACE demo_data LOGGING DATAFILE '/u02/dbfile/pdb1/demo_data01.dbf' SIZE 1G AUTOEXTEND ON NEXT 1G;
CREATE TEMPORARY TABLESPACE demo_temp TEMPFILE '/u02/dbfile/pdb1/demo_temp01.dbf' SIZE 5M AUTOEXTEND ON NEXT 1M;
CREATE USER demo IDENTIFIED BY ora123 DEFAULT TABLESPACE demo_data TEMPORARY TABLESPACE demo_temp; 
GRANT connect,resource TO demo;   

4.常用SQL

ALTER PLUGGABLE DATABASE pdb1 OPEN;
ALTER PLUGGABLE DATABASE pdb1 CLOSE  IMMEDIATE;
DROP PLUGGABLE DATABASE pdb1 INCLUDING DATAFILES;

show pdbs;        
show con_name;    
ALTER SESSION SET CONTAINER = pdb1;

SELECT tablespace_name FROM dba_tablespaces;
SELECT name FROM v$datafile;
SELECT name FROM v$tempfile;
posted @ 2018-01-23 15:58  javaite  阅读(680)  评论(0编辑  收藏  举报