初始化Oracle用户以及表空间的bash shell脚本

holyrong 2013-06-26

Linux脚本很久没有写了,突然有需求写一个初始化Oracle用户以及表空间的bash shell脚本。

做一个记录,以备以后查询

调用方式: ./user.sh oracle /u01/app/oracle/data_01.dbf /u01/app/oracle/index_01.dbf

内容如下: 

#!/bin/bash
# ./user.sh oracle /u01/app/oracle/data_01.dbf /u01/app/oracle/index_01.dbf
sqlplus -s system/$1 <<EOF
CREATE TABLESPACE data_01
    LOGGING
    DATAFILE '$2' SIZE 5M
    AUTOEXTEND  ON NEXT  20000K MAXSIZE  20000M EXTENT MANAGEMENT LOCAL
    SEGMENT SPACE MANAGEMENT  AUTO ;

CREATE TABLESPACE index_01
    LOGGING
    DATAFILE '$3' SIZE 5M
    AUTOEXTEND  ON NEXT  20000K MAXSIZE  20000M EXTENT MANAGEMENT LOCAL
    SEGMENT SPACE MANAGEMENT  AUTO ;

CREATE USER db_hyjzw  PROFILE "DEFAULT"
    IDENTIFIED BY db_hyjzw DEFAULT TABLESPACE data_01
    QUOTA UNLIMITED
    ON data_01
    ACCOUNT UNLOCK;
GRANT "CONNECT" TO db_hyjzw  ;
GRANT "DBA" TO db_hyjzw;
ALTER USER db_hyjzw quota unlimited  ON index_01;
exit
EOF

相关推荐