I have a table like this
`articles`
id: int
data: timestamp
body: varchar
for some reason, I want to split this table into 2 separate tables:
`articles`
id: int
data: timestamp
`article_body`
id: int
article_id: foreign key
body
I can easily achieve that after creating the article_body
table by the following statement:
INSERT INTO article_body (article_id, body)
select id, body
from articles;
and then drop body
from articles
and it's really good if you have a few rows. But in a special case when your table has many rows say 100 million rows it may take hours.
One way is to do that with some other program like python and run concurrent statements with offset, but I want to know is there a way to it faster inside SQL.
As I said in question I'm using PostgreSQL.
article_id
column as both the FK and the PK - removing theid
column fromarticle_body
.