If you’ve upgraded to the TeamSQL Pro Plan, you have access to the Snippets feature, which we think you’ll love. In this post, we’ll talk about what snippets are and the snippets available to those using TeamSQL with their Redshift databases. We’ll begin by covering three Redshift-specific snippets and end by including the usual CRUD commands at the end of the post.
What are Snippets?
Snippets are templates that help you can use to build longer queries. Because TeamSQL knows which database you’re working in, you’ll get the right snippet at the right time (if you work in multiple types of databases, you’ll know how easy it is to get similar-but-different syntaxes mixed up). Now, you’re less likely to run a query that works for MySQL against Redshift (or vice versa).
If you can’t remember the specific syntax, Intellisense can help you out. You can “scroll” through the list of snippets using your arrow keys, and when you’ve found the one you’re interested in, press tab to populate your query window with the snippet. Additionally, if you don’t recall what a specific snippet should do, the drop-down list of snippets includes a brief definition.
For in-depth information about Redshift Snippets, as well as links to the official AWS reference pages, please see the appropriate docs page.
If you have existing data in AWS DynamoDB, S3, or EMR, you can efficiently use the following snippets to copy data over to your Redshift tables:
COPY from DynamoDB COPY from S3 COPY from S3 (Fixed-Width Option) COPY from S3 (Temporary Credentials) COPY from S3 (CSV Option) COPY from S3 (JSON) COPY from S3 (Explicit Values) COPY from S3 (GZIP) COPY from S3 (Timeformat) COPY from S3 (Escape) COPY from EMR
You can also “unload” data TeamSQL returns from Redshift into S3.
UNLOAD to S3 (using an IAM Role) UNLOAD to S3 (using temporary credentials)
If you’ve deleted rows in your tables, you can use the vacuum commands to sort and/or reclaim disk space.
VACUUM FULL… VACUUM FULL… (PERCENT) VACUUM SORT ONLY… VACUUM DELETE ONLY… VACUUM REINDEX…
Snippets for Basic Commands
For in-depth information about snippets for basic commands as they’re used in Redshift, please see the appropriate docs page.
The following is a list of snippets for basic commands as used in Redshift.
SELECT * FROM… SELECT * FROM with WHERE clause… SELECT with INNER JOIN… SELECT Command with INNER JOIN INSERT INTO… INSERT INTO with SELECT… DELETE FROM… UPDATE with WHERE clause… CREATE FUNCTION… DROP FUNCTION… CALL FUNCTION… CREATE TABLE (Simple) CREATE TABLE (with distribution and sort key) DROP TABLE… ALTER TABLE… SELECT INTO (Structure only) SELECT INTO (Structure & Data)