Amazon Redshift
This page describes how to create and maintain connections to your Amazon Redshift database.
Before you can write your transformed data to a table in Amazon Redshift, you should first establish a connection to your Amazon Redshift database.
Create a Redshift connection
Simple example
A Redshift connection can be created as simply as follows:
where:
host_name
: The endpoint of the Amazon Redshift cluster.port
: The port number that you specified when you launched the cluster. The default port for Amazon Redshift is 5439.database_name
: The name of the target database.
Read more:
Note that a Redshift connection must specify the database it is connecting to within the connection string. This means that in order to connect to multiple databases within your account, you need to create at least one connection per database.
Full example
The following example also creates a Redshift connection but additionally limits the maximum number of concurrent connections to your database by configuring an additional option MAX_CONCURRENT_CONNECTIONS
:
Alter a Redshift connection
Some connection options are considered mutable, meaning that in some cases, you can run a SQL command to alter an existing Redshift connection rather than creating a new one.
To change the database you are connecting to but keep everything else the same without having to create an entirely new connection, you can run the following command:
Drop a Redshift connection
If you no longer need a connection, you can easily drop it with the following SQL command:
However, note that if there are existing tables or jobs that are dependent upon the connection in question, the connection cannot be deleted. Attempting to do so will raise the following error:
Learn More
Last updated