Amazon Redshift
Cluster Management Guide (API Version 2012-12-01)

Querying a Database Using the Query Editor

Using the Query Editor is the easiest way to run queries on databases hosted by your Amazon Redshift cluster. After creating your cluster, you can immediately run queries by using the Query Editor on the Amazon Redshift console.

The following cluster node types support the Query Editor:

  • DC1.8xlarge

  • DC2.large

  • DC2.8xlarge

  • DS2.8xlarge

Using the Query Editor, you can do the following:

  • Run single SQL statement queries.

  • Download result sets as large as 100 MB to a comma-separated value (CSV) file.

  • Save queries for reuse. You can't save queries in the EU (Paris) Region or the Asia Pacific (Osaka-Local) Region.

  • View query execution details for user-defined tables.

Query Editor Considerations

Be aware of the following considerations when you use the Query Editor:

  • Up to 50 users can connect to a cluster with the Query Editor at the same time.

  • Up to 500 users can connect to a cluster simultaneously. This total includes the users connecting through the Query Editor.

  • Up to 50 workload management (WLM) query slots can be active at the same time. For more information about query slots, see Implementing Workload Management.

  • Query Editor only runs short queries that can complete within two minutes.

  • Query result sets are paginated with 100 rows per page.

  • You can't use the Query Editor with Enhanced VPC Routing. For more information, see Amazon Redshift Enhanced VPC Routing.

  • You can't use transactions in the Query Editor. For more information about transactions, see BEGIN in the Amazon Redshift Database Developer Guide.

Enabling Access to the Query Editor

To access the Query Editor, you need permission. To enable access, attach the AmazonRedshiftQueryEditor and AmazonRedshiftReadOnlyAccess policies for AWS Identity and Access Management (IAM) to the AWS account that you use to access your cluster.

If you have already created an IAM user to access Amazon Redshift, you can attach the AmazonRedshiftQueryEditor and AmazonRedshiftReadOnlyAccess policies to that user. If you haven't created an IAM user yet, create one and attach the policies to the IAM user.

To attach the required IAM policies for the Query Editor

  1. Sign in to the AWS Management Console and open the IAM console at https://console.aws.amazon.com/iam/.

  2. Choose Users.

  3. Choose the user that needs access to the Query Editor.

  4. Choose Add permissions.

  5. Choose Attach existing policies directly.

  6. For Policy names, choose AmazonRedshiftQueryEditor and AmazonRedshiftReadOnlyAccess.

  7. Choose Next: Review.

  8. Choose Add permissions.

Using the Query Editor

In the following example, you use the Query Editor to perform the following tasks:

  • Run SQL commands.

  • View query execution details.

  • Save a query.

  • Download a query result set.

To complete the following example, you need an existing Amazon Redshift cluster. If you don't have a cluster, create one by following the procedure described in Creating a Cluster.

To use the Query Editor

  1. Sign in to the AWS Management Console and open the Amazon Redshift console at https://console.aws.amazon.com/redshift/.

  2. In the navigation pane, choose Query Editor.

  3. For Schema, choose public to create a new table based on that schema.

  4. Enter the following in the Query Editor window and choose Run query to create a new table.

    create table shoes( shoetype varchar (10), color varchar(10));
  5. Choose Clear.

  6. Enter the following command in the Query Editor window and choose Run query to add rows to the table.

    insert into shoes values ('loafers', 'brown'), ('sandals', 'black');
  7. Choose Clear.

  8. Enter the following command in the Query Editor window and choose Run query to query the new table.

    select * from shoes;

    You should see the following results.

  9. Choose View execution to view the execution details.

  10. Choose Download CSV to download the query results as a CSV file.