<?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>cross database query &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/cross-database-query/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>Mon, 02 Apr 2018 19:16:28 +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: Should we create Multiple Databases OR create Multiple Schemas?</title>
		<link>https://www.dbrnd.com/2016/07/postgresql-should-we-create-multiple-databases-or-create-multiple-schemas-into-one-database/</link>
					<comments>https://www.dbrnd.com/2016/07/postgresql-should-we-create-multiple-databases-or-create-multiple-schemas-into-one-database/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 25 Jul 2016 20:15:12 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[cross database query]]></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[schema]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=1841</guid>

					<description><![CDATA[This title looks like a very basic topic, but this is one of the most important topics for PostgreSQL database professionals. I have observed that most of the new PostgreSQL users are creating multiple databases into PostgreSQL Server which is not wrong We all have common practice for creating multiple databases for the different purpose [&#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%2F07%2Fpostgresql-should-we-create-multiple-databases-or-create-multiple-schemas-into-one-database%2F&amp;linkname=PostgreSQL%3A%20Should%20we%20create%20Multiple%20Databases%20OR%20create%20Multiple%20Schemas%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%2F07%2Fpostgresql-should-we-create-multiple-databases-or-create-multiple-schemas-into-one-database%2F&amp;linkname=PostgreSQL%3A%20Should%20we%20create%20Multiple%20Databases%20OR%20create%20Multiple%20Schemas%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%2F07%2Fpostgresql-should-we-create-multiple-databases-or-create-multiple-schemas-into-one-database%2F&amp;linkname=PostgreSQL%3A%20Should%20we%20create%20Multiple%20Databases%20OR%20create%20Multiple%20Schemas%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%2F07%2Fpostgresql-should-we-create-multiple-databases-or-create-multiple-schemas-into-one-database%2F&amp;linkname=PostgreSQL%3A%20Should%20we%20create%20Multiple%20Databases%20OR%20create%20Multiple%20Schemas%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%2F07%2Fpostgresql-should-we-create-multiple-databases-or-create-multiple-schemas-into-one-database%2F&amp;linkname=PostgreSQL%3A%20Should%20we%20create%20Multiple%20Databases%20OR%20create%20Multiple%20Schemas%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%2F07%2Fpostgresql-should-we-create-multiple-databases-or-create-multiple-schemas-into-one-database%2F&amp;linkname=PostgreSQL%3A%20Should%20we%20create%20Multiple%20Databases%20OR%20create%20Multiple%20Schemas%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%2F07%2Fpostgresql-should-we-create-multiple-databases-or-create-multiple-schemas-into-one-database%2F&#038;title=PostgreSQL%3A%20Should%20we%20create%20Multiple%20Databases%20OR%20create%20Multiple%20Schemas%3F" data-a2a-url="https://www.dbrnd.com/2016/07/postgresql-should-we-create-multiple-databases-or-create-multiple-schemas-into-one-database/" data-a2a-title="PostgreSQL: Should we create Multiple Databases OR create Multiple Schemas?"></a></p><p>This title looks like a very basic topic, but this is one of the most important topics for PostgreSQL database professionals. </p>
<p><em>I have observed that most of the new PostgreSQL users are creating multiple databases into PostgreSQL Server which is not wrong<br />
</em></p>
<blockquote><p>We all have common practice for creating multiple databases for the different purpose of the project.<br />
But in the PostgreSQL server, we should create multiple schemas instead of multiple databases. </p></blockquote>
<p><strong>I recommended 1-database many-schemas approach for the PostgreSQL Server because cross database queries is very costly in PostgreSQL. </strong></p>
<blockquote><p>In the Microsoft SQL Server, we are creating different databases and we can also execute query between multiple databases by specifying a database name.<br />
But this is not possible with the PostgreSQL. </p></blockquote>
<p><a href="https://www.dbrnd.com/2015/05/postgresql-cross-database-queries-using/" target="_blank"><strong><code>For more details, You can visit this article of cross database queries in PostgreSQL. </code></strong></a></p>
<blockquote><p>The Schemas in PostgreSQL are a lot like packages in Oracle. A number of schemas should be more lightweight than a number of databases. </p></blockquote>
<blockquote><p>We require to take a backup of the only single database, including all schemas. We can also add or remove particular schema during the backup or restore operation. </p></blockquote>
<blockquote><p>We can also create different database permission groups &#038; roles for each and every different schema so that we can control the access of database user.</p></blockquote>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2016/07/postgresql-should-we-create-multiple-databases-or-create-multiple-schemas-into-one-database/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>PostgreSQL [Video]: Cross Database Queries using DbLink Extension</title>
		<link>https://www.dbrnd.com/2015/05/postgresql-cross-database-queries-using/</link>
					<comments>https://www.dbrnd.com/2015/05/postgresql-cross-database-queries-using/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Fri, 22 May 2015 16:37:08 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[PostgreSQL Video]]></category>
		<category><![CDATA[Video Help]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[connection]]></category>
		<category><![CDATA[cross database query]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dblink]]></category>
		<category><![CDATA[dblink_connect]]></category>
		<category><![CDATA[foreign data wrapper]]></category>
		<category><![CDATA[plpgsql]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[PostgreSQL Administrator]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=184</guid>

					<description><![CDATA[How we can perform cross database queries in PostgreSQL? The different RDBMS systems like Microsoft SQL Server, MySQL, You can select data from one database to another database. What we are doing is we simply select data using database_name.schema.table. In the PostgreSQL, you cannot perform the cross database query like other database technology. In this [&#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%2F2015%2F05%2Fpostgresql-cross-database-queries-using%2F&amp;linkname=PostgreSQL%20%5BVideo%5D%3A%20Cross%20Database%20Queries%20using%20DbLink%20Extension" 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%2F2015%2F05%2Fpostgresql-cross-database-queries-using%2F&amp;linkname=PostgreSQL%20%5BVideo%5D%3A%20Cross%20Database%20Queries%20using%20DbLink%20Extension" 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%2F2015%2F05%2Fpostgresql-cross-database-queries-using%2F&amp;linkname=PostgreSQL%20%5BVideo%5D%3A%20Cross%20Database%20Queries%20using%20DbLink%20Extension" 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%2F2015%2F05%2Fpostgresql-cross-database-queries-using%2F&amp;linkname=PostgreSQL%20%5BVideo%5D%3A%20Cross%20Database%20Queries%20using%20DbLink%20Extension" 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%2F2015%2F05%2Fpostgresql-cross-database-queries-using%2F&amp;linkname=PostgreSQL%20%5BVideo%5D%3A%20Cross%20Database%20Queries%20using%20DbLink%20Extension" 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%2F2015%2F05%2Fpostgresql-cross-database-queries-using%2F&amp;linkname=PostgreSQL%20%5BVideo%5D%3A%20Cross%20Database%20Queries%20using%20DbLink%20Extension" 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%2F2015%2F05%2Fpostgresql-cross-database-queries-using%2F&#038;title=PostgreSQL%20%5BVideo%5D%3A%20Cross%20Database%20Queries%20using%20DbLink%20Extension" data-a2a-url="https://www.dbrnd.com/2015/05/postgresql-cross-database-queries-using/" data-a2a-title="PostgreSQL [Video]: Cross Database Queries using DbLink Extension"></a></p><p><iframe width="849" height="478" src="https://www.youtube.com/embed/-vk712oS0VM?feature=oembed" frameborder="0" gesture="media" allowfullscreen></iframe></p>
<p><strong>How we can perform cross database queries in PostgreSQL?</strong></p>
<blockquote><p>The different RDBMS systems like Microsoft SQL Server, MySQL, You can select data from one database to another database. What we are doing is we simply select data using database_name.schema.table.<br />
In the PostgreSQL, you cannot perform the cross database query like other database technology.</p></blockquote>
<p>In this post, I am going to demonstrate DbLink extension of PostgreSQL which is used to connect one database to another database.</p>
<blockquote><p>Using DbLink extension, you can perform cross database queries in the PostgreSQL.</p></blockquote>
<p>In this demonstration, I have created two different databases. Respective names &#8220;Database_One&#8221; and &#8220;Database_Two&#8221;.</p>
<blockquote><p>I created one sample table into &#8220;Database_One&#8221; and using DbLink, going to SELECT this table from &#8220;Database_Two&#8221;.<br />
Now, We have to configure DbLink extension in &#8220;Database_Two&#8221;.</p></blockquote>
<p><strong>Below is a full demonstration of this:</strong><br />
<strong>Step 1: Create First sample table and database:</strong></p><pre class="crayon-plain-tag">CREATE DATABASE Database_One;

CREATE TABLE public.tbl_Employee
(
	EmpID INT PRIMARY KEY
	,EmpName CHARACTER VARYING
	,EmpGender CHAR(1)
);

INSERT INTO public.tbl_Employee
VALUES
(1,'Anvesh','M')
,(2,'Neevan','M')
,(3,'Martin','M');</pre><p>
<strong>Step 2: Create Second sample table and database:<br />
</strong></p><pre class="crayon-plain-tag">CREATE DATABASE Database_Two;</pre><p>
<strong>Now, I am going to SELECT Databasee_One data from Database_Two so we have to execute all below scripts on Database_Two to configure DbLink extension for cross database queries.</strong></p>
<hr />
<p><strong>Step 1: Connect to Database_Two:</strong></p>
<p><strong>Step 2: Install / Create DBLink Extenstion:</strong></p><pre class="crayon-plain-tag">CREATE EXTENSION dblink;</pre><p>
<p><strong>Step 3: Verify the system tables of DBLink:</strong></p><pre class="crayon-plain-tag">SELECT pg_namespace.nspname, pg_proc.proname 
FROM pg_proc, pg_namespace 
WHERE pg_proc.pronamespace=pg_namespace.oid 
   AND pg_proc.proname LIKE '%dblink%';</pre><p>
<p><strong>Step 4: Test the connection for Database_One:</strong></p>
<pre class="crayon-plain-tag">SELECT dblink_connect('host=localhost user=dbrnd password=dbrnd dbname=database_one');</pre>
<p><strong>Step 5: Create foreign data wrapper and server for global authentication.<br />
You can use this server object for cross database queries:</strong></p><pre class="crayon-plain-tag">CREATE FOREIGN DATA WRAPPER dbrnd VALIDATOR postgresql_fdw_validator;
CREATE SERVER demodbrnd FOREIGN DATA WRAPPER dbrnd OPTIONS (hostaddr '127.0.0.1', dbname 'database_one');</pre><p>
<p><strong>Step 6: Mapping of user and server:</strong></p><pre class="crayon-plain-tag">CREATE USER MAPPING FOR dbrnd SERVER demodbrnd OPTIONS (user 'dbrnd', password 'dbrnd');</pre><p>
<p><strong>Step 7: Test this server:</strong></p>
<pre class="crayon-plain-tag">SELECT dblink_connect('demodbrnd');</pre>
<p><strong>Step 8: Now, you can SELECT the data of Database_One from Database_Two:</strong></p>
<p>It is creating a virtual table so we have to specify return data type.<br />
<pre class="crayon-plain-tag">SELECT * FROM public.dblink
('demodbrnd','SELECT EmpID,EmpName FROM public.tbl_Employee') 
AS DATA(EmpID INTEGER,EmpName CHARACTER VARYING);</pre>
<p><strong>The Result:</strong><br />
<pre class="crayon-plain-tag">EmpID  |  EmpName
-------------------------
  1    |  "Anvesh"
  2    |  "Neevan"
  3    |  "Martin"</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2015/05/postgresql-cross-database-queries-using/feed/</wfw:commentRss>
			<slash:comments>38</slash:comments>
		
		
			</item>
	</channel>
</rss>
