数据库建用户脚本install.sh
Posted 独立特行
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了数据库建用户脚本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;
/
以上是关于数据库建用户脚本install.sh的主要内容,如果未能解决你的问题,请参考以下文章
执行脚本sh install.sh后:需要输入1等待5秒并回车,等待10秒输入y并回车 ,如何用脚本完成这两个操作。
创建?键安装和卸载httpd-2.4.25.tar.gz 的脚本install_httpd.sh,要求安装?/app/httpd24?录 下,运? httpd.sh install 实现安装,运? h