Does Amazon Redshift support extension dblink?
Asked Answered
L

3

5
CREATE EXTENSION dblink;

I tried to create an extension dblink in AWS, but I receive this error.

ERROR: syntax error at or near "EXTENSION" LINE 1: create extension dblink;

Landon answered 4/8, 2017 at 23:52 Comment(0)
L
10

Yes and No.

Amazon Redshift itself does not provide dblink. However, you can install dblink on a different PostgreSQL server and use it to connect to Amazon Redshift.

See: JOIN Amazon Redshift AND Amazon RDS PostgreSQL WITH dblink

Lafollette answered 5/8, 2017 at 0:18 Comment(3)
for completeness I add that in the same way is supported in Redshift Spectrum tooReactor
Is this supported cross account also?Guerra
@Guerra As long as the two databases can communicate with each other, it will work.Lafollette
D
3

While AWS Redshift is based on Postgresql, it has various enhancements/alterations to integrate both AWS infrastructure and also a very different backend from standard Postgresql. In order to create a DB Link, you don't need to (in fact, you can't) load the DB Link extension.

Instead, AWS have replaced the standard Postgresql CREATE SERVER AND IMPORT FOREIGN SCHEMA statement with their unique CREATE EXTERNAL SCHEMA - this creates your DB links for you:

CREATE EXTERNAL SCHEMA [IF NOT EXISTS] local_schema_name
FROM { [ DATA CATALOG ] | HIVE METASTORE | POSTGRES | MYSQL | KINESIS }
[ DATABASE 'database_name' ]
[ REGION 'aws-region' ]
[ URI 'hive_metastore_uri' [ PORT port_number ] ]
IAM_ROLE { default | 'arn:aws:iam::<AWS account-id>:role/<role-name>' }
[ SECRET_ARN 'ssm-secret-arn' ]          
[ CATALOG_ROLE 'catalog-role-arn-string' ] 
[ CREATE EXTERNAL DATABASE IF NOT EXISTS ]

This does everything in one statement. Full documentation can be found here

Dissemble answered 14/3, 2022 at 10:14 Comment(1)
This should be the current answer.Numbers
R
2

The answer is "Yes", but you have to use Amazon RDS as a ‘cache’ by leveraging the Dblink feature of RDS. This allows us to make any Amazon Redshift table available as a relation in RDS, without the need to explicitly copy that data over. Dblink handles moving the data at the block level.

We've used the approach described in the link that John has provided above. We did a detailed write up of how we did it in a blog post "Have Your Postgres Cake with Amazon Redshift and eat it, too."

https://www.intermix.io/blog/using-amazon-redshift-with-amazon-rds/

Rie answered 6/9, 2018 at 21:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.