2

I have a sql statement executed in a script which connects to sqlplus and execute some GRANTS statements. In the bash script the instruction is something like:

sqlplus sys as sysdba @script.sql

but I need to add the password. How can I do in a single line ?

I tried:

sqlplus "sys as sysdba"/password @script.sql

or without " but it does not work. Thanks

Ernest Poldrige
  • 399
  • 1
  • 6
  • 17

2 Answers2

3

Example 1

oracle@esmd:~> sqlplus /  as sysdba @ulcase1.sql

SQL*Plus: Release 11.2.0.3.0 Production on Fri Feb 21 12:07:50 2020

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Release 11.2.0.3.0 - 64bit Production

Disconnected from Oracle Database 11g Release 11.2.0.3.0 - 64bit Production
oracle@esmd:~>

Example 2

oracle@esmd:~> sqlplus sys/password  as sysdba @ulcase1.sql

SQL*Plus: Release 11.2.0.3.0 Production on Fri Feb 21 12:08:44 2020

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Release 11.2.0.3.0 - 64bit Production

Disconnected from Oracle Database 11g Release 11.2.0.3.0 - 64bit Production
oracle@esmd:~>

Example 3

oracle@esmd:~> sqlplus sys/password@esmd  as sysdba @ulcase1.sql

SQL*Plus: Release 11.2.0.3.0 Production on Fri Feb 21 12:14:49 2020

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Release 11.2.0.3.0 - 64bit Production

Disconnected from Oracle Database 11g Release 11.2.0.3.0 - 64bit Production
oracle@esmd:~>
Dmitry Demin
  • 2,006
  • 2
  • 15
  • 18
1

You can execute it on this way:

sqlplus sys/password as sysdba @script.sql
Romeo Ninov
  • 6,538
  • 1
  • 22
  • 31