English 中文(简体)
CTE 加入
原标题:CTE With Insert In Oracle

i am running a query in oracle with CTE. When i execute the query it works fine in select statement but when i use insert statement it takes ample of time to execute.Any help here is the code

INSERT INTO port_weeklydailypricesTest (co_code,start_dtm,end_dtm)
   SELECT * FROM
        (
            WITH CTE(co_code, start_dtm, end_dtm) AS
            (
                SELECT co_code                                                     ,
                CAST(NEXT_DAY(MIN(dlyprice_date), FRIDAY )-6  AS DATE)   start_dtm ,
                CAST(NEXT_DAY(MIN(dlyprice_date), FRIDAY ) AS DATE)      end_dtm
                FROM   feed_dlyprice
                GROUP BY co_code
                UNION ALL
                SELECT  co_code     ,
                CAST(TO_CHAR(end_dtm + INTERVAL  1  DAY, DD-MON-YYYY ) AS DATE),
                CAST(TO_CHAR(end_dtm + INTERVAL  7  DAY, DD-MON-YYYY ) AS DATE)
                FROM    CTE
                WHERE   CAST(end_dtm AS DATE) <= TO_CHAR(TO_DATE(SYSDATE+1, DD-MON-YYYY ))
             )
            SELECT co_code,start_dtm,end_dtm 
            FROM CTE
        );
问题回答

如你所说,如果选任考试委员会本身的工作表现令人满意,则问题必须归于专家审评组。

某些事情可能会导致插入速度缓慢:

  • The most likely is the presence of a trigger on the target table which executes something very expensive.
  • Another possibility is that the insert is waiting on a locked resource (say some other process has an exclusive table level lock on the target table, or some other shared resource such as a code control table).
  • it could be a storage allocation issue, chaining or row migration, too many indexes or lots of derived columns.
  • perhaps it is down to hardware - underpowered network, dodgy interconnects, a bad disk.

这绝不是详尽的。 这些项目是你能够调查和解决的申请问题。 名单上的各位越多越好,你就越需要现场的德国统计局的援助。





相关问题
Export tables from SQL Server to be imported to Oracle 10g

I m trying to export some tables from SQL Server 2005 and then create those tables and populate them in Oracle. I have about 10 tables, varying from 4 columns up to 25. I m not using any constraints/...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

How to make a one to one left outer join?

I was wondering, is there a way to make a kind of one to one left outer join: I need a join that matches say table A with table B, for each record on table A it must search for its pair on table B, ...

Insert if not exists Oracle

I need to be able to run an Oracle query which goes to insert a number of rows, but it also checks to see if a primary key exists and if it does, then it skips that insert. Something like: INSERT ALL ...

How can I store NULLs in NOT NULL field?

I just came across NULL values in NOT-NULL fields in our test database. How could they get there? I know that NOT-NULL constraints can be altered with NOVALIDATE clause, but that would change table s ...

Type reference scope

I m studying databases and am currently working on a object-relational DB project and I ve encountered a small problem with the number of possible constraints in an object table. I m using "Database ...

OracleParameter and DBNull.Value

we have a table in an Oracle Database which contains a column with the type Char(3 Byte). Now we use a parameterized sql to select some rows with a DBNull.Value and it doesn t work: OracleCommand ...

热门标签