|
TINYINT
|
Integer (0 to 255)
|
|
SMALLINT
|
Integer (-32768 to +32767)
|
|
INT
|
Integer (-2147483648 to +2147483647)
|
|
BIGINT
|
Integer (-9233372036854775808 to +9233372036854775807)
|
|
DECIMAL
|
Decimal (-1038 and 1038 -1)
|
|
NUMERIC
|
Decimal (-1038 and 1038 -1)
|
|
FLOAT
|
Decimal (8 byte, machine-dependent)
|
|
REAL
|
Decimal (4 byte, machine-dependent)
|
|
CHAR(n)
|
String (1 to 255)
|
|
NCHAR(n)
|
String (1 to 255)
|
|
VARCHAR(n)
|
String (1 to 255)
|
|
NVARCHAR(n)
|
String (1 to 255)
|
|
TEXT
|
String (2^31 characters)
|
|
MONEY
|
Decimal (922337203685477.5807 to -922337203685477.5808)
|
|
SMALLMONEY
|
Decimal (214748.3647 to -214748.3648)
|
|
DATE
|
Date (1753-01-01 to 9999-12-31)
|
|
DATETIME
|
DateTime (1753-01-01 to 9999-12-31)
|
|
SMALLDATETIME
|
DateTime (1900-01-01 to 2079-06-06)
|
|
TIME
|
Time (12:00:00AM to 11:59:59:999PM)
|
|
TIMESTAMP
|
Timestamp
|
|
BIGTIME
|
Time (12:00:00.000000 AM to 11:59:59.999999 PM)
|
|
BIGDATETIME
|
DateTime (0001-01-01 to 9999-12-31 and 12:00.000000AM to 11:59:59.999999 PM)
|
|
BIT
|
Boolean (0 or 1)
|
|
BINARY
|
Binary (0 - 256 bytes)
|
|
VARBINARY
|
Binary (0 - 255 bytes)
|
|
IMAGE
|
Blob (Binary 231)
|
CASE value-expression
WHEN [constant | NULL] THEN statement-list …
[ WHEN [constant | NULL] THEN statement-list ] …
ELSE statement-list
END
IF condition THEN expression
[ELSE expression]
END [IF]
DECLARE @c1 FLOAT, @c2 FLOAT
SELECT @c1 = 1000/1000
SELECT @c2 = @c1/30
SELECT @c1 , @c
LIST (
[ALL | DISTINCT] string-expr
[, 'delimiter-string']
[ORDER BY order-by-expr [ ASC | DESC ], ... ]
)
SELECT LIST(EmployeeID) FROM Employees GROUP BY DepartmentID
sa_split_list( str [, delim ] [, maxlen ])line_num Sequential number for the row.row_value Value from the string, truncated to maxlen if required.DROP TABLE IF EXISTS table-name
DECLARE LOCAL TEMPORARY TABLE table-name
… ( col-name [ col-constraint ] …
[ , col-name [ col-constraint ] … ]
[ , table-constraint ] … )
…[ ON COMMIT { DELETE | PRESERVE } ROWS NOT TRANSACTIONAL]
INSERT INTO table-name SELECT ... orSELECT * INTO table-name FROM ...
|
datepart
|
abbr
|
values
|
|
year
|
yy
|
1753–9999 (datetime) 1753–2079 (smalldatetime) 0001–9999 (bigdatetime)
|
|
quarter
|
qq
|
1-4
|
|
month
|
mm
|
1-12
|
|
week
|
wk
|
1-54
|
|
day
|
dd
|
1-31
|
|
dayofyear
|
dy
|
1-366
|
|
weekday
|
dw
|
1–7 (Sun. – Sat.)
|
|
hour
|
hh
|
0-23
|
|
minute
|
mi
|
0-59
|
|
second
|
ss
|
0-59
|
|
millisecond
|
ms
|
0-999
|
|
microseconds
|
us
|
0-999999
|
DATEADD(date-part, value, timestamp)
SELECT DATEADD(month, 102, '1987/05/02')
DATEDIFF(datepart, {date, date | time, time | bigtime, bigtime | datetime, datetime | bigdatetime, bigdatetime}])
SELECT DATEDIFF(hh, "apr 1, 1999", "apr 2, 1999")
SELECT * FROM table-name
WHERE col-name REGEXP 'reg-expr';
SELECT Surname, Surname, City, Phone FROM Contacts WHERE Phone REGEXP '\\d{8}00';
SELECT REGEXP_SUBSTR( col-name, 'reg-expr' )
FROM table-name;
SELECT REGEXP_SUBSTR( Street, '(?<=^\\S+\\s+).*$' ) FROM Customers;
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.