BetaThis is a live doc! Anyone with edit access can make updates in real time without having to publish.
CREATE FUNCTION array_distinct(anyarray) RETURNS anyarray AS $f$
SELECT array_agg(DISTINCT x) FROM unnest($1) t(x);
$f$ LANGUAGE SQL IMMUTABLE;
SELECT array_distinct(some_array_col) from "my_table";
UPDATE "my_table" SET some_array_col = array_distinct(some_array_col || ?);