SQL query to make a table instead of view

1767 views sql
-4

I have the following definition for a view in AQT(Advanced Query Tool), and I want to convert it to a table instead. How do i do that?

View definition

SELECT TIDSPUNKT,QUEUE,ANTAL_KALD,ANTAL_BESVARET,CALLBACK,TABTE_KALD,BESVARET_25_SEK,GNS_VENT,INTERN_KALD FROM KS_DRIFT.V_CTIR_SEAGATE_KS_SPECIFIC where TIDSPUNKT>= '2018-04-02'
 UNION ALL
 SELECT TIDSPUNKT,QUEUE,ANTAL_KALD,ANTAL_BESVARET,CALLBACK,TABTE_KALD,BESVARET_25_SEK,GNS_VENT,INTERN_KALD FROM PERO_NKM_KØ_OVERSIGT where TIDSPUNKT between trunc(sysdate-756) and '2018-04-01'

answered question

What's wrong with a view? Usually you shouldn't store same data twice.

I need to do a Delete operation on soem of the data, which is not possible on the view.

You have two tables, and want to copy some of the data from those to tables to another table, where you delete it?

You could write an INSTEAD OF trigger over the view which executes the delete statements.

1 Answer

9

You can use insert into select from like below:

First create a table with your desired columns and then execute following

Insert into tablename(col1,col2,col2,col4,....)
     SELECT TIDSPUNKT,QUEUE,ANTAL_KALD,ANTAL_BESVARET,CALLBACK,TABTE_KALD,BESVARET_25_SEK,GNS_VENT,INTERN_KALD FROM KS_DRIFT.V_CTIR_SEAGATE_KS_SPECIFIC where TIDSPUNKT>= '2018-04-02'
     UNION ALL
     SELECT TIDSPUNKT,QUEUE,ANTAL_KALD,ANTAL_BESVARET,CALLBACK,TABTE_KALD,BESVARET_25_SEK,GNS_VENT,INTERN_KALD FROM PERO_NKM_KØ_OVERSIGT where TIDSPUNKT between trunc(sysdate-756) and '2018-04-01'

posted this

Have an answer?

JD

Please login first before posting an answer.