Skip to Main Content
  • Questions
  • Using INSERT INTO… SELECT in TRIGGER

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, CHANDRU.

Asked: February 03, 2017 - 4:34 am UTC

Last updated: February 06, 2017 - 2:59 pm UTC

Version: 4

Viewed 10K+ times! This question is

You Asked

I have around 600 columns in a table. After each insert in this table I need to insert the new row in another backup table.

Please tell how to use "INSERT INTO TABLE_NAME2 SELECT * FROM TABLE_NAME1" query in trigger.

Note: Without specifying columns in insert or select clause

Structure of both table is same. Specifying all the column name in trigger is difficult and also if new columns added, we need to add in trigger as well.

and Connor said...

Maybe a different approach ?

http://www.oracle.com/technetwork/issue-archive/2016/16-mar/o26performance-2925662.html

If you really want to those triggers, then you need the columns specified, but you can script this up easily, eg

https://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:1284601743117

Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

It is not for auditing purpose

A reader, February 04, 2017 - 7:57 am UTC

Say I have daily accounting huge data .Data is instead via direct sql loader in one table.
On morning end users must be able to view data from bo api.
But often new data are not available in time because of slow load or bad csv file ....
The requirement is to give users the ability to view data of as yesterday or previous load.
Note that we don't have partitioning license.
So how duplicate each load in optimal way in order to achieve requirements?
Note also that the data are from numerous flat files that the total amount of target rows is about 30 millions.
Tkx
Connor McDonald
February 06, 2017 - 2:59 pm UTC

Well...FDA is *perfect* for that.

It was my mistake to assume this was auditing. The *main* intent of FDA is to be able to provide a view of the data as it was at any point in time in the past.

That is, it lets you run queries like:

select *
from MY_TABLE as of timestamp 'sysdate-1'

etc

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library