/images/avatar.png

Hi! I'm Pratyaksha.

AWS CLI Cheatsheet

CLI Command Structure:

aws <command> <subcommand> [options and parameters]

aws <command> wait <subcommand> [options and parameters] (supported by some commands)

Info

Save output to a file using the > command. For example: aws dynamodb scan --table-name MusicCollection > output.json.

Tip: Use >> to append to a file. Also useful - Load Parameters from a file

Set Up

  • Using long-term credentials with IAM user (Not recommended):

SQL Cheatsheet

Single line comment: -- comment

Multiline comment: /* comments */

Data query Language (DQL)

1
2
3
4
5
6
7
SELECT 'ID: ', id, col_1 + col_2, sqrt(col_2)
FROM   t1
-- precedence within WHERE: functions, comparisons, NOT, AND, OR
WHERE  col_1 > 100
AND    NOT MOD(col_2, 10) = 0
OR     col_3 < col_1
ORDER  BY col_4 DESC, col_5;
1
2
-- number of rows, number of not-null-values
SELECT COUNT(*), COUNT(col_1) FROM t1;
1
2
-- predefined functions
SELECT COUNT(col_1), MAX(col_1), MIN(col_1), AVG(col_1), SUM(col_1) FROM t1;
1
2
-- UNIQUE values only
SELECT DISTINCT col_1 FROM t1;
1
2
-- Only the combination of col_1 plus col_2 is unique
SELECT DISTINCT col_1, col_2 FROM t1;

Case Expression

1
2
3
4
5
6
7
8
SELECT id,
       CASE contact_type
         WHEN 'fixed line' THEN 'Phone'
         WHEN 'mobile'     THEN 'Phone'
         ELSE                   'Not a telephone number'
       END AS 'contact_type',
       contact_value
FROM   contact;

There are two short forms for special CASE expressions: COALESCE and NULLIF.