Hi everyone,

I have a DB migration question. I have a table called "employees" and it has a 
UNIQUE constraint on "employee_email". With some new features being requested, 
I need to relax the constraint and have a new constraint on "employee_email" + 
"employee_number". Since SQLite ALTER table command can't modify an existing 
constraint, I have thought about creating a new table with the new constraint 
and then copying everything from old table to new table and afterwards dumping 
the old table. It does work but my question is what is the fastest and most 
memory efficient way to copy data from old table to new table?

Currently we are using:

sql = "INSERT INTO {} SELECT * FROM {}".format(totable, fromtable)
cur.execute(sql) 

So, a single line statement can copy from old to new. But will this work fine 
even if I have 100s of thousands of records in old table? Or will this load 
pretty much entire data into memory and then copy to new?
Looking for other optimal ways to copy data from one table to another if this 
is not optimal.

Thanks,
Vikas

_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to