Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6171143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:09:47+00:00 2026-05-23T23:09:47+00:00

I am attempting to write an sql command into an sql file so that

  • 0

I am attempting to write an sql command into an sql file so that the output itself can be used as a script. Basically using a script to create output that is itself formatted into runnable script. Maybe it’s redundant but I haven’t been able to think of a better way. I could use an extra set of eyes (or ideas) if possible. Thanks

Here’s the 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 ANY SYNONYM TO &&syn_user;//how is this line formed?
select  'create or replace synonym ' || table_name ||
' for ' || '&&master_user..' ||
table_name || ';'
from user_tables
order by table_name asc;
--REVOKE CREATE ANY SYNONYM FROM &&syn_user;//how is this line formed?
SPO OFF;
SET ECHO ON FEEDBACK ON VERIFY ON HEAD ON TERM ON;
exit

This is the output:

//need the "grant" line here
create or replace synonym AGENTS for webdemo_admin.AGENTS;
create or replace synonym CONSTRUCTION_COMPANY for webdemo_admin.CONSTRUCTION_COMPANY;
create or replace synonym CONTRACT for webdemo_admin.CONTRACT;
create or replace synonym CUSTOMERS for webdemo_admin.CUSTOMERS;
create or replace synonym CUSTOMER_INTEREST for webdemo_admin.CUSTOMER_INTEREST;
create or replace synonym FEATURE for webdemo_admin.FEATURE;
create or replace synonym HOME for webdemo_admin.HOME;
create or replace synonym HOME_NONSTD_FEATURE for webdemo_admin.HOME_NONSTD_FEATURE;
create or replace synonym INTEREST for webdemo_admin.INTEREST;
create or replace synonym NON_STD_FEATURE for webdemo_admin.NON_STD_FEATURE;
create or replace synonym SALES for webdemo_admin.SALES;
create or replace synonym STD_FEATURE for webdemo_admin.STD_FEATURE;
create or replace synonym STD_MODEL for webdemo_admin.STD_MODEL;
create or replace synonym STD_MODEL_FEATURE for webdemo_admin.STD_MODEL_FEATURE;
create or replace synonym SUB_CONTRACTOR for webdemo_admin.SUB_CONTRACTOR;
create or replace synonym WARRANTY_WORK for webdemo_admin.WARRANTY_WORK;
//need the "revoke" line here

I am sure there are better ways to do this, I’m still picking things up as I go. As fo an explanation (for understanding): I want that I maintain a user with full control over the tables (and the schema) but I need a user (or upto 10 users) with the above-listed private synonyms in order for multiple connections to have the same type of access that a real-estate agent might (when viewing this from the perspective of a web app). That is, the synonyms allow for select,insert, update and delete transactions. The reason for the grant/revoke before and after the synonym creation is only to automate the process and remove the security problem of granting the create any synonym to a normal user. Further, I do not want the synonyms to be public as that is also a headache to keep track of (and again a security problem). In any case, private is better and offers more control.

Again, I appreciate any suggestions anyone may have.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T23:09:48+00:00Added an answer on May 23, 2026 at 11:09 pm

    Is the SQL*Plus PROMPT keyword what you’re after? This just displays the rest of the line:

    SQL> DEFINE syn_user = exampleuser1234
    SQL> PROMPT GRANT CREATE ANY SYNONYM TO &&syn_user;;
    GRANT CREATE ANY SYNONYM TO exampleuser1234;
    SQL>
    

    Note that we must double the semicolon since SQL*Plus interprets the first one as the end of the substitution parameter syn_user.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting to write a one-line Perl script that will toggle a line
I'm attempting to write a CompiledQuery using Linq-to-Entities that will replace a stored procedure
I'm attempting to write a performance testing function that can take any function, run
I'm attempting to write a program in Linux using C++ that counts the number
I'm attempting to write a function that generates a list of DateTimes using the
I am attempting to write a JS function (using prototype in rails) that will
I am attempting to write a stored procedure that can take in k words
I've been attempting to write a Lisp macro that would perfom the equivalent of
I am attempting to write an application that uses libCurl to post soap requests
I'm attempting to write a Python C extension that reads packed binary data (it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.