WarWik
WarWik

Reputation: 43

ALTER TABLE with Large number of rows

I have an sales table with millions of records and I want to extend it with a new field. I know ALTER TABLE would certainly lead never ending process. Is there a faster way to do this?

Upvotes: 2

Views: 1450

Answers (1)

Mahesh Madushanka
Mahesh Madushanka

Reputation: 3008

Create table TEMP_TABLE WITH similer to your old table with additional column

INSERT INTO TAMP_TABLE (SELECT * FROM TABLE);

DROP TABLE OLD_TABLE;

RENAME TABLE TEMP_TABLE TO OLD_TABLE_NAME;

Upvotes: 2

Related Questions