博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[Oracle] - Create DB on Oracle 12c for an Application
阅读量:6883 次
发布时间:2019-06-27

本文共 2693 字,大约阅读时间需要 8 分钟。

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:

  • 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/oracle@pdbwbbankcreate 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/oracle@pdbwbbank-- 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/oracle@pdbwbbankselect * 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.

转载地址:http://dfnbl.baihongyu.com/

你可能感兴趣的文章
tar命令的详解
查看>>
1.3 函数调用反汇编解析以及调用惯例案例分析
查看>>
谈谈JAVA工程狮面试中经常遇到的面试题目------什么是MVC设计模式
查看>>
【转】Android Service完全解析,关于服务你所需知道的一切(下) ---- 不错
查看>>
[STL][C++]LIST
查看>>
SQL2005:使用varchar(max)代替text
查看>>
[Git] Git 常用技巧
查看>>
单向链表的逆序操作
查看>>
kNN(K-Nearest Neighbor)最近的分类规则
查看>>
试玩GitHub
查看>>
(十九)WebGIS中I查询的原理及设计(包含AGS、GeoServer、Supermap)
查看>>
SELECT CAST(GETDATE() AS VARCHAR(10)) 显示不同格式的原因
查看>>
akka cluster 初体验
查看>>
HDoj-2524 - 矩形A+B
查看>>
bootstrap模态框和select2合用时input无法获取焦点
查看>>
Asp.net MVC Request Life Cycle
查看>>
Android应用程序模拟手机按键
查看>>
变革之心——读后感
查看>>
CMake 教程
查看>>
Linux编辑器vi使用方法详细介绍
查看>>