I'm building a database and making my table creates in a text file so that,
if I want to recreate my database, I can just rerun the scripts.
At the top of the script are the statements to drop the tables. Next is the
area which creates the tables.
The problem I am encountering is with having a primary key labeled as
serial. Do I have to drop the sequence also to be able to recreate the
table? Omitting the sequence drop did not seem to allow the creation of the
table with a serial, but when I added a drop sequence, the table creates
fine in the script. Am I assuming correctly?
If that is correct, what if I go a step farther and have data dumped from
the table before it is dropped. Won't my sequence be screwed up if I drop
it and then reimport the data? Would the sequence technically be back at 1
and if I have 100 records, will it try to insert duplicate data?
If that is true, what would be the solution? Create the sequence manually,
don't drop the sequence in the script, and have the create table script not
as a SERIAL, but have it set to a default value of the sequence?
Adam Lang
Systems Engineer
Rutgers Casualty Insurance Company