<?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>random() &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/random/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dbrnd.com</link>
	<description>BIGData &#124; NoSQL &#124; MSSQL &#124; MySQL &#124; PostgreSQL</description>
	<lastBuildDate>Thu, 16 Nov 2017 13:18:07 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.4</generator>
	<item>
		<title>PostgreSQL: How to generate a Random Token String?</title>
		<link>https://www.dbrnd.com/2016/04/postgresql-how-to-generate-a-random-token-string/</link>
					<comments>https://www.dbrnd.com/2016/04/postgresql-how-to-generate-a-random-token-string/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Fri, 22 Apr 2016 21:33:16 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[plpgsql]]></category>
		<category><![CDATA[Postgres Query]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[PostgreSQL Administrator]]></category>
		<category><![CDATA[PostgreSQL Error]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<category><![CDATA[random token string]]></category>
		<category><![CDATA[random()]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=1845</guid>

					<description><![CDATA[In this post, I am sharing different scripts for generating a random string in PostgreSQL. Sometimes, we need to generate a random token and any other random code in the Database System. The PostgreSQL Provides a random() function to generate a random string with all the possible different numbers, character and symbol. We can also [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F04%2Fpostgresql-how-to-generate-a-random-token-string%2F&amp;linkname=PostgreSQL%3A%20How%20to%20generate%20a%20Random%20Token%20String%3F" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F04%2Fpostgresql-how-to-generate-a-random-token-string%2F&amp;linkname=PostgreSQL%3A%20How%20to%20generate%20a%20Random%20Token%20String%3F" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F04%2Fpostgresql-how-to-generate-a-random-token-string%2F&amp;linkname=PostgreSQL%3A%20How%20to%20generate%20a%20Random%20Token%20String%3F" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F04%2Fpostgresql-how-to-generate-a-random-token-string%2F&amp;linkname=PostgreSQL%3A%20How%20to%20generate%20a%20Random%20Token%20String%3F" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F04%2Fpostgresql-how-to-generate-a-random-token-string%2F&amp;linkname=PostgreSQL%3A%20How%20to%20generate%20a%20Random%20Token%20String%3F" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F04%2Fpostgresql-how-to-generate-a-random-token-string%2F&amp;linkname=PostgreSQL%3A%20How%20to%20generate%20a%20Random%20Token%20String%3F" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F04%2Fpostgresql-how-to-generate-a-random-token-string%2F&#038;title=PostgreSQL%3A%20How%20to%20generate%20a%20Random%20Token%20String%3F" data-a2a-url="https://www.dbrnd.com/2016/04/postgresql-how-to-generate-a-random-token-string/" data-a2a-title="PostgreSQL: How to generate a Random Token String?"></a></p><p>In this post, I am sharing different scripts for generating a random string in PostgreSQL. </p>
<p>Sometimes, we need to generate a random token and any other random code in the Database System. </p>
<blockquote><p>The PostgreSQL Provides a random() function to generate a random string with all the possible different numbers, character and symbol.<br />
We can also use random() function with cryptography or encryption function to generate a fixed length binary string.
</p></blockquote>
<p><strong>Generate a random string using MD5():</strong></p>
<pre class="crayon-plain-tag">SELECT MD5(random()::text);

/* Result:
md5
text
-------------------------------------
5815789cc68c2c4a8a46e31c72f0a327
*/</pre> </p>
<p><strong>Generate a Capital Latter random string, size of 15:</strong></p>
<pre class="crayon-plain-tag">SELECT array_to_string(ARRAY(SELECT chr((65 + round(random() * 25)) :: integer) 
FROM generate_series(1,15)), '');

/* Result:
array_to_string
text
-------------------
ZPGVXSNNTWFBMDY
*/</pre> </p>
<p><strong>Generate a Small Latter random string, size of 15:</strong></p><pre class="crayon-plain-tag">SELECT array_to_string(ARRAY(SELECT chr((97 + round(random() * 25)) :: integer) 
FROM generate_series(1,15)), '');

/* Result:
array_to_string
text
-----------------
ohmqjtxxqbtqinq
*/</pre><p> </p>
<p><strong>Generate a Numerical random string, size of 15:</strong></p><pre class="crayon-plain-tag">SELECT array_to_string(ARRAY(SELECT chr((48 + round(random() * 9)) :: integer) 
FROM generate_series(1,15)), '');

/* Result:
array_to_string
text
-----------------
132443402808481
*/</pre><p> </p>
<p><strong>Generate a random string with all combinations, size of 15:</strong></p><pre class="crayon-plain-tag">SELECT array_to_string(ARRAY(SELECT chr((48 + round(random() * 59)) :: integer) 
FROM generate_series(1,15)), '');

/* Result:
array_to_string
text
-----------------
`E07<k6@7RKS@CL
*/</pre><p> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2016/04/postgresql-how-to-generate-a-random-token-string/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
	</channel>
</rss>
