You are on page 1of 2

MySQL Cheat Sheet

by Dave Child (DaveChild) via cheatography.com/1/cs/16/

MySQL Data Types MySQL Type Conversion MySQL String Functions (cont)

CHAR String (0 - 255) BINARY 'string' LENGTH REPEAT

VARCHAR String (0 - 255) CAST (expression AS datatype) CHAR_LENGTH REVERSE

TINYTEXT String (0 - 255) CONVERT (expression, datatype) BIT_LENGTH INSERT

TEXT String (0 - 65535) LOCATE ELT


MySQL Grouping Functions
BLOB String (0 - 65535) INSTR FIELD

MEDIUMTEXT String (0 - 16777215) AVG MAX LPAD LCASE

MEDIUMBLOB String (0 - 16777215) BIT_AND STD RPAD UCASE

LONGTEXT String (0 - 4294967295) BIT_OR STDDEV LEFT LOAD_FILE

LONGBLOB String (0 - 4294967295) COUNT SUM RIGHT QUOTE

TINYINT x Integer (-128 to 127) GROUP_CONCAT VARIANCE

MIN MySQL Date and Time Functions


SMALLINT x Integer (-32768 to 32767)

MEDIUMINT x Integer (-8388608 to DAYOFWEEK DATE_SUB


MySQL Mathematical Functions
8388607) WEEKDAY ADDDATE

INT x Integer (-2147483648 to ABS COS DAYOFMONTH SUBDATE


2147483647) SIGN SIN DAYOFYEAR EXTRACT
BIGINT x Integer (- MOD TAN MONTH TO_DAYS
9223372036854775808 to
FLOOR ACOS DAYNAME FROM_DAYS
9223372036854775807)
CEILING ASIN MONTHNAME DATE_FORMAT
FLOAT Decimal (precise to 23 digits)
ROUND ATAN, ATAN2 QUARTER TIME_FORMAT
DOUBLE Decimal (24 to 53 digits)
DIV COT WEEK CURRENT_DATE
DECIMAL "DOUBLE" stored as string
EXP RAND YEAR CURRENT_TIME
DATE YYYY-MM-DD
LN LEAST YEARWEEK NOW
DATETIME YYYY-MM-DD HH:MM:SS
LOG, LOG2, LOG10 GREATEST HOUR SYSDATE
TIMESTAMP YYYYMMDDHHMMSS
POW DEGREES MINUTE UNIX_TIMESTAMP
TIME HH:MM:SS
POWER RADIANS SECOND FROM_UNIXTIME
ENUM One of preset options
SQRT TRUNCATE PERIOD_ADD SEC_TO_TIME
SET Selection of preset options
PI PERIOD_DIFF TIME_TO_SEC
Integers (marked x) that are "UNSIGNED" have
the same range of values but start from 0 (i.e., DATE_ADD
MySQL String Functions
an UNSIGNED TINYINT can have any value
from 0 to 255). ASCII SUBSTRING MySQL Control Flow Functions

ORD MID IF NULLIF


CONV SUBSTRING_INDEX IFNULL
BIN LTRIM

OCT RTRIM

HEX TRIM

CHAR SOUNDEX

CONCAT SPACE

CONCAT_WS REPLACE

By Dave Child (DaveChild) Published 19th October, 2011. Sponsored by Readability-Score.com


cheatography.com/davechild/ Last updated 12th May, 2016. Measure your website readability!
www.getpostcookie.com Page 1 of 2. https://readability-score.com
MySQL Cheat Sheet
by Dave Child (DaveChild) via cheatography.com/1/cs/16/

MySQL Miscellaneous Functions

BIT_COUNT DES_ENCRYPT

DATABASE DES_DECRYPT

USER LAST_INSERT_ID

SYSTEM_USER FORMAT

SESSION_USER VERSION

CURRENT_USER CONNECTION_ID

PASSWORD GET_LOCK

OLD_PASSWORD RELEASE_LOCK

ENCRYPT IS_FREE_LOCK

DECODE BENCHMARK

MD5 INET_NTOA

SHA1 INET_ATON

AES_ENCRYPT FOUND_ROWS

AES_DECRYPT STRCMP

By Dave Child (DaveChild) Published 19th October, 2011. Sponsored by Readability-Score.com


cheatography.com/davechild/ Last updated 12th May, 2016. Measure your website readability!
www.getpostcookie.com Page 2 of 2. https://readability-score.com