Is it possible to do something like this?
$ sqlplus -s user/pass "select 1 from dual"
or
$ echo "select 1 from dual" | sqlplus -s user/pass
I know I can put select 1 from dual
in a file and do this:
$ sqlplus -s user/pass @myFile.sql
but I'm wondering if it's actually necessary to create a file just to satisfy sqlplus
Just be aware that on Unix/Linux your username/password can be seen by anyone that can run "ps -ef" command if you place it directly on the command line . Could be a big security issue (or turn into a big security issue).
I usually recommend creating a file or using here document so you can protect the username/password from being viewed with "ps -ef" command in Unix/Linux. If the username/password is contained in a script file or sql file you can protect using appropriate user/group read permissions. Then you can keep the user/pass inside the file like this in a shell script:
sqlplus -s /nolog <<EOF
connect user/pass
select blah;
quit
EOF