rhurlin (9) [Avatar] Offline
#1
In chapter 1.5.1 after copying 'fastfoods.csv' into the database a primary key is created with

ALTER TABLE ch01.fastfoods ADD COLUMN ff_id SERIAL PRIMARY KEY;

The same line should then be executed a second time, see chapter 1.5.2 after the vacuum and before adding constraints. Because the column is already in the database, it reacts with an error:

NOTICE: ALTER TABLE will create implicit sequence "fastfoods_ff_id_seq1" for serial column "fastfoods.ff_id"
ERROR: column "ff_id" of relation "fastfoods" already exists

Do I miss something here or is only the first line in 1.5.1 needed to create this column with the primary key?

Rainer
regina.leo (265) [Avatar] Offline
#2
Re: [CH01] 1.5 Primary key is created twice?
Rainier,

Good catch. The second ALTER TABLE .. ADD COLUMN is unnecessary. Well we probably should have left out the first one since the second one is more explanatory of why you need it.

Thanks,
Leo