Excellent news, byo !!!!!
Printable View
Excellent news, byo !!!!!
Thank you. If all goes well the first RC (release candidate) will be out tomorrow. :)
Dunno if it was already mentioned, but a basic workaround for the lack of ALTER TABLE is this:
Suppose our current table is 'People' with columns 'narf' and 'fwip'
Create a new table called 'temp_People', with the same columns.
CREATE TABLE temp_People (narf, fwip)
Now copy over the contents of 'People' into this new table.
INSERT INTO temp_People(narf, fwip) SELECT * FROM People
Now kill the original 'People' table.
DROP TABLE People
Now create a new table, once again named 'People'.
It needs the same columns as the original, but also a new one.
We'll call the new one 'newcol'.
CREATE TABLE People (narf, fwip, newcol)
Now we copy across the values from 'temp_People', like-a-da-so:
(Make sure to specify that we're copying into the two columns narf and fwip, as done here)
INSERT INTO People(narf, fwip) SELECT * FROM temp_People
Now drop the copy (temp_People), as it has now fulfilled its purpose.
DROP TABLE temp_People
Voila! All done! You can string these together in one string like this:
CREATE TABLE temp_People (narf, fwip);
INSERT INTO temp_People(narf, fwip) SELECT * FROM People;
DROP TABLE People;
CREATE TABLE People (narf, fwip, newcol);
INSERT INTO People(narf, fwip) SELECT * FROM temp_People;
DROP TABLE temp_People;
It's pretty quick, and it works. You can alter it to give new columns a default value and stuff too.
Yes, cool example, Dines. This is in a case you want to add a new column. If you want to drop a certain column you do:
--Suppose the table People has three fields: narf, fwip, code
--Removing field code.
CREATE TABLE temp_People (narf, fwip);
INSERT INTO temp_People(narf, fwip) SELECT narf, fwip FROM People;
DROP TABLE People;
CREATE TABLE People (narf, fwip);
INSERT INTO People(narf, fwip) SELECT * FROM temp_People;
DROP TABLE temp_People;