Insert, update, delete logging

Hi friends
I have insert, update, delete the table from the journal as

TableName, rowname, date, user, type of operation

for example, user delete a line, I see in my journal but sometimes I want to deleted data in rows.
with oracle do we find data?
or
We can find data another way?

Look at this example, hope you understand the question

SQL> create table my_tab (id number, name varchar2(20));

Table created.

SQL> create table log_my_tab (old_id number, new_id number, old_name varchar2(20), new_name varchar2(20));

Table created.

SQL> create or replace trigger trg_test
after insert or update or delete on my_tab
for each row
begin
if updating then
insert into log_my_tab values(:old.id, :new.id, :old.name, :new.name);
end if;
end;
/

Trigger created.

SQL> select * from my_tab;

no rows selected

SQL> select * from log_my_tab;

no rows selected

SQL> insert into my_tab values(1,'Kamran');

1 row created.

SQL> update my_tab set id=2,name='Agayev' where id=1;

1 row updated.

SQL> select * from log_my_tab;

    OLD_ID     NEW_ID OLD_NAME             NEW_NAME
---------- ---------- -------------------- --------------------
         1          2 Kamran               Agayev

SQL>

As see you in this example, I create two tables, a main table and another table of newspaper. But in addition I create a trigger to track updates and insert old and new values to the log table

- - - - - - - - - - - - - - - - - - - - -
Kamran Agayev a. (10g OCP)
http://kamranagayev.WordPress.com

Tags: Database

Similar Questions

  • Insert, update, delete

    If I have a cfquery with the data name and relevant source etc. then the sql will be the same for:

    1 insert, update, delete with mysql and mssql?
    2. trade unions and different joins for mysql and mssql?

    Thank you!

    When you compare two db, it is reasonable to assume that they will behave the same if you stay plain vanilla sql and that there will be at least a difference when it comes to features.

  • The separate display - process success Message - for INSERT/UPDATE/DELETE

    Hello

    When we either Insert/update/delete records of shape of the APEX, it fires the Page - processing of automatic line (DML) process and displays the following message - process success Message

    -File has been processed.

    Is there a way for each of them, we can change this message...
    I mean, if the creation of a new record - message should be - record has been created... his way... If update... * manual has been updated *... and so on...

    Thank you
    Deepak

    Hello

    One way is to create a component hidden from this page and calculation value according page submit the request.
    for example if the application is updated then the item value record has been updated.

    Then put this point to the message of successful treatment of automatic line (DML) as & Px_YOUR_ITEM.

    Hope this helps

    BR, Jari

  • Why performance degrades overtime when insert/update/delete VARBINARY?

    I use TimesTen directly related. I created a table with a column of type VARBINARY (100000). My test program inserts a line of 8K bytes in this table, then updates that row with another 8K bytes, then finally deletes this line. If I do the insertion/upgrade to update / delete 10000 times in my program, the number of performances is about 8000 operations per second. But if I do 300000 times, performance is about 4000 transactions per second.

    I do not understand why the performance degrades over time? Anyone understand it?

    Thank you!

    Published by: user8224303 on June 18, 2009 12:41

    Published by: user8224303 on June 18, 2009 13:28

    Based on the workload that you describe, and the fact that you see LOG_BUFFER_WAITS increasing this is likely to be the main problem here. Increasing the size of the log buffer and the size of the file should reduce or eliminate this problem. Depending on the type of disk array and how it is configured, you can still see a performance impact when checkpoints occur if the log files are on the same set of disks than the newspapers. Let us know how you go.

    Chris

  • Insert, Update, Delete on a partition table not even at a time

    Hello
    I have a non-partitioned table on which inserts, updates and deletes come at the same time due to which I am facing problem of contention.
    What would be the ideal solutions to solve my problem (deletion conflict.)

    Thank you
    Badin

    Can you give us more details on the "problem of contention"? This could mean a very large number of different things.

    You have different sessions simultaneously update the same row in the table, for example? If so, you probably need to look at the architecture of the application to avoid multiple sessions to the same line at the same time setting, or you would need to look at the data model to avoid multiple sessions to update the same line at the same time setting.

    But there could be dozens of other kinds of claim that you could talk.

    Justin

  • using postings in insert/update/delete

    Hello all;

    I'm so confused right now... I have read several articles on this subject and I don't know who is good or bad

    If an update statement is written in a client front-end as asp.net, must hire us or not, or should leave us it to auto-commit
    This scenario applies with an insert as well

    If you ask from the point of view of determining what is best practice

    Autocommit is evil and should be avoided at all costs. Unless you really, really, really understand what you do, a request that autocommits will end up with data in an inconsistent state. Unless the developers are extremely cautious, a page that allows you to transfer money from one account to another, for example, eventually sending statements to withdraw money from an account and drop it into the other and autocommit will cause to commit inadvertently withdrawal when filing statement fails.

    If you ask from the point of view of what are the technical requirements

    If you are in the mode autocommit, it is useless to engage in explicitly all the instructions (of course, you also won't be able to restore all the instructions explicitly)
    If you disable auto-commit mode, you will have to validate each transaction explicitly. After all never transactionally consistent of the DML statements (INSERT, UPDATE, and DELETE), you will need to do a commit explicit or an explicit rollback. In the example of transfer of account, you would hire after that withdrawal and the filing of declarations had been executed successfully. When you close a connection, your frame can do an implicit validation or cancellation (it depends on the frame) but who should not be trusted.

    Justin

  • Restrict the insert, update, delete the other user table

    I created a new database user. I have granted the privileges system into a TOAD.

    • Select any table
    • alter any table
    • delete a table

    I found that account can select, alter, drop table arrays of other schema. So how I can limit the which account to modify, remove only its tables belonging and select table of all the schema?

    Is there the ALTER table, ALTER view, ALTER procedure, ALTER synonym, DROP table, DROP view, DROP procedure, DROP synonym system privileges? How can I grant it without ANY system privileges?

  • Someone he wrote routines for insert/update/delete for records of MySQL?

    I prefer not to use Spry or other methods of third parties.  I'm comfortable with coding, so this isn't a problem.  Thank you!

    => is used to assign a value to a key of the associative array, like this:

    $fruit = array ("apple"-online "braeburn", "pear"-online "bartlet");

    -> is used in OO to take an action on an object. That's my definition of on-the-fly. On the left is the name of the object and on the right is what to do. For example, you can set of a property or a method running.

    In the login script, there is no need even to understand what is happening. Just set the variables in the first three lines... then, your queries must always refer to the connection object. Since I use $dbh under the name of connection object, a query would be like this:

    $sql = $dbh-> prepare ("SELECT * FROM fruits WHERE fruit_type =: fruit_type");
    $sql-> bindValue ("fruit_type", "apples");
    $sql-> execute();

  • Component ODI OWB 11 GR 2 How to connect lines inserted/updated to update / delete

    Hi experts,
    I developed an ICT KM which will insert into a target table data line-by-line, I used the ICT_SQL_INCR_UPD_ROW_BY_ROW KM of base provided by oracle, what I noticed, is that this newspaper does not work lines that are inserted as other KMs, after that a little research on the internet discovered that ODI has a function for this , oidRef.setNbInsert, but this doesn't work in OWB KM, it gives this error:
    --------------
    Traceback (innermost last):
    "< String >" file, line 305, inside?
    AttributeError: setNbInsert
    [12: 02:05] Szabo Adorian: org.python.core.Py.AttributeError (Py.java)
    org.python.core.PyInstance.invoke (PyInstance.java)
    org. $0 Python.pycode._pyx64.f (< string >: 305)
    org. Python.pycode._pyx64.call_function (< string >)
    org.python.core.PyTableCode.call (PyTableCode.java)
    org.python.core.PyCode.call (PyCode.java)
    org.python.core.Py.runCode (Py.java)
    org.python.core.Py.exec (Py.java)
    --------------

    Dose - anyone have an ideea how can I connect the inserted, updated, deleted in interface OWB lines (we have a customer who would like tho have this feature)?

    Enjoy a quick response,
    CIPI

    Hi CIPI

    Unfortunately, it is not included, the only possible audit for lines is via JDBC and properties explanations in KM.

    So not every API of ODI is supported, a large common subset is available, you can see the doc for more details (these audit would be useful);
    http://download.Oracle.com/docs/CD/E11882_01/OWB.112/e10935/code_tempates.htm#CIHIIJDI

    See you soon
    David

  • user who has the rights to select/insert/update

    I want to know what user has select, insert, update, delete, run, rights on the tables of the ERP.

    concerning

    oracleRaj wrote:
    I want to know what user has select, insert, update, delete, run, rights on the tables of the ERP.

    concerning

    Mark from dba_tab_privs according to the table of ERP

  • With the help of Merge for Update, Insert, Update and also to delete outdated records

    Hi all!!!

    Suppose that a credit memo the following table called Orders:
    ORDERID        STATUS      PRICE 
    ---------- ---------- ---------- 
             1          0        100 
             2          0        200 
             3          0        300 
             4          0        350 
             5          0        390
    In addition, there are a procedure that will generate data on a global temporary table, called Orders_Temp. This temporary table will be used to update the Orders table. + commands + have a trigger that will perform different operations when an Insert, Update, or Delete command is executed.

    Consider the table of Orders_Temp to have the following data after you run a procedure that is responsible for the update of order data:
    ORDERID        STATUS      PRICE 
    ---------- ---------- ---------- 
             1          1        100 
             2          2        200 
             3          0        300 
             5          0        390 
             6          0        350
    As you can see, orders 1 and 2 have been updated. Order 3 and 5 were intact, order 4 has been deleted and command 6 inserted. Fusion will take care of properly manage orders 1, 2, 3, 5 and 6, although producing an update of order 3 and 5, which have not changed.

    So, here are the questions:
    (1) how could remove the 4 arrestedorder, as this order was not present on Orders_Temp? Is it possible to use the merge command to do this?
    (2) is it possible to generates not a update operation for orders of 3 and 5, which have not changed?

    I m using Oracle 10.2 SE.

    Thank you very much!
    Regis

    Hello

    Please try this. Not tested! with 9i. I think you can do this by using the union all.

    MERGE INTO orders tgt
     USING (SELECT A.*, 1 mask
              FROM orders_temp A
            UNION ALL
            SELECT A.*, 0
              FROM orders A
             WHERE NOT EXISTS
                     (SELECT 1
                        FROM orders_temp b
                       WHERE A.order_id = b.order_id)) src
        ON (tgt.order_id = src.order_id)
    WHEN MATCHED
    THEN
      UPDATE SET tgt.status = src.status, tgt.price = src.price
         WHERE src.mask = 1
           AND tgt.status != src.status
           AND tgt.price != src.price
      DELETE
         WHERE src.mask = 0
    WHEN NOT MATCHED
    THEN
      INSERT VALUES (src.order_id, src.status, src.price)
    

    or you could try to use a full outer join and treat NULL values.
    G.

    Edited by: g. March 8, 2011 11:17

    changed to the Union all the

  • approximate number of inserts, updates and deletions

    Hello
    in 10 g with STATISTICS_LEVEL = TYPICAL
    How to see the approximate number of inserts, updates, and deletes for a specific table?

    Thank you.

    This table has been abandoned - but segment still exists – and 'strange' name comes from the management of the recyclebin.

    Nicolas.

  • What is the best way to store the RCS for an insert/update in this rec

    Oracle on Win 64 non-conteneur 12.1.0.2

    When a record in one table is inserted or updated, what would be the best way to store the RCS for this record in this folder.

    I thought of a line after trigger, but did not know if this trigger to store the current_scn would still fire that trigger again (recursive trigger).

    Someone at - he a good idea of what the best way is to do?  The devs don't want to store the pk and the SNA in yet another table...

    Yes, row_dependencies would be the best way to go.  But mgmt doesn't recreate all tables for this.

    3rd party applications retrieve data from tables (all data).  We are looking for a way for them to just pull what is new or updated updated since their last sweater.

    I suggest that you try again and give all OF THE REQUIREMENTS.

    You have rejected ANY answer given and he justified using 'hidden' on what knowledge management or the devs want or do not want to. Stop making us guess what are the requirements and constraints. If you want a real answer then tell us ALL the news.

    When a record in one table is inserted or updated, what would be the best way to store the RCS for this record in this folder.

    Solomon answered repeatedly. If you want to add a column to a table to store the then "best" SNA is to let the Oracle to do this for you automatically by using the DEPENDENCY LINE.

    As he says also re-create the table to add this clause will be MUCH MORE EFFECTIVE that everything THAT you can do it manually. It will be also more accurate because Oracle will fill the value ORA_ROWSCN with the SNA at the time the line was committed. You, as long as user, can't fill a column in function when a line is engaged since real VALIDATION belongs to a transaction, not the line or the trigger that you use.

    Yes - there are two drawbacks to this method:

    1. you need to re-create the table

    2. you cannot add an index to this "hidden" column

    The devs don't want to store the pk and the SNA in yet another table...

    Then? Who cares what the devs want to do? You want the BEST solution? Next, you will need to put aside personal preferences and determine what is the 'best' solution. Why it is important that certain dev wants to do this or not?

    OK, the problem of biz is now, 3rd party external users are an all-wheel drive large number of tables in the database via the API that we wrote.  That was obviously interrupted OLTP during the day.  To reduce to the minimum, we want for them just to extract data that has been inserted/updated since their last sweater.

    It is the definition of a "replica" DB Then why don't you consider a real replicated DB? You can use DataGuard and have replicated DB which is read only that can be used to generate reports. Oracle does ALL the work to keep ALL the tables in sync. You and your developers do NOTHING!

    We thought that store the RCS higher their last sweater would allow the API to extract only data with YVERT higher than their last data pull CHN.

    OK - except you keep rejecting solutions actually do. Ask you questions about the SNA stored in the same table, but then reject the solution that does this. And then you add your "devs" don't want to store the info in a new table either.

    Then your solutions must ONLY use the replication or Log Miner. The REDO logs have all changes, if you want to extract yourself. Replication (e.g., DataGuard) will use these logs for you to maintain a replicated database.

    We thought about it, but recreate all tables in production with ROWDEPENDENCIES as well as dealing with CF and other dependencies idea this was shot.

    Well you NEVER mentioned you "thought that" and rejected it. And you NEVER mentioned anything about FKs and other dependencies. What is FKs and other dependencies which prevents this working solution? Tell us! Give us ALL the information.

    Wouldn't a trigger AFTER LINE capture the commit YVERT?  Or is after really not after validation?

    No - a trigger has NOT one commit. A trigger runs as a step in a transaction. Validation applies to the entire transaction. Until you, or Oracle, issues a commit, there is NO "committed SNA" to be stored as ORA_ROWSCN.

    You can easily see that for yourself. Create a simple table with dependencies of the line and then update two different sessions.

    create the table emp_scn rowdependencies in select * from emp where rownum<>

    Select empno, emp_scn ora_rowscn

    Update emp_scn set work = 'b' where empno = 7499

    commit;

    The first SELECT statement will show you that each row has the same SNA.

    EMPNO, ORA_ROWSCN

    7369,70622201

    7499,70622201

    7521,70622201

    Now, do the update (but no commit), then SELECT it

    EMPNO, ORA_ROWSCN

    7369,70622201

    7499,

    7521,70622201

    Where is the value of 7499? This session will NOT see a value for the changed lines in the current transaction. Other sessions will still see the old value.

    Now do the validation, then SELECT

    EMPNO, ORA_ROWSCN

    7369,70622201

    7499,70622301

    7521,70622201

    7499 now has a new and different value than the other lines. It will not be this new value until the validation occurs.

    Yes, row_dependencies would be the best way to go.  But mgmt doesn't recreate all tables for this.

    Well, you got the answer you want. You ask the best way. Now, you say that you were told the best way. But now you don't like the answer.

    How is it our fault? Your question has been answered wasn't she?

    Here are the facts:

    1 oracle creates a history of changes - the REDO log files

    2. you can use Log Miner to extract these changes

    3. you can create your own change log by adding a log file of MV to your table.

    4. you can then write a custom code to use this MV log file to determine which rows to "reproduce".

    So far reject you all THE POSSIBLE solutions.

    Accept it or change the requirements to allow one of the solutions proposed to be used.

    Personally, if I HAD to use a customized solution, I would use a MV journal to record the ROWID of the lines that have changed (for tables ROWID cannot be changed). I would then extract the appropriate lines by pulling on the lines corresponding to these row ID.

    Even that has problems since a line can be changed several times and children lines can also be amended several times - these questions FK you mentioned.

    I suggest you read this entire thread on AskTom a dozen years ago. It addresses ALL these issues.

    https://asktom.Oracle.com/pls/Apex/f?p=100:11:0:P11_QUESTION_ID:16998677475837

    Then in your next reply on this topic give us a summary of where some things with your question and what help you further expect.

  • What happens when you insert/modify/delete a row in a table - concepts

    I am trying to understand the below concepts regarding the internal concepts (for example, undo and redo)

    (1) what is happening in the database when you insert a row in a table?

    (2) what is happening in the database when you update a row in a table?

    (3) what is happening in the database when you remove one line in the table?

    I have read the oracle documentation and mistook the redo and undo behavior. It would be great if someone explains the concept in a simple way.  I'm a novice programmer to understand database concepts. Any help would be much appreciated.

    INSERTIONS and deletions are handled the same way.  The cancellation of an INSERT is a DELETE.   The cancellation of a REMOVAL is an INSERT.

    Therefore, the generation 'Cancel' for INSERTION is less than that of a DELETION (because the cancellation of a DELETION is to reinsert the line - the value of each column in the row must be captured in the undo).

    If restore you an INSERT, then Oracle executes effectively a DELETE tablename WHERE rowid =... rowid_that_was_inserted.  A cancellation for an INSERTION is 'rapid '.

    If restore you a DELETION, then Oracle executes effectively an INSERT tablename values (col1, col2, coln).  The cancellation of a DELETION takes more time because Oracle would have to re-enter the values.

    Remember that Oracle also captures the redo to undo it (and do it again for the price drop if you do a restore).

    Hemant K Chitae

  • Can I use shrink for an asset (perform insert very-delete operations) table

    Hello guys,.

    I have a very simple question. According to an article (link: http://www.dba-oracle.com/t_automatic_segment_space_management.htm) the following quote is written
    Beware:  Using ASSM can hinder database DML performance, and most Oracle experts will use manual freelists and freelist groups.  Click here for details on automatic segment space management internals.
    
    Using automatic segment space management is great for almost all Oracle applications, with the exception being super-high update tablespaces, which would use traditional freelists with multiple freelist groups.
    I just want to use shrink my table in order to reclaim the unused space. However, I play a lot insert and delete operations on the table (not update, insert and delete). So, I wonder, if I use shrink, my table will affect seriously? Because I insert and remove thousands of rows in this table every day.


    And my second question is how can I know that my table is in SAMS (automatic segment space management) to use retractable? Because I was told that my table shoul be in SAMS to use retractable?
    select * from v$version;
    Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0 - 64 bit Production
    PL/SQL Release 11.2.0.1.0 - Production
    "CORE 11.2.0.1.0 Production."
    AMT for 64-bit Windows: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    best regards
    Charlie

    970992 wrote:
    I just want to use shrink my table in order to reclaim the unused space.

    Ok. You are sure that there is some unused space and that Oracle will not reuse space automatically? If you are constantly inserting and removing a table, unless you remove constantly more data that you insert or you use direct-path inserts to prevent Oracle to reuse the space freed by deletions, there is no reason to believe that there is unused space in the table.

    However, I play a lot insert and delete operations on the table (not update, insert and delete). So, I wonder, if I use shrink, my table will affect seriously? Because I insert and remove thousands of rows in this table every day.

    Thousands of lines is enough little activity.

    If you want to shrink the table, you generally want to do while there is little or no activity on the table since you will need to at least briefly to acquire a lock on the table. If you do only a few thousand a day race DML operations, it shouldn't be difficult to find a window where the shrink will not be a significant impact on DML.

    But, back to my first point, I would tend to wait that you don't need to shrink the table in the first place.

    And my second question is how can I know that my table is in SAMS (automatic segment space management) to use retractable? Because I was told that my table shoul be in SAMS to use retractable?

    Assuming that you know what the table tablespace is in

    SELECT segment_space_management
      FROM dba_tablespaces
     WHERE tablespace_name = <>
    

    Justin

Maybe you are looking for

  • Firefox does not open. Already running

    I reinstalled Firefox. But this occure from time to time.

  • cancellation from one to the other

    I just found out that my 1: 1 is no longer in existence.  I enjoyed this support and am discouraged that it was cancelled without notification.  I also paid for this service for the following years of the purchase of an Apple computer.  Should not be

  • VI FPGA-61017 open error

    LabVIEW RT running on the cRIO-9068, LabVIEW FPGA programming mode. Citing the FPGA VI open (from the RT program) returns the error-61017 code. Everything seems to work OK, but unexplained errors keep me awake at night. I looked everywhere but could

  • What does the 'Keep Your Drive' Lenovo?

    I have a default/a SSD failed in a relatively new X230t (under warranty). Several attempts to clone the drive (using some tools) has resulted in reports not having read some areas on the SSD. Lenovo hardware analysis indicates: test targeted reading

  • Space on the busy 'unknown' disc C

    Hello Recently I was checking how much space I had left on my drive C (232 GB SSD) because I noticed he was getting quite full. Now here's the strange thing you: he said I have only 59 Gb of free space (which would therefore 173 GB used space) but wh