Solved

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

Posted on 2008-10-08
9
14,434 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 73

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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 73

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 73

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 73

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

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.

Question has a verified solution.

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

"Disruption" is the most feared word for C-level executives these days. They agonize over their industry being disturbed by another player - most likely by startups.
For cloud, the “train has left the station” and in the Microsoft ERP & CRM world, that means the next generation of enterprise software from Microsoft is here: Dynamics 365 is Microsoft’s new integrated business solution that unifies CRM and ERP fun…
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.

786 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