My Google Searching skills were not enough to find a solution to this. If possible, how can I promote a partition on a table to a table on its own?
Let's assume I have part0
, part1
, and part2
. Is there any ALTER TABLE
that I can give that converts part0
to a new table?
My thought process was, since the data is already existing in a separate file on disk, the table creation process may be faster than creating a new table using a SELECT
query.
Best Answer
You do not need
SELECT
. This can be done with pure DDL.For this example, let say the partitioned table is as follows:
mydb
mytable
part0
,part1
,part2
)This can be tricky but here is goes
What this does is first make
mynewtable
without any partitions and the same schema in all other aspects. Then, it swaps themynewtable
table withpart0
.If you are not sure of this, then run
Examine the rows in
mynewtable
and the newpart0
and make suremynewtable
has the data from the originalpart0
part0
should be emptyOnce you are sure the transposition worked then run
Please test this in a lab or sqlfiddle. GIVE IT A TRY !!!