简体   繁体   English

如何找到上次使用的表?

[英]How to find last used table?

I have 2 Identical Oracle Tables (Table1 & Table2). 我有2个相同的Oracle表(表1和表2)。 Data insertion in both these tables are truncate and then load. 这两个表中的数据插入都将被截断然后加载。 Once the data is inserted to a table, a synonym is applied on it. 一旦将数据插入到表中,便对其应用同义词。 Also the table to be inserted for next load is found out using 此外,使用以下方法查找了要插入的表以供下次加载

SELECT   OBJECT_NAME
     INTO   var1
     FROM   (SELECT   RR.OBJECT_NAME,
                      RANK () OVER (ORDER BY RR.LAST_DDL_TIME ASC) RNK
               FROM   SYS.ALL_OBJECTS RR
              WHERE  RR.OBJECT_NAME IN
                               ('Table1', 'Table2'))
    WHERE   RNK = 1;

However I need an alternate technique for this as DDL_TIME for both these tables becomes same if we grant an access role to any user. 但是,我需要一种替代技术,因为如果我们授予任何用户访问权限,这两个表的DDL_TIME将变得相同。 Please note we cannot alter the table structure 请注意,我们无法更改表格结构

This is too long for a comment. 这个评论太长了。

You have a poor application design. 您的应用程序设计不佳。 You are using database metadata for a purpose that it is not intended for. 您将数据库元数据用于非预期目的。 If you need to keep track of things like the time when a user was granted access to a table, you should keep this information explicitly in another table, either wrapping the access control logic in a stored procedure or using a DDL trigger. 如果需要跟踪诸如授予用户访问表的时间之类的信息,则应将该信息显式保存在另一个表中,或者将访问控制逻辑包装在存储过程中,或者使用DDL触发器。

A sign that you have a problem is that DDL_TIME isn't doing what you want. 有问题的迹象是DDL_TIME并未执行您想要的操作。 This column is doing what it is documented to do and presumably what the database needs it to do. 本专栏正在做它所记录的事情,大概是数据库需要它做的事情。 The shortcoming is your re-interpretation of it. 缺点是您对它的重新解释。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM