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

  • SEARCH
  • Home
  • 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 6604393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:08:59+00:00 2026-05-25T19:08:59+00:00

My Oracle scott schema contains table list like that ‘prefix_A’ ‘prefix_B’ ‘prefix_C’ ‘A’ ‘B’

  • 0

My Oracle scott schema contains table list like that

'prefix_A'
'prefix_B'
'prefix_C'
'A'
'B'
'C'

Now i want to drop list of tables ,containing table prefix like that ‘Prefix_’,But others table A ,B ,C will be remain same.

How it is possible ?

Thanks in Advance.

  • 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-25T19:09:00+00:00Added an answer on May 25, 2026 at 7:09 pm

    Use dynamic SQL driving off the data dictionary.

    begin
         for trec in ( select table_name
                       from user_tables
                       where table_name like 'PREFIX\_%' escape `\' )
         loop
             dbms_output.put_line('dropping table ' || trec.table_name);
             execute immediate 'drop table '||trec.table_name;
         end loop;
    end;
    

    It’s a good idea to be precise with the LIKE clause; using the escape keyword to ensure underscores aren’t treated as wildcards. Alternatively use substr(table_name, 1, 7) = 'PREFIX_'.

    Dropping the wrong table isn’t a disaster provided you’re working on 10g or later and the RECYCLE BIN is enabled, but it’s still better not to. Obviously you wouldn’t run code like this in Production, but you would use the principle to generate a script of drop statements.

    The above code doesn’t handle dependencies. If you have foreign keys referencing the prefixed tables and you want to force the dropping of the tables use this additional logic:

         execute immediate 'drop table '|| trec.table_name ||' cascade constraint';
    

    This drops the foreign key constraints but leaves the (formerly) dependent tables.

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

Sidebar

Related Questions

Oracle creates nicely HTML-formatted workload reports (AWR) that list things like instance statistics, wait
Many Oracle discussions use the emp and related tables in the scott/tiger schema. How
I have created many interlinked tables as user "SCOTT" in oracle DB. I want
Consider the Oracle emp table. I'd like to get the employees with the top
oracle has 'DESCRIBE' to get all the details of the table like wise does
Oracle:- I have around 850 records in an table, that need to be assigned
Oracle FAQ defines temp table space as follows: Temporary tablespaces are used to manage
ORACLE does not permit NULL values in any of the columns that comprise a
Oracle 10g has Profiles that allow various resources to be limited. Here are some
I found out that Oracle Database 10g and 11g treat the following PL/SQL block

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.