[Oracle] - Create DB on Oracle 12c for an Application

來源:互聯網
上載者:User

標籤:oracle   oracle12c   pdb   synonym   create db   

<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">Let's say we are going to develop a application for a bank, or any other enterprise, this application need a DB. And we decide to choose Oracle 12c. Then we make a plan:</span>

  • Application is for WBBANK, so name is WBBANK
  • Application DB is running in a individual PDB
  • Application DB has its own tablespace
  • There are two users for this DB, one is to administrate objects of the DB (schema), which is used by DBA and other one is to operate the data, which is used by application

Following is details:

1. Create PDB and its DBA user
sqlplus sys as sysdbaCREATE PLUGGABLE DATABASE PDBWBBANK  ADMIN USER wbbank_dba IDENTIFIED BY oracle  ROLES = (dba)  DEFAULT TABLESPACE WBBANK_DEFAULT    DATAFILE '/u01/app/oracle/oradata/orcl/pdbs/pdbwbbank/wbbank_default.dbf' SIZE 100M AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED   STORAGE (MAXSIZE 2G MAX_SHARED_TEMP_SIZE 100M)  PATH_PREFIX = '/u01/app/oracle/oradata/orcl/pdbs/pdbwbbank/'  FILE_NAME_CONVERT = ('/u01/app/oracle/oradata/orcl/pdbseed/','/u01/app/oracle/oradata/orcl/pdbs/pdbwbbank/');

2. Open PDB
alter pluggable database pdbwbbank open;

Now you can remote access this pdb with service name, pdbwbbank.

3. Create tablespace

conn wbbank_dba/[email protected]create tablespace WBBANK datafile '/u01/app/oracle/oradata/orcl/pdbs/pdbwbbank/wbbank01.dbf' size 100M autoextend on next 10M MAXSIZE UNLIMITED;


4. Create admin user and app user

create user wbbank_owner identified by oracle default tablespace WBBANK quota unlimited on WBBANK;grant connect to wbbank_owner;grant resource to wbbank_owner;create user wbbank_user identified by oracle default tablespace WBBANK quota unlimited on WBBANK;create role wbbank_user_role;grant create session to wbbank_user_role;grant wbbank_user_role to wbbank_user;

5. Test
conn wbbank_dba/[email protected]-- Create table users in schema wbbank_ownerCREATE TABLE wbbank_owner.users( id number(10) NOT NULL,  username varchar2(50) NOT NULL UNIQUE,  password varchar2(50) NOT NULL,  create_date TIMESTAMP DEFAULT SYSDATE,  CONSTRAINT users_pk PRIMARY KEY (id));--Must grant access privileges to wbbank_user or wbbank_user_role, otherwise synonym is uselessgrant all privileges on wbbank_owner.users to wbbank_user_role;--Create private synonym in schema wbbank_usercreate synonym wbbank_user.users for wbbank_owner.users;

Try
conn wbbank_user/[email protected]select * from users;

Remarks
  • wbbank_owner is to manage objects, all objects are created under wbbank_owner. It has RESOURCE role. Please note RESOURCE role doesn‘t have synonym creation role.
  • wbbank_user is only to operate data through synonyms.
  • wbbank_dba create synonym and grant privileges to data operator, wbbank_user. It has DBA role, it‘s DBA of this PDB.

著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

[Oracle] - Create DB on Oracle 12c for an Application

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.