tags:

views:

86

answers:

3

In Informix, I can do a select from the systables table, and can investigate its version column to see what numeric version a given table has. This column is incremented with every DDL statement that affects the given table. This means I have the ability to see whether a table's structure has changed since the last time I connected.

Is there a similar way to do this in Oracle?

+3  A: 

Not really. The Oracle DBA/ALL/USER_OBJECTS view has a LAST_DDL_TIME column, but it is affected by operations other than structure changes.

dpbradley
That may be good enough; I'm not worried so much about false positives (unless they happen so frequently that the column is essentially worthless).
Laird Nelson
Well, the non-obvious case is that grants on the table will update this column - have never understood or liked this...
dpbradley
The 'understanding' is that grants (or really REVOKE) require views, procedures, current SQLs etc to be invalidated/re-validated.
Gary
adding a new grant (which should not invalidate anything) will change the timestamp
dpbradley
+3  A: 

You can do that (and more) with a DDL trigger that keeps track of changes to tables. There's an interesting article with example here.

Pop
+2  A: 

If you really want to do so, you'd have to use Oracle's auditing functions to audit the changes. It could be as simple as:

AUDIT ALTER TABLE WHENEVER SUCCESSFUL on [schema I care about];

That would at least capture the successfuly changes, ignoring drops and creates. Unfortunately, unwinding the stack of the table's historical strucuture by mining the audit trail is left as an exercise to the reader in Oracle, or to licensing the Change Management Pack.

You could also roll your own auditing by writing system-event triggers which are invoked on DDL statements. You'd end up having to write your own SQL parser if you really wantedto see what was changing.

Adam Musch
Hi, Adam; no, all I really need to know is that a structural change occurred, or even might have occurred. I am working on augmenting the OpenJPA ReverseMappingTool and want a way to let it cache table structure since going to the database can be very time consuming. Thanks!
Laird Nelson