Add column to an existing table?

The simplest way to populate your database with test data.

Moderators: David Atkinson, Anu Deshpande, Lionel

Add column to an existing table?

Postby jbaima » Mon Jun 14, 2010 4:14 pm

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
jbaima
 
Posts: 1
Joined: Mon Jun 14, 2010 4:08 pm

Postby james.billings » Wed Jun 16, 2010 11:25 am

Hi John,
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:

Code: Select all
SELECT *
INTO temptable
FROM sourcetable


- 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.
james.billings
 
Posts: 1144
Joined: Wed Jun 16, 2010 11:10 am
Location: My desk.


Return to SQL Data Generator 1

Who is online

Users browsing this forum: No registered users and 0 guests