Delete 3 tables at a time

As normal select query i am getting 3 tables data at a time
like
select * from table_1 t1,table_2 t2,table_3 t3
where t1.col1 = t2.col1
and t2.col1 = t3.col1
and t1.col5 = t3.col2
like this is there a way to delete those 3 tables data at a time. other than 3 seperate delete statements
Any helps will be appreciated.

It is possible that you could do a
DELETE FROM ( <<your query>> )
WHERE <<your criteria>>but that relies on every column being key-preserved in the SELECT statement, which is rather unlikely.
Multiple delete statements (preferrably wrapped in one or more procedures) would probably be the best approach.
Justin

Similar Messages

  • How to delete all data in all tables in one time ?!

    1 CREATE OR REPLACE PROCEDURE delete_all_data
    2 IS
    3 v_statement VARCHAR2 (200);
    4 BEGIN
    5 FOR i IN (SELECT *
    6 FROM user_tables)
    7 LOOP
    8 v_statement :=
    9 'delete table ' || i.table_name ;
    10 EXECUTE IMMEDIATE v_statement;
    11 END LOOP;
    12 commit;
    13* END;
    SQL> /
    Procedure created.
    SQL> exec delete_all_data
    BEGIN delete_all_data; END;
    ERROR at line 1:
    ORA-00903: invalid table name
    ORA-06512: at "DE2.DELETE_ALL_DATA", line 10
    ORA-06512: at line 1
    I made the previous code , but it's didn't work with me .... any help for this problem please ?!
    I'm just reminder ..... all what I need ,that delete all data in all tables in one time only .
    I'm waiting for the answer ..... and thanks in advance

    create or replace
    FUNCTION TRUNC_SCHEMA RETURN NUMBER AS
    CURSOR select_table IS SELECT TABLE_NAME AS TNAME FROM USER_TABLES ORDER BY 1;
    sTableName Varchar2(128);
    sUser Varchar2(128);
    sConstraintName Varchar2(128);
    plsql_block Varchar2(512);
    BEGIN
    SELECT USER INTO sUser FROM DUAL;
    IF ((sUser='SYSTEM') OR (sUser='SYS')) THEN
    RETURN 1;
    END IF;
    EXECUTE IMMEDIATE 'PURGE RECYCLEBIN';
    -- DISABLE table's constraints
    FOR C1 IN (select CONSTRAINT_NAME, TABLE_NAME from user_constraints where STATUS = 'ENABLED' AND CONSTRAINT_TYPE in ('P','R') ORDER BY R_CONSTRAINT_NAME) LOOP
    sConstraintName := C1.CONSTRAINT_NAME;
    sTableName := C1.TABLE_NAME;
    plsql_block := 'ALTER TABLE ' || sTableName || ' DISABLE CONSTRAINT ' || sConstraintName;
    EXECUTE IMMEDIATE plsql_block ;
    END LOOP;
    FOR D IN select_table LOOP
    --get table name
    sTableName := D.TNAME;
    -- clear table
    plsql_block := 'TRUNCATE TABLE ' || sTableName;
    EXECUTE IMMEDIATE plsql_block ;
    END LOOP;
    -- ENABLE table's constraints
    FOR C2 IN (select CONSTRAINT_NAME, TABLE_NAME from user_constraints where STATUS = 'DISABLED' AND CONSTRAINT_TYPE in ('P','R') ORDER BY R_CONSTRAINT_NAME desc) LOOP
    sConstraintName := C2.CONSTRAINT_NAME;
    sTableName := C2.TABLE_NAME;
    plsql_block := 'ALTER TABLE ' || sTableName || ' ENABLE CONSTRAINT ' || sConstraintName;
    EXECUTE IMMEDIATE plsql_block ;
    END LOOP;
    RETURN 0;
    EXCEPTION WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE('ERROR: ' || SQLERRM);
    RETURN 1;
    END TRUNC_SCHEMA;
    /

  • How To Restore Deleted Table With It's Data To Specified Time Using 10g

    Hello Everybody
    I would like to gain from your experience in the Felid of DBA so now i am not trying to restore the full database, but i have a stupid user dropped accedintaly a single table from the database. i want to restore this table after being deleted but also i have big problem i dont have any backup for this table so if you please send to me any solution to restore this deleted table
    Notes : I have (Flash backup On , Archive Log Is On)
    it is not that the database is corrupted or anything
    Ramez S. Swires

    Hey N. Gasparotto
    Thank you for replying me. in the first thread you told me
    ( Without any flashback availability, you haven't any other choice than PITR (Point In Time Recovery)).
    i already checked i found that flashback is working and archive log are working and both are working normally and working before dropping the table and also i cant restore the table which is dropped.
    So what can i do?
    Do you have any other idea?
    Ramez S. Sawires

  • Creating SQL-Loader script for more than one table at a time

    Hi,
    I am using OMWB 2.0.2.0.0 with Oracle 8.1.7 and Sybase 11.9.
    It looks like I can create SQL-Loader scripts for all the tables
    or for one table at a time. If I want to create SQL-Loader
    scripts for 5-6 tables, I have to either create script for all
    the tables and then delete the unwanted tables or create the
    scripts for one table at a time and then merge them.
    Is there a simple way to create migration scripts for more than
    one but not all tables at a time?
    Thanks,
    Prashant Rane

    No there is no multi-select for creating SQL-Loader scripts.
    You can either create them separately or create them all and
    then discard the one you do not need.

  • Retriving data  from two tables at a time.

    Please use this forum to provide feedback about OTN content/services. All other posts will be DELETED.
    hi all,
    Am using win98 and Oracle 7.
    I have splitted a table into two tables having 10 and 9 fields respectively and records of 2000.Now in form builder I have put both tables in same block and on same canvas.
    Now when I execute a query I retrieve records of 1st table and can navigate through records of 1st table only .To retrive records of 2nd table I have to put curser in 2nd table and query again for data retrival from 2nd table.This is bothering me to match coulmn of both tables.
    Is there any way to execute the records of both tables at a time, so that matching coulmns of both tables would become easy to reach.
    Thanks and Regards

    heeeey mohammad
    you have first to make master/detail block not one block only
    then jion between them as pk and fk

  • Insert and Delete at the same time?

    Hi,
    I have a dynamic list and dynamic form. When a person inserts a record using the dynamic form, I would like to delete a record from another table using a foreign key when the new record is added (assuming a record exists in the other table). Is this achievable, and if so, can anyone provide any help?
    Thanks in advance for any advice provided.
    Gary

    As kendenny says, this appears to be a misunderstanding of how database transactions work.
    As Hoek says, if it's an insert and delete on the same table, there is a MERGE statement that can help do that as a single statement.
    However, you do not do an INSERT from one table and a DELETE at the same time from another table.  But that doesn't matter, because that's the point of logica transactions on a database.
    You perform your insert, which starts a transaction (if one isn't already started).
    You then delete from your other table (which adds to the transaction)
    When you're happy that both things are done, you COMMIT your transaction which then applies those changes.
    If you're not happy with something you can ROLLBACK, and that will undo all the changes from the transaction.
    So, the commit and rollback allow the changes to be applied as one logical unit, even though the changes are applied in multiple steps.

  • I updated my iMac to Mountain Lion. All the files were deleted. I have Time Machine backups. When I restart the mac pressing Command R to restore from backup it shows the previous OS X (Leopard) beside the date of the backup. Will it go back if I restore?

    I updated my iMac to Mountain Lion. All the files were deleted. I have Time Machine backups. When I restart the mac pressing Command R to restore it from the backup it shows the previous OS X (Leopard) beside the date of the backup that I want to select. Will it go back to Leopard if I restore it from the backup?

    No, it won't revert to the prior OS X but you you may have third party apps installed that were compatible with Lion that may not be compatible with Mountain Lion.
    App Compatibility Table - RoaringApps - App compatibility and feature support for OS X & iOS
    After you restore from TM, check HD > Incompatible Software

  • Delete tables (cleanly)

    hi guys,
    How do we (1) delete tables (2) delete table entries
    and together deleting the other entries with corresponding foreign key?
    Thanks
    Message was edited by:
            TY Ng

    Hi ,
    U can delete entries from the table using the following syntax.
    DELETE FROM <TABLENAME>.
    Variants:
    1. DELETE FROM dbtab WHERE cond.
    DELETE FROM (dbtabname) WHERE cond.
    2. DELETE dbtab.
    DELETE *dbtab.
    DELETE (dbtabname) ...
    3. DELETE dbtab FROM TABLE itab.
    DELETE (dbtabname) FROM TABLE itab.
    4. DELETE dbtab VERSION vers.
    DELETE *dbtab VERSION vers.
    Effect
    Deletes lines from a database table (see Relational Databases ). You can specify the name of the database table either in the program itself with DELETE FROM dbtab ... or at runtime as the contents of the field dbtabname with DELETE FROM (dbtabname) .... In both cases, the database table must be known to the ABAP Dictionary. Only data from the current client is usually deleted. You can delete data using a view only if the view refers to a single table and was created in the ABAP Dictionary with the maintenance status "No restriction".
    DELETE belongs to the Open SQL command set.
    Notes
    The DELETE statement does not perform authorization checks. You must program these yourself.
    The final (irrevocable) deletion of lines with the DELETE statement is not performed until after a database commit (see Logical Unit of Work (LUW)). Prior to this, you can reverse any database update with a database rollback (see Programming Transactions).
    You cannot rely exclusively on the locking mechanism of the database system to synchronize several users trying to access the same dataset at the same time. You should therefore use the SAP locking mechanism.
    Variant 1
    DELETE FROM dbtab WHERE cond.
    DELETE FROM (dbtabname) WHERE cond.
    Addition:
    ... CLIENT SPECIFIED
    Effect
    Deletes lines in a database table that satisfy the WHERE clause cond. With this variant, specification of a WHERE condition is obligatory .
    When the statement has been executed, the system field SY-DBCNT contains the number of deleted lines.
    The return code is set as follows:
    SY-SUBRC = 0:
    At least one line was deleted.
    SY-SUBRC = 4:
    No lines were deleted, since no line was selected.
    Example
    Delete all bookings for the Lufthansa flight 0400 on 02.28.1995 (in the current client):
    TABLES SBOOK.
    DELETE FROM SBOOK WHERE CARRID = 'LH'       AND
                            CONNID = '0400'     AND
                            FLDATE = '19950228'.
    Note
    To delete all the lines in a table, you must specify a WHERE condition that is true for all lines. You can achieve this with
    ... WHERE f IN itab
    If the internal table itab is empty, such a condition would select all lines.
    Addition
    ... CLIENT SPECIFIED
    Effect
    Switches off automatic client handling. This allows you to delete data across all clients in the case of client-specific tables. The client field is then treated like a normal table field, for which you can formulate suitable conditions in the WHERE clause.
    You must specify the addition CLIENT SPECIFIED immediately after the name of the database table.
    Variant 2
    DELETE dbtab.
    DELETE *dbtab.
    DELETE (dbtabname) ...
    Additions:
    1. ... FROM wa
    2. ... CLIENT SPECIFIED
    See Short forms not allowed and * work areas not allowed.
    Effect
    These are SAP-specific short forms used to delete one line of a database table. If the name of the database table is specified in the program, the primary key of the line to be deleted is taken from the specified work area - dbtab or *dbtab. If the name of the database table is not determined until runtime ( DELETE (dbtabname) ...), the addition ... FROM wa is obligatory .
    When the statement has been executed, the system field SY-DBCNT contains the number of deleted lines (0 or 1).
    The return code is set as follows:
    SY-SUBRC = 0:
    The line was deleted.
    SY-SUBRC = 4:
    No lines could be deleted, since no line exists with the primary key specified.
    Example
    Delete the booking with the booking number 3 for the Lufthansa flight 0400 on 28.02.1995 (in the current client):
    TABLES SBOOK.
    SBOOK-CARRID = 'LH'.
    SBOOK-CONNID = '0400'.
    SBOOK-FLDATE = '19950228'.
    SBOOK-BOOKID = '00000003'.
    DELETE  SBOOK.
    Addition 1
    ... FROM wa
    Effect
    Takes the primary key for the line to be deleted not from the table work area dbtab, but from the explicitly specified work area wa. Here, the key values from left to right are taken from wa according to the structure of the primary key in the table work area dbtab (see TABLES). The structure of wa is not taken into account. Therefore, the work area wa must be at least as wide (see DATA) as the primary key in the table work area dbtab and the alignment of the work area wa must correspond to the alignment of the primary key in the table work area. Otherwise, you get a runtime error.
    Note
    If a work area is not explicitly specified, the values for the line to be deleted are taken from the table work area dbtab, even if the statement appears in a subroutine (see FORM) or function module (see FUNCTION) where the table work area is stored in a formal parameter or a local variable of the same name.
    Addition 2
    ... CLIENT SPECIFIED
    Effect
    As with variant 1.
    Variant 3
    DELETE dbtab FROM TABLE itab.
    DELETE (dbtabname) FROM TABLE itab.
    Addition:
    ... CLIENT SPECIFIED
    Effect
    Mass deletion: Deletes all database table lines for which the internal table itab contains values for the primary key fields. The lines of the internal table itab must satisfy the same condition as the work area wa in addition 1 to variant 2.
    The system field SY-DBCNT contains the number of deleted lines, i.e. the number of lines of the internal table itab for whose key values there were lines in the database table dbtab.
    The return code is set as follows:
    SY-SUBRC = 0:
    All lines from itab could be used to delete lines from dbtab.
    SY-SUBRC = 4:
    For at least one line of the internal table in the database table, there was no line with the same primary key. All found lines are deleted.
    Note
    If the internal table itab is empty, SY-SUBRC and SY-DBCNT are set to 0.
    Addition
    ... CLIENT SPECIFIED
    Effect
    As with variant 1.
    Variant 4
    DELETE dbtab VERSION vers.
    DELETE *dbtab VERSION vers.
    This variant is not allowed in an ABAP Objects context. See VERSION addition not allowed.
    Note
    This variant is now obsolete, since variants 1 - 3 allow you to specify the database table name dynamically.
    Effect
    Deletes a line in a database table, the name of which is taken from the field vers at runtime. The database table must be known to the ABAP Dictionary and its name must conform to the following naming convention: It must begin with 'T' and can consist of four additional characters. The field vers must contain the table name without a leading 'T'. Only lines in the current client are deleted. The line to be deleted is taken from the statically specified table work area dbtab or *dbtab.
    The return code is set as follows:
    SY-SUBRC = 0:
    The line was deleted.
    SY-SUBRC = 4:
    No lines could be deleted because no line existed with the specified primary key.
    <b>Reward points if this helps,</b>
    Kiran

  • TS1368 I want to delete a lot of things childrens stories, albums which are not used which that are on my ipad. However when I go through Itunes it wont show me most of the stuff in my library. it takes ages to delete one at a time.

    I want to delete a lot of things childrens stories, albums which are not used which that are on my ipad. However when I go through Itunes it wont show me most of the stuff in my library. it takes ages to delete one at a time.
    Can you help please?

    Thanks King_Penguin for taking time to read and reply. 
    I just purchased this movie on Thursday, May 15, so just a few days ago.  I have never had any trouble whatsoever since I have been in Vietnam.  I have downloaded several movies and even music and they have all synced to my respected Apple products except for this purchase. 
    Sorry, I don't quite understand what you mean by studios and different versions.  Could you please explain? 
    I checked my purchased list in my purchase history under my account and there are no hidden items. 

  • TS3899 cannot receive or send email from my hotmail account, refuses to verify server. I have changed my password, deleted the account numerous times, any solutions? all on ios 6.

    cannot receive or send email from my hotmail account, refuses to verify server. I have changed my password, deleted the account numerous times, any solutions? all on ios 6. it was working up until a few days ago and now refuses to load on both my ipad 2 and iphone 4S
    in the process deleted all my contact, very annoying.
    all help is much appreciated.
    interesting that my gmail account does work perfectly.

    this may or may not help - but give it a try.  On a forum some were reporting that talk21 is now under the yahoo umbrella.  below are the steps this use listed.  (This was an android forum, but the email settings should be the same.  In short it looks like their server names have changed.  An existing account may have simply been forwarded - but if you are reinstalling, it may want a clean install to the right servers.)  Pay particular attention to the server names and port settings.  (this thread was started based on a discussion of Imap vs pop - you are already an Imap person - so ignore that part)
    See if this helps.
    why settle for pop3, when IMAP works with talk21 and not only does mail get pushed out faster with IMAP, but when you click refresh it will be received faster than pop3.  The other advantage is subfolders are also supported with IMAP but cant be seen with POP3. This mail feature works with my android eclair & hero phone and the settings are exactly the same for win mobiles also (not tested). The mail setting up roadmap is the same from what i can remember once in the mail feature for win mobi. 
    This is what you need to do to setup Talk21 email with IMAP. 
    Incoming server settings
    IMAP server - imap.mail.yahoo.com
    Port - 143
    Security type - none 
    Outgoing Server settings
    SMTP server - smtp.mail.yahoo.com
    Port - 25
    Security type - none Also important note - Enable 'require sign-in'
    and enter your talk21 username and password The End...works a treat for me p.s. Its only taken me 3 years to work it out with win mobile and recently with android. Finally got it to work...hope this helps all the talk21 users out there. if there are any other similar posts out there with no answer...dont forget to mention my name when passing this post around.

  • Update or delete table from XML

    Is it possible to update or delete table's row from XML file?
    Thanks
    Prasanta De

    Hi Steve,
    Thanks for your reply but I could not find any example from the documentation for update-request or delete-request. I need your help in this regards.
    1. I have emp table with many rows and the simple structure like this
    DEPTNO NUMBER(2)
    EMPNO NUMBER(2)
    EMPNAME VARCHAR2(20)
    EMPSAL NUMBER(8,2)
    Key is defined on deptno and empno
    2. I have a xml file like this
    <?xml version = '1.0'?>
    <ROWSET>
    <ROW num="1">
    <DEPTNO>1</DEPTNO>
    <EMPNO>11</EMPNO>
    <EMPSAL>1111.11</EMPSAL>
    </ROW>
    <ROW num="2">
    <DEPTNO>1</DEPTNO>
    <EMPNO>12</EMPNO>
    <EMPSAL>2222.22</EMPSAL>
    </ROW>
    <ROW num="3">
    <DEPTNO>1</DEPTNO>
    <EMPNO>13</EMPNO>
    <EMPSAL>3333.33</EMPSAL>
    </ROW>
    </ROWSET>
    3. I want that xsql servlet will read this xml file and update EMPSAL column depending upon the value of DEPTNO and EMPNO from xml file.
    Please let me know how I should use update-request in xsql page.
    Thanks
    Prasanta De
    null

  • DELETE TABLE STATEMENT WITHIN A LOOP IN A PROCEDURE

    i am using delete table tablename statement inside a cursor for loop which is inside a procedure
    it is telling error in that delete statement
    can't i put it inside the loop

    you can only run DDL commands like create, drop etc in pl/sql by using "execute immediate" or dbms_sql package. when you use either of the two mentioned , it will work anywhere in PL/SQL , yes even in a loop. Note that the commit on DDL are implicit , so take care of your transactions if any ..
    --Samson                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Error in code generation for deleting table BUT000_TD

    Hi,
    Did anyone encounter this error while working on EEWB ?
    I created the project extension via EEWB and completed the wizard setting with the package (dev. class) value as $temp as I wanted to test it locally.
    One of the errors, that I got is:
    Error in code generation for deleting table BUT000_TD
        Message no. DA464
    Diagnosis
        This error message indicates that internal inconsistencies exist.
    Procedure
        Please consult SAP.

    Hi,
    As I mentioned in my previous post kindly check the consistency of the structure BUT000_TD.
    Regards,
    Sudheer.

  • How can i update more than one table at a time?

    i would like to update more than one table at a time. In Java Studio creator2 how can i do table updation?

    Hi,
    Please go through the below thread might be of help to you.
    http://forum.sun.com/jive/thread.jspa?forumID=123&threadID=51839
    RK

  • How can i delete a 'backups' from time machine for a computer i no longer have

    i have been using my time capsule for a few years now, everything was great until my imac died and i had to replace it
    when i did, the time capsule worked perfectly, as it allowed me to "migrate" all my backed up data onto my new machine, joy
    but now, as it wants to start its backups of the new imac, there just isnt enough disk space on the drive, and i suspect this is due to every file on my new machine is marked as never have being backed up which means i need like 400G, and most of the time capsule's space is still consumed by the old backups
    how can i remove this old back up from the time capsule without reformatting the whole drive (i have other machines that are still using the backup service and i dont want that interrupted)
    it just seems like, since i am no longer on the old machine, i cant access that machine's backup in order to delete them (through the time machine interface), and i cant seem to find a single tutorial on how to do this that is written in non-programmer speak (i really dont feel comfortable cracking open terminal and command-lining this sort of thing)
    am i just nuts or is this really all that uncommon a problem with no easy solution?!?
    any advice is appreciated, thanks in advance

    how can i remove this old back up from the time capsule
    click here for instructions.

  • How to insert into more than one table at a time also..

    hi,
    i am a newbee.
    how to insert into more than one table at a time
    also
    how to get a autoincremented value of an id say transactionid for a particular accountid.
    pls assume table as
    transactionid accountid
    101 50
    102 30
    103 50
    104 35
    i want 102 for accountid 30 and 103 for accountid 50.
    thank u

    @blushadow,
    You can only insert into one table at a time. Take a look here :
    Re: insert into 2 tables
    @Raja,
    I want how to extract the last incremented value not to insert.Also, I don't understand your thread title... which was "how to insert into more than one table at a time also.. "
    Insert, extract... ? Can you clarify your job ?
    Nicolas.

Maybe you are looking for

  • Problem with storing pictures to the Media Card

    I set my 8330 to store pictures to the media card.  It works for a while and then the device reverts to storing it on the device memory.  It does this without asking or telling me that it's done so.  It's very frustrating.  Anybody have any idea why

  • Error while creating equipment BOM (IB01)

    hi guys, while creating equipment BOM (IB01) i am getting this error, while adding components. 'Material type NLAG cannot be used with item category (plant 1000)'. regards chinta

  • I don't know where to start............

    I'm horrified at the treatment I have had, all I wanted was to move home and I have been treated like an idiot, my BT move was cancelled and nobody at BT can tell me why, I had to sign up as a new customer, I was guaranteed my original (40 year) phon

  • How to keep the WBS & Order in account assignment tab of SD contract item?

    Hi Experts, If I remove the plant from the shipping tab in the contract item (the contract type is WV), I will be able to enter the WBS or Order in accounting assignment tab. However, if I enter the plant (in order to determine the tax in pricing), t

  • HP5520 Connection Error 403

    HP5520 Connection Error 403 when attempt to scan even though it shows I am connected to WiFi.