Add column to an existing table?
jbaima
Posts: 2
I have a table with some real data but I would like to add several new columns to that table. So, can I have the program keep existing columns and then just fill in the new, selected columns?
After a certain point, it is quite inconvenient to have to drop/truncate what is there and completely regenerate the table.
Thanks!
-John
After a certain point, it is quite inconvenient to have to drop/truncate what is there and completely regenerate the table.
Thanks!
-John
Comments
This feature is something that has been asked for previously, and will hopefully make it in to a future release of the product.
For now, there is a workaround that may be of use to you:
- Add your new column(s)
- Create a copy of the table you are interested in using something along the lines of:
- In SQL Data Generator, choose the option to "Use Existing data source" for the table you are working with. Source Type is "SQL Table or View", and the Source is the copy you made (temptable in the above example)
- Expand the table in the tree on the left, and for the new columns, select the generator you wish to use.
- Confirm the other columns are correctly referring to the source temp table.
- With the table itself selected on the left, ensure you have "Same as mapped data" set in the Specify number of rows box.
- You still need to have "Delete data from table before generation" ticked, otherwise you will just get twice the number of records (or it will fail with duplicate keys) and you may also need to temporarily remove foreign key constraints if it warns you the delete could fail.
Hopefully the above will achieve the effect you are after, but if not, please feel free to contact support.
James.
Redgate Software