oracle

Oracle 12c PDB基础

2017-02-20  本文已影响0人  biohyper

查看pdb开启状态

select con_id, dbid, guid, name , open_mode from v$pdbs;

建立连接

进入cdb

sqlplus /nolog
conn sys/sys as dba
sqlplus sys/sys@localhost:1521/orcl as sysdba

进入pdb(pdb可以通过alter session container进入也可以直接通过tns方式(如下)登录)
sqlplus sys/sys@localhost:1521/pdborcl as sysdba

显示所有的plaggable db

show pdbs;

查看当前连接名称

show con_name;

新建pdb

CREATE PLUGGABLE DATABASE xff_db ADMIN USER xff IDENTIFIED BY xifenfei
STORAGE (MAXSIZE 2G MAX_SHARED_TEMP_SIZE 100M)
DEFAULT TABLESPACE xifenfei
DATAFILE '/u01/app/oracle/oradata/xifenfei/xff/xifenfei01.dbf' SIZE 25M AUTOEXTEND ON  5  PATH_PREFIX = '/u01/app/oracle/oradata/xifenfei/xff/'
FILE_NAME_CONVERT = ('/u01/app/oracle/oradata/xifenfei/pdbseed/', 
'/u01/app/oracle/oradata/xifenfei/xff/');
#### 删除PDB
DROP PLUGGABLE DATABASE xff_db INCLUDING DATAFILES;

Unplugging PDB

alter pluggable database FF close immediate;
alter pluggable database ff UNPLUG into '/tmp/ff.xml';

Plug Unplugging PDB

create pluggable database ff using '/tmp/ff.xml' copy file_name_convert=('/u01/app/oracle/oradata/xifenfei/FF/','/u01/app/oracle/oradata/xff_l/xff');
exec DBMS_PDB.SYNC_PDB();

启动关闭PDB

打开单个pdb

lter pluggable database pdborcl open;

打开所有pdb

alter pluggable database all open;

关闭所有pdb

alter pluggable database all close immediate;

进入pdb

alter session set container=pdborcl;
--//
conn sys/sys@localhost:1521/pdborcl as sysdba;

进入cdb

alter session set container=cdb$root;
--//
conn / as sysdba;

创建用户

创建全局用户

create user c##xff identified by xifenfei;

创建本地用户

alter session set container=pdborcl;
create user xxx identified by 123;

用户授权

grant connect to c##xff;
grant resource to c##xff container=all

修改参数

alter system set open_cursors=500 container=all;
show parameter open_cursors;
alter session set container=pdborcl;
show parameter open_cursors;
--//
alter system set open_cursors=100;
show parameter open_cursors;
conn / as sysdba
show parameter open_cursors;

使用触发器实现PDB自动启动

--先连接  
conn / as sysdba  
  
--创建触发器  
CREATE OR REPLACE TRIGGER open_pdbs  
AFTER STARTUP ON DATABASE  
BEGIN  
EXECUTE IMMEDIATE 'ALTER PLUGGABLE DATABASE ALL OPEN';  
END open_pdbs;
\   --sqlplus中结束脚本编写
上一篇下一篇

猜你喜欢

热点阅读