12c 初探--連線,啟動/關閉,建立使用者,資料字典等
Environment:
Windows 7 64, Virtualbox :
Oracle Linux 6.4 64bit ---Unbreakable enterprise kernel
Oracle 12.1
This article covers:
1. Connecting to the root database.
2. Getting containers information in the system.
3. Switch between different containers.
4. Opening a PDB
5. Data dictionaries in the root and PDB.
6. Creating and granting privilege to a common user.
7. Renaming and dropping a PDB.
Connecting using OS authentication
Login linux as oracle, start Oracle listener, login oracle using sqlplus using OS authentication, and start the Oracle instance;
lsnrctl start.
sqlplus "/as sysdba"
startup
SQL> show con_name
CON_NAME
----------------------------------------------------
CDB$ROOT
Con_name is the current container name. In 12c multitenant,a container could be the prebuilt root database or a pluggable database which is created by user.
The root(cdb$root) is the parent of all pdbs, no pdb is the child of any other pdb. Every PDB is owned by SYS, which is a common user in the CDB, regardless of which user created the PDB.
Con_id of cdb$root(AKA: the root) is 1.
Question: how many containers in the system ?
Answer: Login the root and query v$containers.
select con_id, name, open_mode from v$containers;
CON_ID NAME OPEN_MODE
---------------- ---------------- --------------------------------------------
1 CDB$ROOT READ WRITE
2 PDB$SEED READ ONLY
3 PDBORCL MOUNTED
The PDB$SEED is a template for user to create its own pdb, pdb$seed is ALWAYS mounted in read only mode.
Pdborcl is created during the installation. By default, pdb(s) are mounted but not open for users when oracle instance starts. You have to manually put pdb(s) in open mode.
Question: how to change current container:
Answer:
alter session set container = PDBORCL;
Session altered.
SQL> show con_name;
CON_NAME
------------------------------
PDBORCL
Question: how to put the pdb in open mode:
alter pluggable database pdborcl open;
alter pluggable database all open;
Or, put all pdbs in open mode immediately after the instance startup.
create or replace trigger Sys.After_Startup after startup on database
begin
execute immediate 'alter pluggable database all open';
end;
Data dictionaries in the root and PDB
select con_id, name, open_mode from v$containers;
CON_ID NAME OPEN_MODE
---------- ------------------------------ ----------
3 PDBORCL MOUNTED
Remember when logged in as sys to the root, v$container shows us information of all containers. Now, we're constrained to the current container. The same rule applies to all v$xxx, cdb_xxx.
This makes sense, because pdb users shold not have access to other pdb data unless he's authorized to. Let's examine the cdb_xxx and dba_xxx.
When you're connected to CDB$ROOT, there's a big different in what you can see in the dba_xxx and cdb_xxx. dba_xxx gives you information of cdb$root, while cdb_xxx the whole picture of all containers.
SQL> show con_name;
CON_NAME
------------------------------
CDB$ROOT
SQL> select count(*), con_id from cdb_tablespaces group by con_id;
COUNT(*) CON_ID
---------- ----------
3 2
5 3
5 1
SQL> select count(*) from dba_tablespaces;
COUNT(*)
----------
5
When you are connected to a PDB, the CDB_xxx or DBA_xxx views show the same information.
Question : how to create a common user and grant privilege to it?
Answer:
SQL> create user c##1 identified by c##1 container=all;
User created.
SQL> grant dba to c##1 container=all;
Grant succeeded.
SQL> connect c##1/c##1@pdborcl;
Connected.
Without the container clause, the creation and granting only applies to the current container -- the root. You're not able to create a common user in the PDB.
Alter user c##1 quota unlimited on users.
It's a new privilege in 12c required to write to tablespaces.
Question: how to rename a PDB?
Answer:
To rename a pdb, login as sysdba to pdb, put it in "open restricted" mode and run alter database command; finally close and open it.
sqlplus system/123456@pdborcl;
alter pluggable database pdborcl close immediate;
alter pluggable database pdborcl open restricted;
alter pluggable database pdborcl rename global_name to pdb3_bis;
alter pluggable database pdborcl close immediate;
alter pluggable database pdborcl open;
Question: how to drop a PDB:
Answer:
drop pluggable database pdborcl including datafiles;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/638844/viewspace-768316/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- mysql階段04 連線工具, 連線方式, 啟動關閉mysqlMySql
- WebSocket:從建立連線到關閉的完整流程Web
- spring boot 不連線資料庫啟動Spring Boot資料庫
- db2資料庫的啟動和關閉DB2資料庫
- openguass 3.1.0 資料庫啟動,關閉,狀態檢查資料庫
- 網路 保證在關閉連線前, 把資料發出去
- 網路學習筆記(一):TCP連線的建立與關閉筆記TCP
- 使用screen讓關閉ssh連線時不關閉程式
- oracle資料庫的啟動關閉與各種服務Oracle資料庫
- 3 啟動和關閉
- Centos7 資料庫啟動使用者的建立方法CentOS資料庫
- 怎麼建立網站連線資料庫網站資料庫
- win10系統快速啟動怎麼關閉 關閉Windows快速啟動Win10Windows
- 日常Bug排查-連線突然全部關閉
- 9. 啟動、關閉tomcatTomcat
- 啟動與關閉服務
- 01啟動(關閉)套接字
- centos下nginx啟動、重啟、關閉CentOSNginx
- win10快速啟動怎麼關閉_win10如何關閉快速啟動Win10
- SpringBoot druid配置datasource啟動初始化資料庫連線Spring BootUI資料庫
- [20181031]12c 線上移動資料檔案.txt
- Oracle 12c 關閉歸檔模式Oracle模式
- MySQL 線上開啟&關閉GTID模式MySql模式
- windows10怎麼關閉快速啟動_windows10關閉快速啟動的方法Windows
- TCP 的連線建立與關閉狀態及資料傳輸通訊過程【含有 PHP 測試實驗程式碼】TCPPHP
- 直播系統開發,pymssql連線資料庫 並設定資料格式為字典SQL資料庫
- 12C關於CDB、PDB線上移動資料檔案、線上重新命名資料檔案的操作說明
- express入門04 資料庫連線 表結構建立 模型建立Express資料庫模型
- 達夢資料庫關於[-70028]:建立SOCKET連線失敗的錯誤原因資料庫
- win10 自動重啟關閉方法_win10自動重啟怎麼關閉Win10
- 如何關閉win10快速啟動_win10系統快速啟動怎麼關閉Win10
- linux下mysql安裝、授權、建立使用者、連線navicat、連線entityLinuxMySql
- 用c#建立與資料庫的連線 c#連sqlserverC#資料庫SQLServer
- SQLAlchemy - 資料庫的連線、建立會話與模型SQL資料庫會話模型
- Oracle相關資料字典檢視Oracle
- Ubuntu網站開啟時提示建立資料庫連線錯誤怎麼解決Ubuntu網站資料庫
- lavavel 自動生成資料字典
- nginx關閉/重啟/啟動的操作方法Nginx
- 解讀MySQL 8.0資料字典的初始化與啟動MySql