create table public.profiles (
id uuid not null,
username text default 'Пользователь #' + рандомное и уникальное число
primary key (id)
);
CREATE SEQUENCE profiles_seq START 1;
CREATE OR REPLACE FUNCTION nextval_rand(regclass)
RETURNS text AS
$func$
BEGIN
EXECUTE format('ALTER SEQUENCE profiles_seq INCREMENT %s', (random() * 100)::int + 1);
RETURN 'Пользователь #' || nextval($1)::text;
END
$func$ LANGUAGE plpgsql SECURITY DEFINER;
create table profiles (
id uuid not null,
username text default nextval_rand('profiles_seq'::regclass),
primary key (id)
);
insert into profiles (id) values
(gen_random_uuid()),
(gen_random_uuid()),
(gen_random_uuid()),
(gen_random_uuid()),
(gen_random_uuid());
select * from profiles;