How can I get my scrpit to replace or reconstruct objects that are already created?

I am a student of design of database so please bare in mind, I am a beginner.

Basically, I want my script to be run again on the same system. When she did this I want to replace or rebuild the items already made by the script before (in this case a number of tables with PK and FK).

At the moment if I do this it just says: objects and referential integrity already exists? Is there a way I can do that, then it replaces them? Moreover, the tables contain no data.

Thanks in advance!

Published by: Jay on November 4, 2010 04:25

Hello

You probably table create statements in a place safe?

You can for example create this kind procedure

CREATE PROCEDURE drop_all_my_tbl
AS
BEGIN
  FOR c1 IN(
    SELECT table_name,constraint_name
    FROM user_constraints
  )LOOP
    EXECUTE IMMEDIATE 'ALTER TABLE ' || c1.table_name || ' DROP CONSTRAINT ' || c1.constraint_name;
  END LOOP;
  FOR c2 IN(
    SELECT table_name
    FROM user_tables
  )LOOP
    EXECUTE IMMEDIATE 'DROP TABLE ' || c2.table_name;
  END LOOP;
END;
/

Then your run it

BEGIN
  drop_all_my_tbl;
END;

This will drop all your tables, so be careful.
Also I have not test what I have now the schema to test

Kind regards
Jari

Published by: jarola November 4, 2010 13:36
typo in the script

Tags: Database

Similar Questions

Maybe you are looking for

  • No sound after installing windows 10

    I installed Windows on a PC with windows 8.1 10 and now no sound.  I have to download new drivers?  ?????  Thanks for your help.

  • Satellite Pro L300 - questions ACPI in Linux: buggy dsdt implementation

    Hi, I have a L300 with Insyde BIOS 1.50 and I was struggling with the ACPI in Linux (like many others, the web is littered with hacks and workarounds for this laptop). After you enable the acpi kernel debugging, I noticed that some features were mark

  • Issue of fan on hp pavilion dv7 6187 cl

    I have a hp pavilion dv7 6187 cl and, recently, the fan stop working properly, so it must be replaced. Anyone know if the fan can be removed from the sink or I have to buy another radiator with the fan. I am aware of the disassembly procedure. Also,

  • Layout table UUT_RESULT PART_NUMBER

    In the default database for TestStand schema, I see how UUT_SERIAL_NUMBER is generated by the recall of PreUUT. How can I get the PART_NUMBER to the same charge table UUT_RESULT field? Some of my DUT have different numbers than others. Stephen

  • Simple CVI user interface changes

    I'm changing the UI Simple CVI (TestStand 4.1.1) and would like to have a similar functionality using the SequenceCombo and the SequenceView box as the complete UI featured the sequence list box and the box of SequenceView (STEPLISTVIEW).  So that wh