Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: SQL*Plus, SQL*Load - How to hide password?
In article <34841DAD.41C67EA6_at_cs.huji.ac.il> Nir Dagan, nirda_at_cs.huji.ac.il writes:
>I know one way is to enter the password manualy while connecting, Is
>there another way, in which I wont need to type anything during the run?
In most Unixes, if it's on the command line, it can be seen, and there's no 100% certain method of concealing it. The simplest solution is to build a shell script and run that instead, so that the username and password are not on the command line. It will probably look like this:
#!/bin/sh sqlplus <<EOF scott/tiger_at_db @some_sql_file EOF
This uses the little-known 'here document' feature of the Bourne shell - the "<<EOF" instructs the shell to take everything up to "EOF" as standard input. (You can use any string instead of "EOF". I generally use "!".) You can write a script using shell variables:
#!/bin/sh USERNAME=scott PASSWORD=tiger DATABASE=db SCRIPT=some_sql_file sqlplus <<EOF $USERNAME/$PASSWORD@$DATABASE @$SCRIPT EOF
This is somewhat cryptic to read, but is regarded as better coding style, especially if you do more than connect once and run one SQL script.
(Extending this solution to SQL*Loader has been left as an exercise for the reader :)