You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Désactivation des triggers (y comprit ceux des checks de clefs étrangère) d'une table
ALTERTABLEschema.table_name DISABLE TRIGGER ALL;
-- Do your thingsALTERTABLEschema.table_name ENABLE TRIGGER ALL;
Désactivation d'un trigger en particuler
SELECT tgname,
tgtype
FROM pg_trigger
WHERE tgrelid ='<schema>.<table>'::regclass
AND tgisinternal;
-- EnsuiteALTERTABLE<schema>.<mytable> DISABLE TRIGGER "<tgname>"-- Do your thingsALTERTABLE<schema>.<mytable> ENABLE TRIGGER "<tgname>"
json
Remplacer le nom d'une clef dans un champ json/jsonb
createtableexample(id intprimary key, champ jsonb);
insert into example values
(1, '{"nme": "test"}'),
(2, '{"nme": "second test"}');
update example
set champ = champ -'nme'|| jsonb_build_object('name', champ ->'nme')
where champ ? 'nme'
returning *;
Remplacer la valeur d'une clef dans un champ json/jsonb
update example
set champs = champs -'name'|| jsonb_build_object('name', replace((champs ->>'name'),'<from>','<to>'))
where champ ? 'name'
returning *;