sqlplus statement from command line

后端 未结 4 1526
半阙折子戏
半阙折子戏 2020-12-02 09:03

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/pas

4条回答
  •  猫巷女王i
    2020-12-02 09:45

    I'm able to execute your exact query by just making sure there is a semicolon at the end of my select statement. (Output is actual, connection params removed.)

    echo "select 1 from dual;" | sqlplus -s username/password@host:1521/service 
    

    Output:

             1
    ----------
             1
    

    Note that is should matter but this is running on Mac OS X Snow Leopard and Oracle 11g.

提交回复
热议问题