How to do "DDL rollback"

I have script, that contains several DDL-statements. For example script removes FK-constraint from a column, then it renames the column, then it puts new data to the column, then it puts new FK-constraint to the column, also some other ALTER-statements are done, and with several tables.
I want to test my such script. I want to test so that if something in my long script throws error, then i can rollback all made ddl changes and fox the script and rerun the script again. How can i do this?
It could be something like this:
begin DDL tran;
   alter 1
   alter 2
   alter N
when others then
   rollback all ddl
end DDL tran;

You cannot ROLLBACK a DDL. Because Oracle issue COMMIT before and after execution of the DDL statement.
But the best way to write these DDL Script is to include the command to drop the newly created object in the script itself.
I would say like this.
drop table t
create table t (no integer)
/

Similar Messages

  • How to do safePoint Rollback

    Hi,
    Jdev : 11.1.1.2.1
    Can some one please share me a link how to do safepoint rollback.
    i.e Rollback up to some specific point only.
    Thanks,
    Hari

    Hi,
    Are you expecting
    http://www.oracle.com/technetwork/developer-tools/adf/learnmore/007-cancelform-savepoint-169126.pdf

  • How does the LCM rollback feature work in theory?

    Hi
    How does the LCM rollback feature work in theory?
    Let's say
    1. I've Webi report 'x' in QA system
    2. I promote a modified version of webi report 'x' from DEV to QA using LCM. So now I've 'x1' in QA.
    3. I "rollback" this promotion job in LCM. Which means I've get back 'x' in QA system.
    So does this mean that LCM kept a "backup" copy of 'x' in QA (CMS+filestore file backup) before overwriting with the promoted 'x1' from DEV?
    If yes, does it clear the 'x' anytime from QA? (maybe after second iteration of 'x2'?)
    Thanks

    I highly recommend you read the following blog posts that contains straight answers to common questions about the automatic update feature:
    Hello, Adobe Flash Player Background Updater (Windows)!
    Adobe Flash Player Background Updater for Mac is live!

  • How to Track DDL and DML Operations happening in Backend into Log Files....

    Hi I have one requirement for Tracking the DDL And DML Operation happening in Backend once the user Inserts or Updates any Table.How to Implement the same can anyone proviode the code for the same.
    Ex: I have multiple tables in my database if any user fires the DDL or DML it should make entry in the Log file as
    Name of the Table Operation Timestamp
    X Insert DD-MM-YYYY HH24:MM:SS
    Y Update DD-MM-YYYY HH24:MM:SS
    Z Delete DD-MM-YYYY HH24:MM:SS
    L Select DD-MM-YYYY HH24:MM:SS
    Is it Possible to Develop it through Procedure,Function or Package,please give me Idea,,,,,

    Please do not post same question in multiple forum. How to Track DDL and DML Operations happening in Backend into Log Files....
    What's wrong with the answers posted in the above forum ? Do you go through the "AUDIT" option as suggested in the above post by various members ?

  • How to set DDL lock for a table

    OCI,how to set DDL lock for a table?

    Oracle acquires a dictionary lock automatically on behalf of any DDL transaction requiring it. Users cannot explicitly request DDL locks. Only individual schema objects that are modified or referenced are locked during DDL operations. The whole data dictionary is never locked
    DDL locks fall into three categories: exclusive DDL locks, share DDL locks, and breakable parse locks.
    see this link
    http://www.sc.ehu.es/siwebso/KZCC/Oracle_10g_Documentacion/server.101/b10743/consist.htm#i5281

  • How to handle DDL in remote database

    Hi our db running on 10g. How to handle DDL's on the remote database? My requirement is as a object migration, how to migrate object/s from database A to database B through user. Say i have table call my_table in database A I want to create/replace this table on database B as a database user. Is there a way can be done? Database link or streams or any other method?
    Thanks in advance,
    -B

    You have many options to do this, just to name a few
    use COPY command of SQLPLUS
    SQL> copy from scott/tiger@DB_A
             to scott/tiger@DB_B
             create new_emp using select * from emp;create database link to database A in database B, run this from database B
    create new_emp as select * from emp@dblinkDB_A;or export/import
    etc.

  • How to extract ddl

    Hi, someone to know how to extract ddl database oracle lite, using some tool or program native.
    Thanks
    Fabrício

    Hi Frabricio,
    Oracle Lite does not provide any tools to extract DDL, but you can use your own sql script by using the Oracle Lite Dictionary tables:
    Section 5.1, "ALL_COL_COMMENTS"
    Section 5.2, "ALL_CONSTRAINTS"
    Section 5.3, "ALL_CONS_COLUMNS"
    Section 5.4, "ALL_INDEXES"
    Section 5.5, "ALL_IND_COLUMNS"
    Section 5.6, "ALL_OBJECTS"
    Section 5.7, "ALL_SEQUENCES"
    Section 5.8, "ALL_SYNONYMS"
    Section 5.9, "ALL_TABLES"
    Section 5.10, "ALL_TAB_COLUMNS"
    Section 5.11, "ALL_TAB_COMMENTS"
    Section 5.12, "ALL_USERS"
    Section 5.13, "ALL_VIEWS"
    Section 5.14, "CAT"
    Section 5.15, "COLUMN_PRIVILEGES"
    Section 5.16, "DATABASE_PARAMETERS"
    Section 5.17, "DUAL"
    Section 5.18, "TABLE_PRIVILEGES"
    Section 5.19, "USER_OBJECTS"
    Regards.
    Marc

  • How to run DDL in a Trigger?

    I am trying to create a trigger that automatically sets the quota for any new users created in the database. However, I am running into the follow error because whenever you run DDL, Oracle automatically commits, which you can't do in a trigger. Does anyone have any ideas on how to get around this? We are on Oracle 11gR1.
    . The problem is, I am getting an ERROR at line 1:
    ORA-04092: cannot COMMIT in a trigger
    CREATE OR REPLACE TRIGGER TESTER.AUTO_QUOTA
    AFTER INSERT ON USERS FOR EACH ROW
    DECLARE
    sqlstmt     VARCHAR2(100);
    BEGIN
    sqlstmt:='ALTER USER ' || :NEW.USERNAME || ' QUOTA UNLIMITED ON ' || :NEW.TABLESPACE_NAME;
    execute IMMEDIATE SQLSTMT;
    END;
    /

    ji**** wrote:
    I am trying to create a trigger that automatically sets the quota for any new users created in the database. However, I am running into the follow error because whenever you run DDL, Oracle automatically commits, which you can't do in a trigger. Does anyone have any ideas on how to get around this? We are on Oracle 11gR1.This approach is wrong.
    What is the purpose of a trigger? The answer is protecting the integrity of the transaction - not to do "extra stuff" outside the current actual business transaction. Like sending e-mails. Or SMS's. Or issue DDL commands.
    What happens when you do "extra stuff" in that trigger and the transaction is rolled back for example? What now happens to that "extra stuff" that should not have existed/have been done in the first place?
    The correct approach is to create a procedure or package that does this "extra stuff". Then schedule a job from this trigger to call that procedure.
    When the transaction commits, so too is the job to do the "extra stuff". If the trigger is rolled back, so too the submission of the job. And the trigger does not need smelly approaches like autonomous transactions for getting "extra stuff" done.

  • How to get files rollback by using File Adapter

    Hi All,
    I have a question..
    How can we get the files rollback whenever the inbound file adapter is down after reading some files in source.??
    Regards,
    VenkatCH

    Hi VenkatCH,
    You can do rollback with File Adapter using jca.retry.* properties.
    you can do same with below ways:
    1.click on File Adapter.
    2. Go to view> property inspector.
    3. click on binding properties and set the properties.
    Thanks
    Richa

  • How to get ddls from sqlplus like that of TOAD

    Hi,
    I have to work on a terminal machine for a client where the TOAD is not installed. For my regular DBA activities I need to take the DDL many times.
    I am very much used to the style of DDL scripts which TOAD 9.6.x.x gives for any object in a schema.
    Can someone suggest how I can I get exactly TOAD-like scripts (which provide not just the create statements)
    For e.g.
    *1.From sqlplus when I do*
    select dbms_metadata.get_ddl('TABLE','APE1_ACCUMULATORS') from dual;
    I get only the below
    CREATE TABLE XLTDBO92.APE1_ACCUMULATORS
    CYCLE_CODE NUMBER(4) CONSTRAINT APE1ACCU_CYCLE_CODE_NN NOT NULL,
    CYCLE_INSTANCE NUMBER(2) CONSTRAINT APE1ACCU_CYCLE_INSTANCE_NN NOT NULL,
    CUSTOMER_SEGMENT NUMBER(4) CONSTRAINT APE1ACCU_CUSTOMER_SEGMENT_NN NOT NULL,
    CUSTOMER_ID NUMBER(9) CONSTRAINT APE1ACCU_CUSTOMER_ID_NN NOT NULL,
    ACCUM_TYPE_ID NUMBER(9) CONSTRAINT APE1ACCU_ACCUM_TYPE_ID_NN NOT NULL,
    OWNER_ID
    *2.But from TOAD 9.6.x.x when i click on "create scripts" I will get*
    DROP TABLE XLTDBO92.APE1_ACCUMULATORS CASCADE CONSTRAINTS;
    CREATE TABLE XLTDBO92.APE1_ACCUMULATORS
    CYCLE_CODE NUMBER(4) CONSTRAINT APE1ACCU_CYCLE_CODE_NN NOT NULL,
    CYCLE_INSTANCE NUMBER(2) CONSTRAINT APE1ACCU_CYCLE_INSTANCE_NN NOT NULL,
    CUSTOMER_SEGMENT NUMBER(4) CONSTRAINT APE1ACCU_CUSTOMER_SEGMENT_NN NOT NULL,
    CUSTOMER_ID NUMBER(9) CONSTRAINT APE1ACCU_CUSTOMER_ID_NN NOT NULL,
    ACCUM_TYPE_ID NUMBER(9) CONSTRAINT APE1ACCU_ACCUM_TYPE_ID_NN NOT NULL,
    OWNER_ID
    DROP SYNONYM XLTDB92.APE1_ACCUMULATORS;
    CREATE SYNONYM XLTDB92.APE1_ACCUMULATORS FOR XLTDBO92.APE1_ACCUMULATORS;
    GRANT DELETE, INSERT, SELECT, UPDATE ON XLTDBO92.APE1_ACCUMULATORS TO XLTDBO92_ALL;
    So my question is:
    How to such scripts from sqlplus as well ,irrespective of the type of the object?_
    Note:I am posting a new thread because my previous question was answered even though i was not able to type in completely. My mistake as it was posted in before i could finish the question.
    Regds,
    Kunwar

    If the DDL returned by dbms_metadata is not to your liking then write your own scrips to generate DDL or cover scripts to generate all related items that you want.
    In the case of synonyms and grants this is very easy using rdbms dictionary views, but if you generate a table's DDL you may also want and need the PK, UK, FK, secondary indexes, comments, and policies on the table as well as synonyms and grants. Everything that if you drop the tables goes away.
    There is a dbms_metaddata procedure get_dependent_ddl to generate dependend objects on a table that may be of interest.
    HTH -- Mark D Powell --

  • How to get DDL descriptions of DDIC tables?

    Hi,
    for a replication scenario of ERP data into BOBJ BI on Demand we have to define data schemas in the BI oD MS SQL Server. Instead of doing that manually, we could also import DDL (data definition language) descriptions of the ERP DDIC table to replicate into the SQL Server.
    The question is: Is it possible to generate or extract DDL descriptions of database tables defined in the ERP DDIC and if yes, how (e.g. inside ABAP or using DB tools)?
    Thanks for any assistance,
    H-D

    Hi,
    if you use SQL2005 or SQL2008 you can try SSMS to generate the DDL statements. Just expand your database <SID> and apply a filter on the tables tab. If you right click on a specific table you have the option to 'Script table as' -> 'Create to' -> 'New Query Editor Window'. That way you will get the CREATE TABLE statement.
    Regards,
    Sven

  • How to Generate DDL Statement for PSAPROLL Tablespace on Oracle9i-HP_UX

    Hi,
    I am having SAP R3 46C installed with Oracle 9i on HP_UX 11i system.
    I want to generate required DDL statements for PSAPROLL Tablespace/Rollback Segments as Backup/recovery purpose, before converting it into PSAPUNDO.
    Its easy to find & store required DDL statements using OEM. But, I am not able to locate oemapp  (under $ORACLE_HOME/bin directory) application in the installation.
    The current patch level of installed oracle is
    I want to start OEM in HP_UX system, if it is possible.
    otherwise,
    I want to know the other alternatives to generate the required DDL statements.
    Thanks in advance.
    Regards,
    Bhavik G. Shroff

    Hi Stefan,
    On windows Platform it is very easy to get DDL info for any object of database.
    But, I was not able to start OEM in HP_UX system.
    I have done my job complete using this good package of Oracle9i, in this way.
    SQL> SET heading off
    SQL> SET long 10000
    SQL> SET pages 100
    SQL> SELECT dbms_metadata.get_ddl(u2019TABLESPACEu2019,'PSAPROLLu2019)
    FROM DBA_TABLESPACES;
    O/P:
    CREATE TABLESPACE "PSAPROLL" DATAFILE
    '/oracle/RQ1/sapdata1/roll_1/roll.data1' SIZE 681574400 REUSE ,
    '/oracle/RQ1/sapdata1/roll_2/roll.data2' SIZE 3145719808 REUSE
    LOGGING ONLINE PERMANENT BLOCKSIZE 8192
    EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1048576 SEGMENT SPACE MANAGEMENT MANUAL
    SQL> SELECT dbms_metadata.get_ddl(u2019ROLLBACK_SEGMENTu2019,'PRS_0u2019)
    FROM DBA_SEGMENTS;
    CREATE ROLLBACK SEGMENT "PRS_0" TABLESPACE "PSAPROLL"
    STORAGE(INITIAL 10485760 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 32765
    Also follow this useful links:
    [DDL Generation--Oracle's Answer to Save You Time and Money|http://www.dbasupport.com/oracle/ora9i/DDLgen2.shtml]
    [DDL Generation--Oracle's Answer to Save You Time and Money|http://www.dbasupport.com/oracle/ora9i/DDLgen3.shtml]
    Good.
    Thanks a lot.

  • How to turn off rollback in DML?

    Hi,
    I do lot DML statements and I don't require roll back; how can I trun off this to speed
    up DML statements?
    Thanx
    Alfred

    1) As mentioned above, other than direct-path inserts, there's no way to bypass the rollback segments.
    2) "Autocommit" isn't a feature within the database. SQL*Plus and most client API's will implement "Autocommit" for you by issuing a "commit" immediately following your successful statement.
    3) Turning "Autocommit" on will always (can't think of a counterexample) make your process slower, not faster. Committing is a reasonably expensive operation in any database.
    Justin

  • How to avoid redo/rollback?

    Hi Alls,
    I want to delete some data in a table without rollback?
    How can I do?
    Thanks.
    Witchuda.

    Hi,
    Use cancelAction() described here: http://kuba.zilp.pl/?id=481
    Kuba

  • How to track DDL Changes and source code changes

    How can I track the DDL Changes and the Source code (Functions,Procedures,Packages & views) changes made for selective schemas?.
    I mean I want to maintain the history of DDL changes and the sourcecode change history. How to do that? Please provide your guideline with some example...

    Hi,
    you could use a DDL trigger (before create)
    to maybe capture the code and do the audit as well?
    Try this:
    SQL>create table old_code
    2 as
    3 select user username, 0 version, sysdate date_changed, user_source.*
    4 from user_source
    5 where 1=0
    6 /
    Table created.
    SQL>create sequence version_seq;
    Sequence created.
    SQL> create or replace trigger create_trigger
    2 before create on schema
    3 declare
    4 l_date date := sysdate;
    5 l_ver number;
    6 begin
    7 if (ora_dict_obj_type in ( 'PACKAGE', 'PACKAGE BODY', 'PROCEDURE',
    'FUNCTION' ) )
    8 then
    9 select version_seq.nextval into l_ver from dual;
    10
    11 insert into old_code
    12 select user, l_ver, l_date, user_source.*
    13 from user_source
    14 where name = ora_dict_obj_name
    15 and type = ora_dict_obj_type;
    16 end if;
    17 end;
    18 /
    Trigger created.
    SQL> create or replace function f return number
    2 as
    3 begin
    4 return 0;
    5 end;
    6 /
    Function created.
    SQL> select * from old_code;
    no rows selected
    SQL> create or replace function f return date
    2 as
    3 begin
    4 return sysdate;
    5 end;
    6 /
    Function created.
    ops$[email protected]> select * from old_code;
    USERNAME VERSION DATE_CHAN NAME TYPE LINE TEXT
    aaaaaaaaaaa 2 17-OCT-02 F FUNCTION 1 function f return number
    aaaaaaaaaaa 2 17-OCT-02 F FUNCTION 2 as
    aaaaaaaaaaa 2 17-OCT-02 F FUNCTION 3 begin
    aaaaaaaaaaa 2 17-OCT-02 F FUNCTION 4 return 0;
    aaaaaaaaaaa 2 17-OCT-02 F FUNCTION 5 end;

Maybe you are looking for

  • Mini-DVI to DVI Adapter

    I am looking to get a second monitor for my iMac G5 for FCP (I'm also looking to get Final Cut Studio). In the help file it says the iMac G5 has a Mini-VGA port, but at the Apple store I bought a Mini-DVI to VGA and Mini-DVI to TV adapter and they wo

  • Solaris Management Console (SMC) - Solaris 9 x86

    I�ve just installed Solaris 9 (x86) version. I�m unable to install Solaris Management console. I was using below command to add listed patches: pkgadd -d . SUNWpmgr SUNWrmui SUNWlvmr SUNWlvma SUNWlvmg I�m unable to find these packages on cd1. Somehow

  • Patches did not update to client Windows 7

    Hi We have 2 domain controllers installed on Windows server 2003 STD. Also Group policy management installed with the these servers. We have installed WSUS server on the another server that installed Windows server 2008 STD. When WSUS server  shows t

  • Can I use DVD+R disks with my MacBookPro, OS10.7.5, and iMovie 6 and IDVD 7.1.2

    Can I use DVD+R disks with my MacBookPro, OS10.7.5, and iMovie 6 and iDVD 7.1.2  ???? I have always used DVD-R.  I made a mistake in ordering and got 100 DVD+R .  Would it be advisable to return them?

  • Graph in a XY from Subvi

    Grettins for my project I have to adquire datos from a DAQ so I made a states machines and I saved that datas in a array. in another state I export that datas to excel by local variables I have another state "Graph", in this state I want to Graph th