Oracle SQL: How to INSERT a SELECT statement with a GROUP BY clause on a table with IDENTITY column?

后端 未结 1 642
臣服心动
臣服心动 2021-01-18 21:22

In an application, I intend on truncating and inserting on an Oracle 12c database, but have found this issue with an IDENTITY column. Even though the INSE

相关标签:
1条回答
  • 2021-01-18 22:20

    In the Oracle Community, this question has been answered. https://community.oracle.com/message/13227544#13227544

    insert into T1 (owner_name, pet_count)
    with t as (select /*+ materialize */ owner_name, count(*) as pet_count from aux group by owner_name)
    select owner_name, pet_count from t
    

    Quoting the original answer, keep in mind the materialize hint is not documented. Thanks to all for your help!

    0 讨论(0)
提交回复
热议问题