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 7923825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:26:31+00:00 2026-06-03T17:26:31+00:00

I am using Oracle SQL developer 2.1 for creating a synonym. CREATE OR REPLACE

  • 0

I am using Oracle SQL developer 2.1 for creating a synonym.

CREATE OR REPLACE SYNONYM "ETKS_PR_RW"."SQ_CLDOS_ATCHMNT_ID" 
    FOR "CLDOS_ONLINE_DBA"."SQ_CLDOS_ATCHMNT_ID";

How can I check that if this synonym already exists then don’t create the synonym if it does.

  • 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-06-03T17:26:33+00:00Added an answer on June 3, 2026 at 5:26 pm

    As you’re using the replace keyword there is no need to check whether the synonym exists first. You will over-write whatever synonym existed with the previous name.

    The only reason to be wary of using replace is if you might have a different synonym with the same name. If your database is organised well this shouldn’t happen. You should always know what all of your objects are and where the synonyms point.

    However, if you do want to there are a couple of options:

    1. Remove replace. The statement will throw an error if the synonym already exists and won’t get over-written.
    2. Query the data-dictionary, as you’re in multiple schemas all_synonyms seems like the best bet.

      select *
        from all_synonyms
       where owner = 'ETKS_PR_RW'
         and synonym_name = 'SQ_CLDOS_ATCHMNT_ID';
      

    If you want to combine these into a single block then you can do something like this:

    declare
    
       l_exists number;
    
    begin
       -- check whether the synonym exists
       select 1
         into l_exists
         from all_synonyms
        where owner = 'ETKS_PR_RW'
          and synonym_name = 'SQ_CLDOS_ATCHMNT_ID';
    
    -- an error gets raise if it doesn-t.
    exception when no_data_found then
       -- DDL has to be done inside execute immediate in a block.
       execute immediate 'CREATE OR REPLACE SYNONYM ETKS_PR_RW.SQ_CLDOS_ATCHMNT_ID 
                       FOR CLDOS_ONLINE_DBA.SQ_CLDOS_ATCHMNT_ID';
    
    end;
    /
    

    On a slightly separate not please do not quote your object names. Oracle can have cased objects, but it is very, very rarely worth the hassle. All objects will be upper-cased automatically so you don’t need the ".

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

Sidebar

Related Questions

In Oracle SQL Developer, one can list the data in a table using the
I'm writing code using Oracle SQL Developer. I have a simple select statement that
Using Oracle SQL Developer I'm trying to access a given package that has been
I'm using Allround Automation PL/SQL Developer with Oracle 10g, and today I've noticed that
I am using Oracle Sql Developer I have a huge script that creates tables,
I am using Oracle SQL developer to create a basic table with the following
I've been creating stored procedures using Oracle SQL developer. For some reason, one of
In addition to How to create a dump with Oracle PL/SQL Developer? Is that
I'm using Oracle SQL Developer to query an Oracle DB (not sure which version
I am using Oracle SQL Developer, but I am having an issue seeing results

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.