【问题标题】:ORA-14450 GTT alter table issueORA-14450 GTT 更改表问题
【发布时间】:2021-01-13 06:27:47
【问题描述】:

我在更改 GTT 表时遇到问题。

我需要找到该表上的活动用户,有人可以帮忙查询如何在 oracle 数据库中的特定对象上找到活动用户

【问题讨论】:

    标签: oracle ddl alter-table global-temp-tables


    【解决方案1】:

    据我所知,您并没有解释您要解决什么问题,而是解释了您认为可能会帮助您解决什么问题。所以,让我猜猜。

    这是一个全局临时表 (GTT):

    SQL> create global temporary table gtt (id number) on commit preserve rows;
    
    Table created.
    
    SQL> insert into gtt values (1);
    
    1 row created.
    
    SQL> commit;
    
    Commit complete.
    

    你试图改变它,但是 - 它失败了:

    SQL> alter table gtt add name varchar2(10);
    alter table gtt add name varchar2(10)
    *
    ERROR at line 1:
    ORA-14450: attempt to access a transactional temp table already in use
    

    好的,所以 - 删除行并提交,然后重试:

    SQL> delete from gtt;
    
    1 row deleted.
    
    SQL> commit;
    
    Commit complete.
    
    SQL> alter table gtt add name varchar2(10);
    alter table gtt add name varchar2(10)
    *
    ERROR at line 1:
    ORA-14450: attempt to access a transactional temp table already in use
    

    仍然没有运气。但是,如果您截断表格,那么它有效

    SQL> truncate table gtt;
    
    Table truncated.
    
    SQL> alter table gtt add name varchar2(10);
    
    Table altered.
    
    SQL>
    

    如果这不是您所追求的,那么看看这是否回答了您的问题:以特权用户身份连接(例如 SYS,如果您没有其他用户)并运行这样的查询:它显示谁拥有GTT,它的名字,谁锁定它(哪个 Oracle 用户)以及它是哪个操作系统用户(这可能有助于您联系这些人):

    SQL> select b.owner,
      2         b.object_name,
      3         a.oracle_username,
      4         a.os_user_name
      5    from v$locked_object a, dba_objects b
      6   where a.object_id = b.object_id;
    
    OWNER           OBJECT_NAM ORACLE_USERNAME OS_USER_NAME
    --------------- ---------- --------------- ------------------------------
    SCOTT           GTT        SCOTT           littlefoot
    
    SQL>
    

    【讨论】:

      猜你喜欢
      • 2012-09-09
      • 1970-01-01
      • 1970-01-01
      • 2014-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多