From PostgreSQL wiki
Jump to: navigation, search

We discussed creating random data to fill a database that is to be used as an example.

Some useful queries for generating random data:

select random() from generate_series(1,3); -- Generates random numbers select (array[...])[random() * nelems + 1]; -- Selects random elements from an array select now() - ‘1 year ago’::interval * random() -- Gives you random dates over the last year select uuid_generate_v4(); -- Generates a uuid

To affect a random subset of your rows, update where random() < 0.3 for example

We then decided it would be useful to have a sample database available for public consumption. There is already one example database available at github.com/pgexperts/librec, but we wanted one that implemented a lot more PostgreSQL features and had lots of random data in it. We could make one that would be used to store data about PGCon.

Demo database needs: hstore full text search range type auditing tables foreign keys views roles spatial data functional indexes array constraint partitions listen/notify

The start of this project is available on github at: https://github.com/pvh/postgresql-sample-database

Lastly, we also discussed the desire for an extension for plotting and graphing data visually called e.g. pg_graph. One example function it might provide is something to plot x,y points using ascii art.