zoukankan      html  css  js  c++  java
  • 数据库建用户脚本install.sh


    --创建oracle用户和表空间, 仅首次安装系统时需要执行.
    --若之前已创建同名的表空间或用户, 则对应脚本会被忽略.
    declare
    ---------------------------------------------------------------
    -- 以下配置请根据实际部署情况手工修改
    ---------------------------------------------------------------
    --用户名
    v_username varchar2(1000) := 'test';
    --密码
    v_password varchar2(1000) := '1';
    --数据文件目录, 这个目录在ORACLE服务器, 需要和DBA确认.
    v_datafile_path varchar2(1000) := '/home/oracle/app/oradata/orcl';

    --存放数据泵备份文件的目录, 这个目录在ORACLE服务器, 需要和DBA确认. 对应linux系统的目录需要手工创建?
    --v_directory_path varchar2(1000) := '/home/oracle/product/admin/ora11g/dpdump';
    ---------------------------------------------------------------
    -- 以下信息请勿修改
    ---------------------------------------------------------------
    v_count number;
    v_dir_name varchar2(1000); --目录名称
    v_ts_name varchar2(1000); --当前库表空间
    begin
    v_username := LOWER(v_username);
    v_dir_name := LOWER('fmdmp_' || v_username);
    v_ts_name := LOWER(v_username);

        --创建数据备份与恢复目录
        select count(1) into v_count from dba_directories a where a.directory_name = UPPER(v_dir_name);
        if v_count = 0 then
         execute immediate 'create directory ' || v_dir_name || ' as ''' || v_directory_path || '/' || v_username || '''';
        end if;

        --创建当前库表空间
        select count(*) into v_count from dba_tablespaces a where a.tablespace_name = UPPER(v_ts_name);
        if (v_count = 0) then
            execute immediate 'create tablespace '
    || v_ts_name || ' logging datafile ''' || v_datafile_path || '/' || v_ts_name || '.dbf'' size 512M'
    || ' autoextend on next 512M'
    || ' extent management local'
    || ' segment space management auto';
        end if;
        
        --创建当前库用户
        select count(*) into v_count from dba_users a where a.username = UPPER(v_username);
        if (v_count = 0) then
            execute immediate 'create user ' || v_username || ' identified by ' || v_password || ' default tablespace ' || v_ts_name || ' temporary tablespace TEMP';
        end if;
    execute immediate 'grant connect, resource, dba, unlimited tablespace, create any table, select any table, grant any object privilege, create any synonym, drop any synonym to ' || v_username;
    execute immediate 'grant execute on utl_file to ' || v_username;
    --授权目录给当前库用户
        execute immediate 'grant read,write on directory ' || v_dir_name || ' to ' || v_username;
        
        --授权查询dba_directories给当前用户
        execute immediate 'grant select on sys.DBA_DIRECTORIES to ' || v_username;
    end;
    /

  • 相关阅读:
    (15)如何使用Cocos2d-x 3.0制作基于tilemap的游戏:第三部分(完)
    (14)如何使用Cocos2d-x 3.0制作基于tilemap的游戏:第二部分
    (13)如何使用Cocos2d-x 3.0制作基于tilemap的游戏:第一部分
    (12)瓦片地图
    (11)粒子系统
    (10)场景转换(Transitions)
    (9)SpriteFrameCache和TextureCache
    LeetCode:数组中的第K个最大元素【215】
    LeetCode:累加数【306】
    LeetCode:组合总数III【216】
  • 原文地址:https://www.cnblogs.com/skiing886/p/7616340.html
Copyright © 2011-2022 走看看