In PostgreSQL I need to refactor a table (Purchases); it has a foreign key to another table (Shop). Instead I want two fields that keep the relatio
Your seem to go the wrong way. Your original, normalized schema is typically superior. If you need to display shop / user, create a VIEW.
But you may have your reasons, so here goes:
UPDATE purchases p
SET (shop, shop_user) = (s.name, s."user")
FROM shop s
WHERE s.id = p.shop_id;
Don't use the reserved word "user" as identifier.
And "name" is hardly ever a good name, either.
And varchar(255) in Postgres typically indicates a misunderstanding.
varchar(255)