sql - Oracle SQLPlus question - writing strings to txt file -
i attempting write sql command sql file output can used script. using script create output formatted runnable script. maybe it's redundant haven't been able think of better way. use set of eyes (or ideas) if possible. thanks
here's script:
connect &&master_user/&&master_pwd.@&&tns_alias set linesize 132 pagesize 0 echo off feedback off set verify off head off term off trimspool on spo syns_list.sql --grant create synonym &&syn_user;//how line formed? select 'create or replace synonym ' || table_name || ' ' || '&&master_user..' || table_name || ';' user_tables order table_name asc; --revoke create synonym &&syn_user;//how line formed? spo off; set echo on feedback on verify on head on term on; exit
this output:
//need "grant" line here create or replace synonym agents webdemo_admin.agents; create or replace synonym construction_company webdemo_admin.construction_company; create or replace synonym contract webdemo_admin.contract; create or replace synonym customers webdemo_admin.customers; create or replace synonym customer_interest webdemo_admin.customer_interest; create or replace synonym feature webdemo_admin.feature; create or replace synonym home webdemo_admin.home; create or replace synonym home_nonstd_feature webdemo_admin.home_nonstd_feature; create or replace synonym interest webdemo_admin.interest; create or replace synonym non_std_feature webdemo_admin.non_std_feature; create or replace synonym sales webdemo_admin.sales; create or replace synonym std_feature webdemo_admin.std_feature; create or replace synonym std_model webdemo_admin.std_model; create or replace synonym std_model_feature webdemo_admin.std_model_feature; create or replace synonym sub_contractor webdemo_admin.sub_contractor; create or replace synonym warranty_work webdemo_admin.warranty_work; //need "revoke" line here
i sure there better ways this, i'm still picking things go. fo explanation (for understanding): want maintain user full control on tables (and schema) need user (or upto 10 users) above-listed private synonyms in order multiple connections have same type of access real-estate agent might (when viewing perspective of web app). is, synonyms allow select,insert, update , delete transactions. reason grant/revoke before , after synonym creation automate process , remove security problem of granting create synonym normal user. further, not want synonyms public headache keep track of (and again security problem). in case, private better , offers more control.
again, appreciate suggestions may have.
is sql*plus prompt
keyword you're after? displays rest of line:
sql> define syn_user = exampleuser1234 sql> prompt grant create synonym &&syn_user;; grant create synonym exampleuser1234; sql>
note must double semicolon since sql*plus interprets first 1 end of substitution parameter syn_user
.
Comments
Post a Comment