How can i pass parameter to sql script?

前端 未结 2 1970
死守一世寂寞
死守一世寂寞 2020-12-17 10:07
CREATE TABLE DMS_POP_WKLY_REFRESH_20100201 NOLOGGING PARALLEL AS
SELECT wk.*,bbc.distance_km ,NVL(bbc.tactical_broadband_offer,0) tactical_broadband_offer ,
       s         


        
2条回答
  •  时光说笑
    2020-12-17 10:41

    SQL*Plus uses &1, &2... &n to access the parameters.

    Suppose you have the following script test.sql:

    SET SERVEROUTPUT ON
    SPOOL test.log
    EXEC dbms_output.put_line('&1 &2');
    SPOOL off
    

    you could call this script like this for example:

    $ sqlplus login/pw @test Hello World!
    

    Edit:

    In a UNIX script you would usually call a SQL script like this:

    sqlplus /nolog << EOF
    connect user/password@db
    @test.sql Hello World!
    exit
    EOF
    

    so that your login/password won't be visible with another session's ps

提交回复
热议问题