CREATE OR REPLACE FUNCTION random_text(n_length INTEGER default 50) RETURNS TEXT LANGUAGE SQL AS $$ select string_agg(substr(characters, (random() * length(characters) + 0.5)::integer, 1), '') as random_word from (values('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-')) as symbols(characters) -- length of word join generate_series(1, n_length) on 1 = 1; $$;
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter