On Thursday 08 February 2007 09:19, Bryce Nesbitt wrote: > > > > INSERT INTO mytable SELECT * FROM mytable WHERE pk = 123; > > > > Or something close to that... I suspect if you changed the '*' to the > > columns you wanted you could also work in the other columns you want > > to change as well... > > But that will violate the unique primary key constraint: > > insert into xx_plan_rule select * from xx_plan_rule where rule_id=9; > ERROR: duplicate key violates unique constraint "xx_plan_rule_pkey"
It will, because you are copying all columns, including the pk. Try: INSERT INTO mytable (colname_1, colname_2, colname_3) SELECT (colname_1, colname_2, colname_3) FROM mytable WHERE pk = 123; BR, -- Aarni Ruuhimäki ---------------------------(end of broadcast)--------------------------- TIP 2: Don't 'kill -9' the postmaster