Show Menu
Cheatography

Vertica SQL Cheat Sheet Cheat Sheet (DRAFT) by

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Data Types

BINARY
1 to 65.000
Fixed-­length binary string
VARBINARY
1 to 65.000
Variab­le-­length binary string
LONG VARBINARY
1 to 32.000.000
Long variab­le-­length binary string
BYTEA
1 to 65.000
Variab­le-­length binary string
RAW
1 to 65.000
Variab­le-­length binary string
BOOLEAN
1
True or False or NULL
CHAR
1 to 65.000
Fixed-­length character string
VARCHAR
1 to 65.000
Variab­le-­length character string
LONG VARCHAR
1 to 32.000.000
Long variab­le-­length character string
DATE
8
Represents a month, day, and year
TIME
8
Represents a time of day without timezone
DATETIME
8
Represents a date and time without timezone
SMALLD­ATETIME
8
Represents a date and time without timezone
TIME WITH TIMEZONE
8
Represents a time of day with timezone
TIMESTAMP
8
Represents a date and time without timezone
TIMESTAMP WITH TIMEZONE
8
Represents a date and time with timezone
INTERVAL
8
Measures the difference between two points in time
INTERVAL DAY TO SECOND
8
Represents an interval measured in days and seconds
INTERVAL YEAR TO MONTH
8
Represents an interval measured in years and months
DOUBLE PRECISION
8
Signed 64-bit IEEE floating point number, requiring 8 bytes of storage
FLOAT
8
Signed 64-bit IEEE floating point number, requiring 8 bytes of storage
FLOAT(n)
8
Signed 64-bit IEEE floating point number, requiring 8 bytes of storage
FLOAT8
8
Signed 64-bit IEEE floating point number, requiring 8 bytes of storage
REAL
8
Signed 64-bit IEEE floating point number, requiring 8 bytes of storage
INTEGER
8
Signed 64-bit integer, requiring 8 bytes of storage
INT
8
Signed 64-bit integer, requiring 8 bytes of storage
BIGINT
8
Signed 64-bit integer, requiring 8 bytes of storage
INT8
8
Signed 64-bit integer, requiring 8 bytes of storage
SMALLINT
8
Signed 64-bit integer, requiring 8 bytes of storage
TINYINT
8
Signed 64-bit integer, requiring 8 bytes of storage
DECIMAL
8+
8 bytes for the first 18 digits of precision, plus 8 bytes for each additional 19 digits
NUMERIC
8+
8 bytes for the first 18 digits of precision, plus 8 bytes for each additional 19 digits
NUMBER
8+
8 bytes for the first 18 digits of precision, plus 8 bytes for each additional 19 digits
MONEY
8+
8 bytes for the first 18 digits of precision, plus 8 bytes for each additional 19 digits
GEOMETRY
1 to 10.000.000
Coordi­nates expressed as (x,y) pairs, defined in the Cartesian plane
GEOGRAPHY
1 to 10.000.000
Coordi­nates expressed in longit­ude­/la­titude angular values, measured in degrees
UUID
16
Stores univer­sally unique identi­fiers (UUIDs)
 

Select queries

Select all columns
SELECT * FROM tbl;
Select come columns
SELECT col1, col2 FROM tbl;
Select only unique records
SELECT DISTINCT COL1 FROM tbl WHERE condition;
Column alias with AS
SELECT col FROM tbl AS newname;
Order results
SELECT * FROM tbl ORDER BY col [ASC | DESC]
Group results
SELECT col1, SUM(col2) FROM tbl GROUP BY col1;