cli connection to oracle on linux

Posted on

Question :

I am trying to connect to a local oracle on both windows and linux machines.
I am running the following command

echo Select count(*) FROM all_tables where owner='schema_name'; | sqlplus USER/PASS@localhost:1521

It works on windows but I get a syntax error on Linux. Can someone please fine tune my command to run on Linux?

This is the error I get:

-bash: syntax error near unexpected token

Answer :

You just need to wrap the query in quotes:

echo "Select count(*) FROM all_tables where owner='schema_name';" | sqlplus USER/PASS@localhost:1521

Leave a Reply

Your email address will not be published. Required fields are marked *