Redshift Snippet List

Snippets are available with TeamSQL Pro Plan.

First item is the label of snippet so you can start writing one of the labels in TeamSQL Query Editor and use them.

 

 

 

SELECT * FROM…

Simple SELECT command

SELECT * FROM with WHERE clause…

Simple SELECT command with WHERE clause

SELECT with INNER JOIN…

SELECT Command with INNER JOIN

INSERT INTO…

Insert into a table on “public”

INSERT INTO with SELECT…

Insert into a table on “public” using SELECT

DELETE FROM…

Delete rows from a table on “public”

UPDATE with WHERE clause…

Update records in a table on “public”

COPY from DynamoDB

IAM Role) Loads the Amazon Redshift table with data from the DynamoDB table. The Amazon Redshift table must already exist in the database (Ref: http://docs.aws.amazon.com/redshift/latest/dg/r_COPY_command_examples.html)

COPY from S3

(I AM Role) Loads a table from an Amazon S3 bucket. The COPY command loads all of the files in the given folder (Ref:http://docs.aws.amazon.com/redshift/latest/dg/r_COPY_command_examples.html)

COPY from S3 (Fixed-Width Option)

(IAM Role) Assumes a data file formatted fixed-width size for each column – all of the columns are the same width as noted in the specification (Ref: http://docs.aws.amazon.com/redshift/latest/dg/r_COPY_command_examples.html)

COPY from S3 (Temporary Credentials)

(Temporary Credentials) Loads a table from an Amazon S3 bucket. The COPY command loads all of the files in the given folder. (Ref: http://docs.aws.amazon.com/redshift/latest/dg/r_COPY_command_examples.html)

COPY from S3 (CSV Option)

(IAM Role) Loads a table from an Amazon S3 bucket, contents of a text file with the field values separated by commas (Ref: http://docs.aws.amazon.com/redshift/latest/dg/r_COPY_command_examples.html)

COPY from S3 (JSON)

(IAM Role) To load from JSON data using the ‘auto’ argument, the JSON data must consist of a set of objects. The key names must match the column names, order does not matter.

COPY from S3 (Explicit Values)

(IAM Role) Loads a table from an Amazon S3 bucket, this command overrides the default IDENTITY behavior of auto-generating values for an IDENTITY column and instead loads the explicit values from the given file. (Ref: http://docs.aws.amazon.com/redshift/latest/dg/r_COPY_command_examples.html)

COPY from S3 (GZIP)

(IAM Role) Loads a table from a pipe-delimited GZIP in Amazon S3 bucket. (Ref: http://docs.aws.amazon.com/redshift/latest/dg/r_COPY_command_examples.html)

COPY from S3 (Timeformat)

(IAM Role) Loads a table from Amazon S3 bucket and assumes date/time format will be same as given format (Ref: http://docs.aws.amazon.com/redshift/latest/dg/r_COPY_command_examples.html)

COPY from S3 (Escape)

(IAM Role) Loads a table from Amazon S3 bucket and it loads characters that match the delimiter character (in this case, the pipe character). In the input file, make sure that all of the pipe characters that you want to load are escaped with the backslash character. Then load the file with the ESCAPE parameter.(Ref: http://docs.aws.amazon.com/redshift/latest/dg/r_COPY_command_examples.html)

COPY from EMR

(IAM Role) Loads a table with tab-delimited data from lzop-compressed files in an Amazon EMR cluster. COPY will load every file in the given folder.

UNLOAD to S3 (IAM Role)

(IAM Role) Unloads the result of a query to one or more files on Amazon Simple Storage Service (Amazon S3), using Amazon S3 server-side encryption (SSE-S3). (Ref: http://docs.aws.amazon.com/redshift/latest/dg/r_UNLOAD.html)

UNLOAD to S3 (Temporary Credentials)

(Temporary Credentials) Unloads the result of a query to one or more files on Amazon Simple Storage Service (Amazon S3), using Amazon S3 server-side encryption (SSE-S3). (Ref: http://docs.aws.amazon.com/redshift/latest/dg/r_UNLOAD.html)

VACUUM FULL…

Sorts the specified table (or all tables in the current database) and reclaims disk space occupied by rows that were marked for deletion by previous UPDATE and DELETE operations.

VACUUM FULL… (PERCENT)

Sorts the specified table (or all tables in the current database) and reclaims disk space occupied by rows that were marked for deletion by previous UPDATE and DELETE operations. (Ref: http://docs.aws.amazon.com/redshift/latest/dg/r_VACUUM_command.html)

VACUUM SORT ONLY…

Sorts the specified table (or all tables in the current database) without reclaiming space freed by deleted rows. This option is useful when reclaiming disk space is not important but resorting new rows is important. (Ref: http://docs.aws.amazon.com/redshift/latest/dg/r_VACUUM_command.html)

VACUUM DELETE ONLY…

Reclaims disk space occupied by rows that were marked for deletion by previous UPDATE and DELETE operations, and compacts the table to free up the consumed space. (Ref: http://docs.aws.amazon.com/redshift/latest/dg/r_VACUUM_command.html)

VACUUM REINDEX…

Analyzes the distribution of the values in interleaved sort key columns, then performs a full VACUUM operation. VACUUM REINDEX takes significantly longer than VACUUM FULL because it makes an additional pass to analyze the interleaved sort keys. (Ref: http://docs.aws.amazon.com/redshift/latest/dg/r_VACUUM_command.html)

CREATE FUNCTION…

Create a function on “public”

DROP FUNCTION…

Drop a function on “public”

CALL FUNCTION…

Call a function on “public”

CREATE TABLE (Simple)

Create a table on “public”

CREATE TABLE (with distribution and sort key)

Create a table on “public” schema distribution and sort key

DROP TABLE…

Drop a table on “public”

ALTER TABLE…

Alter a table on “public”

SELECT INTO (Structure only)

Create a table (only structure) on “public” like another one

SELECT INTO (Structure & Data)

Create a table (structure & data) on “public” like another one