I need to retrieve data from tables which is located in two different database
so need to use dblink , but not able to understand its format
Do you mean you're on one database and you want to query another?
First of all you'll need to make sure that postgresql-contrib is installed
in my case
dnf install postgresql-contrib-9.4.6-1.fc23.x86_64
Then you need to create the extension in postgresql to use dblink.
create extension dblink;
Here's is a simple example
SELECT * FROM dblink('dbname=Test','SELECT date1, int2 FROM test1') AS test(date1 date, int2 integer);
I've tested this and it works fine.
All the best
Ref Postgresql dblink