<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>fixlinux.com &#187; PostgreSQL</title>
	<atom:link href="http://fixlinux.com/category/postgresql/feed/" rel="self" type="application/rss+xml" />
	<link>http://fixlinux.com</link>
	<description>security + stability = sanity</description>
	<lastBuildDate>Wed, 07 Dec 2011 04:03:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>randomize timestamp in postgresql</title>
		<link>http://fixlinux.com/2009/12/21/randomize-timestamp-in-postgresql/</link>
		<comments>http://fixlinux.com/2009/12/21/randomize-timestamp-in-postgresql/#comments</comments>
		<pubDate>Mon, 21 Dec 2009 19:52:44 +0000</pubDate>
		<dc:creator>derek</dc:creator>
				<category><![CDATA[PostgreSQL]]></category>

		<guid isPermaLink="false">http://fixlinux.com/2009/12/21/randomize-timestamp-in-postgresql/</guid>
		<description><![CDATA[The following may be useful for test data or if you need to get data into a table that has a timestamp column included in the primary key requirement. Create a function that will allow you to specify a random number range (taken from the http://wiki.postgresql.org/wiki/Random_Range): CREATE OR REPLACE FUNCTION random(numeric, numeric RETURNS numeric AS [...]]]></description>
			<content:encoded><![CDATA[<p>The following may be useful for test data or if you need to get data into a table that has a timestamp column included in the primary key requirement.</p>
<p>Create a function that will allow you to specify a random number range (taken from the <a title="PostgreSQL Wiki" href="http://wiki.postgresql.org/wiki/Random_Range">http://wiki.postgresql.org/wiki/Random_Range</a>):</p>
<pre>CREATE OR REPLACE FUNCTION random(numeric, numeric
RETURNS numeric AS $$
SELECT ($1 + ($2 - $1) * random())::numeric;
$$ LANGUAGE 'sql' VOLATILE;</pre>
<p>I then used it to generate a range of timestamps for today:</p>
<pre>select timestamp '2009-12-21' + random(0,86400) * interval '1 second' as timestamp;</pre>
]]></content:encoded>
			<wfw:commentRss>http://fixlinux.com/2009/12/21/randomize-timestamp-in-postgresql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

