> ## Documentation Index
> Fetch the complete documentation index at: https://docs.exploratory.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Amazon Redshift Database Data Import

You can quickly import data from your Amazon Redshift Database into Exploratory.

Here is a [blog post](https://blog.exploratory.io/exploratory-data-analysis-for-amazon-redshift-with-r-dplyr-9a14441020eb#.aqcbfa6h8) introducing this support in detail.

## 1. Create a Connection to use

Create a connection following [this instruction](https://docs.exploratory.io/en/import/connection.html.md).

## 2. Open Redshift Import dialog

Click '+' button next to 'Data Frames' and select 'Database Data'.

![](https://mintcdn.com/exploratory-inc/w_BKR9NcFwjvyQXp/en/import/images/import-database.png?fit=max\&auto=format\&n=w_BKR9NcFwjvyQXp\&q=85\&s=49072dc21685823884ca5dd29d8595cf)

Click Amazon Redshift to select.

![](https://mintcdn.com/exploratory-inc/7Kn_H2bJDKm3Jv90/en/import/images/redshift.png?fit=max\&auto=format\&n=7Kn_H2bJDKm3Jv90\&q=85\&s=d62113080150355ad7b35be87ce638b3)

## 3. Preview and Import

Click Preview button to see the data back from your Redshift db.

![](https://mintcdn.com/exploratory-inc/7Kn_H2bJDKm3Jv90/en/import/images/import-redshift-dialog.png?fit=max\&auto=format\&n=7Kn_H2bJDKm3Jv90\&q=85\&s=5b0f546682d880914950406659b4edb6)

If it looks ok, then you can click 'Import' to import the data into Exploratory.

## 4. Querying Random Sample Data

You might want to take a random sample of the data that would be reasonable size for your analysis.

You can use [md5](http://docs.aws.amazon.com/redshift/latest/dg/r_MD5.html) function to get random number generated and use it like below to get the random sample of the data.

```
SELECT *
   FROM airline_2016_01
   ORDER BY md5('randomSeed' || flight_num)
   LIMIT 100000
```

## 5. Using Parameters in SQL

First, click a parameter link on the SQL Data Import Dialog.

![](https://mintcdn.com/exploratory-inc/m5S7Pfr13E6f1q8Y/en/import/images/add_parameter.png?fit=max\&auto=format\&n=m5S7Pfr13E6f1q8Y\&q=85\&s=36e0536377b7020f271cfe3ade161c80)

Second, define a parameter and click Save button.

![](https://mintcdn.com/exploratory-inc/w_BKR9NcFwjvyQXp/en/import/images/define_parameter.png?fit=max\&auto=format\&n=w_BKR9NcFwjvyQXp\&q=85\&s=1fc9d0b8803efcc782f5575d9b94ebd0)

Finally, you can use @{} to surround a variable name inside the query like below.

```
select *
from airline_2016_01
where carrier = @{carrier}
```

If you type @ then it suggests parameters like below.

![](https://mintcdn.com/exploratory-inc/7Kn_H2bJDKm3Jv90/en/import/images/insert_param_in_query.png?fit=max\&auto=format\&n=7Kn_H2bJDKm3Jv90\&q=85\&s=01377085ff3712dd98c42cb6f8044cf0)

Here's a [blog post](https://exploratory.io/note/kanaugust/An-Introduction-to-Parameter-in-Exploratory-WCO4Vgn7HJ) for more detail.

## 6. AWS Security Group Setup

![](https://mintcdn.com/exploratory-inc/7Kn_H2bJDKm3Jv90/en/import/images/redshift4.png?fit=max\&auto=format\&n=7Kn_H2bJDKm3Jv90\&q=85\&s=c2d75c67fb241d8514911765e37dc6f0)

If you encounter a database connection error, please go to AWS console and make sure you added your client PC's IP address to your Security Group (Inbound) associated with the Redshift cluster.

## 7. Number of rows

From performance point of view, we no longer show actual number of rows which can be only fetched by executing whole query again.

![](https://mintcdn.com/exploratory-inc/t8wulpy3B474-b7T/en/import/images/sql_number_of_rows.png?fit=max\&auto=format\&n=t8wulpy3B474-b7T\&q=85\&s=93b2478a659616e383ff2704fdaa8125)

If you still want to show the actual number of query for your query, you can do so by setting System Configuration.

![](https://mintcdn.com/exploratory-inc/7Kn_H2bJDKm3Jv90/en/import/images/num_of_rows_config_menu.png?fit=max\&auto=format\&n=7Kn_H2bJDKm3Jv90\&q=85\&s=af6d606401cd4a424960d5d725c26e72)

Then set "Yes" For "Show Actual Number of Rows on SQL Data Import Dialog"

![](https://mintcdn.com/exploratory-inc/7Kn_H2bJDKm3Jv90/en/import/images/num_of_rows_config.png?fit=max\&auto=format\&n=7Kn_H2bJDKm3Jv90\&q=85\&s=41dd4780173eef007b2edf1607357bcf)

This will show you Actual Number of Rows like below.

![](https://mintcdn.com/exploratory-inc/m5S7Pfr13E6f1q8Y/en/import/images/actual_num_of_rows.png?fit=max\&auto=format\&n=m5S7Pfr13E6f1q8Y\&q=85\&s=8d6aa5cd6a05dc5e1d7805865d47445c)

## 8. Exploratory Data Analysis for Amazon Redshift with R & dplyr

Here is the link to the blog post [Exploratory Data Analysis for Amazon Redshift with R & dplyr](https://blog.exploratory.io/exploratory-data-analysis-for-amazon-redshift-with-r-dplyr-9a14441020eb)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.