ALTER TABLE vs DROP/CREATE statements
324137Dec 20 2005 — edited Dec 21 2005Hello Everyone,
I have created a script in order to update our database which includes adding new columns to a table. However, database changes and script generation must now be done using the Erwin data modeler and script generated using a compare option (within Erwin) which compares the model with the actual database.
I had a script of a few lines with a few ALTER TABLE ...ADD COLUMN statements to add the new columns.
Now, in Erwin, instead of generating 'ALTER TABLE...ADD COLUMN statements, Erwin has generated an ALTER TABLE...RENAME and CREATE TABLE statements which as a side effect will drop/re-create the table, all of it's indexes, constraints, foreign keys, etc.
Instead of a few simple "hand written" lines to run a fast script, the script is a few pages long with all of those DROP/CREATE statements, which makes the script way too much complicated and takes much longer to run.
And this, even though the Erwin option "USE ALTER TABLE ADD COLUMN" statement to create columns.
I was told that the DROP/CREATE is normal and that this is the way it should be done.
Am I out of it by thinking that it should use ALTER TABLE ADD COLUMN statements to add new columns to a table and not the DROP/CREATE methodology ? Am I missing something ? Do these new "data thinkers" know something that I am missing ?
Makes me think of the 80s when people were generating dBase application with the included application generator and were ending up with all kinds of useless and non efficient code.
Any though on this ? Am I out in the field ?
Thank you.