Solved

How to find the last update time of each table in Oracle?

Posted on 2008-10-08
9
14,846 Views
Last Modified: 2013-12-19
I have a program that link to a database, however, when I use the program, I want to know which table does it updated? However, this program does not write any timing information nor the tables do not have a column that store the last update time. Therefore, I would like to know does Oracle records the last alteration / update time of each table? If not, are there any other methods that let me find out the last update time? Thanks!
0
Comment
Question by:mawingho
9 Comments
 
LVL 9

Assisted Solution

by:jamesgu
jamesgu earned 50 total points
ID: 22675197
SELECT SCN_TO_TIMESTAMP(ORA_ROWSCN) from table_name where ...
0
 

Author Comment

by:mawingho
ID: 22675219
it doesn't work........
0
 
LVL 74

Assisted Solution

by:sdstuber
sdstuber earned 200 total points
ID: 22675234
How do you define "last update time"?




the ora_rowscn suggested above shows when the commit happened,  not necessarily when the updates occured.

also note,  if the last alteration to a table was a delete, then you don't have a row for the ora_rowscn.

without logs in your application, row level auditing will give you what you want,  after that best you could do would be to go through log miner for scn estimate times.


0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 74

Assisted Solution

by:sdstuber
sdstuber earned 200 total points
ID: 22675237
note, turning auditing on doesn't help with historical timestamps, only as a go-forward solution.
0
 
LVL 74

Assisted Solution

by:sdstuber
sdstuber earned 200 total points
ID: 22675249
oh and scn_to_timestamp doesn't exist in 9i.  it was introduced in 10g.
0
 
LVL 17

Assisted Solution

by:NicksonKoh
NicksonKoh earned 50 total points
ID: 22675557
If you use TOAD, you can easily see the last DDL date on the table.
Just go to Schema Browser and click on the Tablename. You can see the table creation and last DDL information just above the tabs.
0
 
LVL 74

Assisted Solution

by:sdstuber
sdstuber earned 200 total points
ID: 22675806
last_ddl_time is when the table was last changed "structurally"  like truncate, create, alter table, etc.

It doesn't account for DML changes:  insert, update, delete
0
 
LVL 10

Assisted Solution

by:dbmullen
dbmullen earned 50 total points
ID: 22678254
it appears you're trying to "reverse engineer" some process

turn on tracing
run the program
turn off tracking
http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96533/sqltrace.htm#1018

look at the dump file.
that will show everything that program does.

if tracing isn't an option, you'll have to create an after insert or update or delete trigger on every table..

forget about trying to find what happened already.  just do it again.

0
 
LVL 29

Accepted Solution

by:
MikeOM_DBA earned 150 total points
ID: 22678311
Otherwise,
If you have "monitoring" option set, just check:

{ALL|DBA|USER}_TAB_MODIFICATIONS

SQL> desc ALL_TAB_MODIFICATIONS
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 TABLE_OWNER                                        VARCHAR2(30)
 TABLE_NAME                                         VARCHAR2(30)
 PARTITION_NAME                                     VARCHAR2(30)
 SUBPARTITION_NAME                                  VARCHAR2(30)
 INSERTS                                            NUMBER
 UPDATES                                            NUMBER
 DELETES                                            NUMBER
 TIMESTAMP                                          DATE
 TRUNCATED                                          VARCHAR2(3)
 DROP_SEGMENTS                                      NUMBER

Open in new window

0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
Messaging apps are amazing tools with the power to do a lot of good, but the truth is the process of collaborating with coworkers requires relationships established through meaningful communication - the kind of communication that only happens face-…
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question