Monday, July 20, 2009

Run sql query from command line

We all know to run sql scripts (.sql files) from command prompt but sometimes we need to run a sql query from command prompt. It is sometimes necessary when we have to fetch a query result from a script (shell/perl) and process it. By following way, we can run a sql query from command prompt.

echo "select * from dual;" | sqlplus -S user/pwd\@sid

No comments: