1. 程式人生 > >shell oracle 建立使用者指令碼

shell oracle 建立使用者指令碼

#!/bin/sh
echo -n "key q is exit:"
read keyExit
if [ "$keyExit" == "q" ]; then
        exit 0
fi


echo -n "Please Input Oracle System Passwrod:"
read Password
echo "system passwrod is  $Password"


echo -n "Please Input crate Oracle UserName:"
read UserName
echo "crate Oracle username is $UserName"


echo -n "Please Input Oracle SID:"
read SID
echo "Oracle SID is $SID"




table_space=$UserName"_data"
echo "Create tablespaceName is:  $table_space"


data_file="/u01/oracle/oradata/$SID/$UserName""_01.dbf"
echo "Create datafile is: $data_file"


su - oracle <<!


ORACLE_SID=$SID
export ORACLE_SID


sqlplus /nolog <<EOF


conn system/$Password


spool createuser.log 


    create tablespace $table_space
    logging
    datafile '$data_file'
    size 32M
    autoextend on
    next 32m maxsize 2048m
    extent management local;


    create user $UserName identified by $UserName
    default tablespace $table_space
    temporary tablespace user_temp;


    grant connect,resource to $UserName;
 
spool off 
EOF
exit