sqlplus statement from command line

后端 未结 4 1525
半阙折子戏
半阙折子戏 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条回答
  •  臣服心动
    2020-12-02 09:43

    My version

    $ sqlplus -s username/password@host:port/service <<< "select 1 from dual;"
    
    
             1
    ----------
             1
    

    EDIT:

    For multiline you can use this

    $ echo -e "select 1 from dual; \n select 2 from dual;" | sqlplus -s username/password@host:port/service
    
    
             1
    ----------
             1
    
    
             2
    ----------
             2
    

提交回复
热议问题