Wednesday, October 31, 2012

Fast data copy with “Create Table Select From” in PL/SQL



 tried creating temp table normally and copied the data using normal INSERT INTO SELECT query:
INSERT INTO TA
SELECT * FROM A
This approach took a lot of time to execute.
Then I tried creating same temp table with different syntax. I tried CREATE TABLE SELECT FROM syntax of PL SQL for creating as well as copying the data into temp table:
CREATE TABLE TA
AS
SELECT * FROM A
The second approach was amazingly fast. The above sql can be generalized to create table as follow:
CREATE TABLE new_table_name [ ( column [, ...] ) ]
AS
SELECT [ ( column [, ...] ) ] FROM existing table_name

No comments:

Post a Comment