zoukankan      html  css  js  c++  java
  • [Oracle]

    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 sysdba
    
    CREATE 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@pdbwbbank
    
    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/oracle@pdbwbbank
    
    -- Create table users in schema wbbank_owner
    CREATE 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 useless
    grant all privileges on wbbank_owner.users to wbbank_user_role;
    
    --Create private synonym in schema wbbank_user
    create synonym wbbank_user.users for wbbank_owner.users;

    Try
    conn wbbank_user/oracle@pdbwbbank
    
    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.

  • 相关阅读:
    【STM32 .Net MF开发板学习02】GPIO测试
    【STM32 .Net MF开发板学习01】Hello world
    【STM32 .Net MF开发板学习04】TinyGUI位图显示
    【STM32 .Net MF开发板学习03】TinyGUI绘图示例
    【STM32 .Net MF开发板学习06】蜂鸣器和LED数码管显示
    免费发放firmwave,打造史上最低价.Net MF开发板
    Windows Media Center携手新浪、搜狐推出互联网视频
    【STM32 .Net MF开发板学习07】全屏位图无闪烁显示
    第二部分 Mongodb增删改查 简单
    第二部分 Mongodb固定集合与性能 简单
  • 原文地址:https://www.cnblogs.com/blfbuaa/p/6758696.html
Copyright © 2011-2022 走看看