If you want to dummy up a bunch of data in PostgreSQL you can use this neat little trick
create table test (a int); insert into test (select generate_series(0,999,1)); INSERT 0 1000
Knowledge Breeds Fear
If you want to dummy up a bunch of data in PostgreSQL you can use this neat little trick
create table test (a int); insert into test (select generate_series(0,999,1)); INSERT 0 1000
I frequently find the need to have single quoted output when i generate dynamic SQL.
It's always a pain to remember the exact number of ticks needed to get the quoted output.
Here is a reminder on how to do it:
select ''''||schemaname||'.'||tablename||'''' from pg_tables
4 quotes when there's no text, or 3 quotes on the outside and one on the inside when there is text.
select '''public.'||tablename||''';' from pg_tables
Random Database, OS or otherwise interesting tips and tricks.