SlideShare a Scribd company logo
1 of 2
"################Anar Godjaev##############################"
"################This script is useful for when you want to create a user with a
random password##########"
#!/usr/bin/ksh
SID=$1
echo $SID
export ORACLE_SID=${SID}
echo "userid (password will be generated)"
read userid
set -A M 0 1 2 3 4 5 6 7 8 9 
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
L="8"
password=""
while [ $L -gt 0 ]
do
password="$password${M[$(($RANDOM%${#M[*]}+1))]}"
L="$(($L-1))"
done
if [ -z "${userid}" ] || [ -z "${password}" ] ; then
echo "wrong number of items entered. Press to quit."
read nothing
exit
fi
### DOES USER ALREADY EXIST? IF SO, EXIT ###
check_the_user()
{
sqlplus -s <internal
set pages 0 lines 150 head off veri off feed off term off echo off
select count(*) from dba_users where username = upper('${userid}');
END
}
if [[ `check_the_user` -gt 0 ]] ; then
echo "ERROR -- user ${userid} already exists - to exit."
read nothing
exit
fi
echo "userid ${userid}"
echo "newpassword: $password"
if [ -z "${userid}" ] || [ -z "${password}" ] ; then
echo "wrong number of items entered. Press to quit."
read nothing
exit
fi
echo " is this correct (y/n)?"
yesno="n"
read yesno
if [ -z "${yesno}" ] || [ ${yesno} != "Y" ] && [ ${yesno} != "y" ] ; then
exit
fi
sqlplus -s <internal
set pages 0 lines 150 head off veri off feed off term off echo off
create user ${userid}
identified by "$password"
default tablespace anar01
temporary tablespace temp
QUOTA UNLIMITED ON anar01
QUOTA 0 ON SYSTEM ;
GRANT SSE_ROLE TO ${userid} ;
exit
ENDSQL
echo "All done. Press to continue."
read nothing
exit

More Related Content

Viewers also liked

Viewers also liked (16)

Susan Jones. Rebranding of an icon.
Susan Jones. Rebranding of an icon.Susan Jones. Rebranding of an icon.
Susan Jones. Rebranding of an icon.
 
Exposicion copia
Exposicion copiaExposicion copia
Exposicion copia
 
Acta Junta Extra 05/11/15
Acta Junta Extra 05/11/15Acta Junta Extra 05/11/15
Acta Junta Extra 05/11/15
 
Bia 1
Bia 1Bia 1
Bia 1
 
Con sabor a monte
Con sabor a monteCon sabor a monte
Con sabor a monte
 
Бережливое производство и мышление ч.2
Бережливое производство и мышление ч.2Бережливое производство и мышление ч.2
Бережливое производство и мышление ч.2
 
Introduccion a power point
Introduccion a power pointIntroduccion a power point
Introduccion a power point
 
Environment pollution
Environment pollutionEnvironment pollution
Environment pollution
 
Oromo Liberation Front (OLF) major-policies programs
 Oromo Liberation Front  (OLF) major-policies  programs Oromo Liberation Front  (OLF) major-policies  programs
Oromo Liberation Front (OLF) major-policies programs
 
Schedul epresentation
Schedul epresentationSchedul epresentation
Schedul epresentation
 
Zina Kelas X
Zina Kelas X Zina Kelas X
Zina Kelas X
 
(Physical review, vol. 84, 1951) feynman, r.p. an operator calculus having ap...
(Physical review, vol. 84, 1951) feynman, r.p. an operator calculus having ap...(Physical review, vol. 84, 1951) feynman, r.p. an operator calculus having ap...
(Physical review, vol. 84, 1951) feynman, r.p. an operator calculus having ap...
 
4 ta tarea unaldo
4 ta tarea unaldo4 ta tarea unaldo
4 ta tarea unaldo
 
Presentacion grupo2
Presentacion grupo2Presentacion grupo2
Presentacion grupo2
 
Exposicion copia
Exposicion copiaExposicion copia
Exposicion copia
 
Crecimiento de la ciudad
Crecimiento de la ciudadCrecimiento de la ciudad
Crecimiento de la ciudad
 

More from Anar Godjaev

Asm disk group migration from
Asm disk group migration from Asm disk group migration from
Asm disk group migration from Anar Godjaev
 
How to protect your sensitive data using oracle database vault / Creating and...
How to protect your sensitive data using oracle database vault / Creating and...How to protect your sensitive data using oracle database vault / Creating and...
How to protect your sensitive data using oracle database vault / Creating and...Anar Godjaev
 
how to protect your sensitive data using oracle database vault
how to protect your sensitive data using oracle database vaulthow to protect your sensitive data using oracle database vault
how to protect your sensitive data using oracle database vaultAnar Godjaev
 
Database Vault / Verinin Güvenliği
Database Vault /  Verinin GüvenliğiDatabase Vault /  Verinin Güvenliği
Database Vault / Verinin GüvenliğiAnar Godjaev
 
Oracle Golden Gate
Oracle Golden GateOracle Golden Gate
Oracle Golden GateAnar Godjaev
 
Oracle 10g Database Server Kurulum
Oracle 10g Database Server KurulumOracle 10g Database Server Kurulum
Oracle 10g Database Server KurulumAnar Godjaev
 
DataPump ile Single Parititon Export
DataPump ile Single Parititon ExportDataPump ile Single Parititon Export
DataPump ile Single Parititon ExportAnar Godjaev
 
Redologlar ve Yöneti̇mi̇
Redologlar ve Yöneti̇mi̇Redologlar ve Yöneti̇mi̇
Redologlar ve Yöneti̇mi̇Anar Godjaev
 
Veri̇tabani ve Kullanici Yöneti̇mi̇
Veri̇tabani ve Kullanici Yöneti̇mi̇Veri̇tabani ve Kullanici Yöneti̇mi̇
Veri̇tabani ve Kullanici Yöneti̇mi̇Anar Godjaev
 
Instance ve Media Bozukluklarını Inceleme
Instance ve Media Bozukluklarını IncelemeInstance ve Media Bozukluklarını Inceleme
Instance ve Media Bozukluklarını IncelemeAnar Godjaev
 
Conditional Control
Conditional ControlConditional Control
Conditional ControlAnar Godjaev
 
Audit Mekani̇zmasi
Audit Mekani̇zmasiAudit Mekani̇zmasi
Audit Mekani̇zmasiAnar Godjaev
 

More from Anar Godjaev (20)

Oracle GoldenGate
Oracle GoldenGateOracle GoldenGate
Oracle GoldenGate
 
Asm disk group migration from
Asm disk group migration from Asm disk group migration from
Asm disk group migration from
 
How to protect your sensitive data using oracle database vault / Creating and...
How to protect your sensitive data using oracle database vault / Creating and...How to protect your sensitive data using oracle database vault / Creating and...
How to protect your sensitive data using oracle database vault / Creating and...
 
how to protect your sensitive data using oracle database vault
how to protect your sensitive data using oracle database vaulthow to protect your sensitive data using oracle database vault
how to protect your sensitive data using oracle database vault
 
Database Vault / Verinin Güvenliği
Database Vault /  Verinin GüvenliğiDatabase Vault /  Verinin Güvenliği
Database Vault / Verinin Güvenliği
 
Oracle Golden Gate
Oracle Golden GateOracle Golden Gate
Oracle Golden Gate
 
Oracle 10g Database Server Kurulum
Oracle 10g Database Server KurulumOracle 10g Database Server Kurulum
Oracle 10g Database Server Kurulum
 
DataPump ile Single Parititon Export
DataPump ile Single Parititon ExportDataPump ile Single Parititon Export
DataPump ile Single Parititon Export
 
Redologlar ve Yöneti̇mi̇
Redologlar ve Yöneti̇mi̇Redologlar ve Yöneti̇mi̇
Redologlar ve Yöneti̇mi̇
 
Contraints
ContraintsContraints
Contraints
 
Oracle SQL
Oracle SQLOracle SQL
Oracle SQL
 
Veri̇tabani ve Kullanici Yöneti̇mi̇
Veri̇tabani ve Kullanici Yöneti̇mi̇Veri̇tabani ve Kullanici Yöneti̇mi̇
Veri̇tabani ve Kullanici Yöneti̇mi̇
 
Instance ve Media Bozukluklarını Inceleme
Instance ve Media Bozukluklarını IncelemeInstance ve Media Bozukluklarını Inceleme
Instance ve Media Bozukluklarını Inceleme
 
Conditional Control
Conditional ControlConditional Control
Conditional Control
 
PL/SQL Blocks
PL/SQL BlocksPL/SQL Blocks
PL/SQL Blocks
 
Wait Interface
Wait InterfaceWait Interface
Wait Interface
 
Audit Mekani̇zmasi
Audit Mekani̇zmasiAudit Mekani̇zmasi
Audit Mekani̇zmasi
 
Tuning SGA
Tuning SGATuning SGA
Tuning SGA
 
Parallel Server
Parallel ServerParallel Server
Parallel Server
 
Table Partitions
Table PartitionsTable Partitions
Table Partitions
 

You want to create a user with a random password

  • 1. "################Anar Godjaev##############################" "################This script is useful for when you want to create a user with a random password##########" #!/usr/bin/ksh SID=$1 echo $SID export ORACLE_SID=${SID} echo "userid (password will be generated)" read userid set -A M 0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z L="8" password="" while [ $L -gt 0 ] do password="$password${M[$(($RANDOM%${#M[*]}+1))]}" L="$(($L-1))" done if [ -z "${userid}" ] || [ -z "${password}" ] ; then echo "wrong number of items entered. Press to quit." read nothing exit fi ### DOES USER ALREADY EXIST? IF SO, EXIT ### check_the_user() { sqlplus -s <internal set pages 0 lines 150 head off veri off feed off term off echo off select count(*) from dba_users where username = upper('${userid}'); END } if [[ `check_the_user` -gt 0 ]] ; then echo "ERROR -- user ${userid} already exists - to exit." read nothing exit fi echo "userid ${userid}" echo "newpassword: $password" if [ -z "${userid}" ] || [ -z "${password}" ] ; then echo "wrong number of items entered. Press to quit." read nothing exit fi echo " is this correct (y/n)?" yesno="n" read yesno if [ -z "${yesno}" ] || [ ${yesno} != "Y" ] && [ ${yesno} != "y" ] ; then exit fi sqlplus -s <internal set pages 0 lines 150 head off veri off feed off term off echo off create user ${userid} identified by "$password"
  • 2. default tablespace anar01 temporary tablespace temp QUOTA UNLIMITED ON anar01 QUOTA 0 ON SYSTEM ; GRANT SSE_ROLE TO ${userid} ; exit ENDSQL echo "All done. Press to continue." read nothing exit