MySQL Quick Reference Sheet
MySQL Quick Reference Sheet
numeric ABS(X)
FLOOR(X)
SIGN(X)
CEILING(X)
TINYINT[(digits)] [unsigned|zerofill] 256 ROUND(X[,D]) EXP(X)
BIT,BOOL,BOOLEAN synonyms for tinyint(1) DIV(X) MOD(N,M)
SMALLINT[(digits)] [unsigned|zerofill] 65,536 POW(X,Y) POWER(X,Y)
MEDIUMINT[(digits)] [unsigned|zerofill] 16,777,216 SQRT(X) RAND([seed])
INT,INTEGER[(digits)] [unsigned|zerofill] 4,294,967,296 PI() DEGREES(X)
BIGINT[(digits)] [unsigned|zerofill] 18,446,744,073,709,551,616 RADIANS(X) COT(X)
FLOAT[(digits, digits after decimal)] [unsigned|zerofill] 23 digits COS(X) ACOS(X)
DOUBLE[(digits, digits after decimal)] [unsigned|zerofill] 24…53 digits SIN(X) ASIN(X)
DECIMAL[(digits, digits after decimal)] [unsigned|zerofill] a type of DOUBLE stored as a string TAN(X) ATAN(X) ATAN2(X)
LOG(X), LOG2(X), LOG10(X) LN(X)
TRUNCATE(X, D) REFERENCE SHEET
versions 3.23, 4.0, 4.1
strings
CHAR[(length)] 0…255 – fixed length, right-padded with spaces
functions
VARCHAR[(length)] 0…255 – variable length (trailing spaces removed) ASCII('str') CONV(number,from_base,to_base) BIN(num),OCT(num),HEX(num)
BINARY,VARBINARY[(length)] 0…255 – stores bytes instead of character strings ORD('str') CHAR(number[ USING charset],…) CONCAT('str'1, 'str1',…)
TINYTEXT|TINYBLOB 0…255 – text stores strings, blob stores bytes LENGTH('str') CHAR_LENGTH('str') CONCAT_WS('separator', 'str1', 'str2')
TEXT|BLOB 0…65,535 – text stores strings, blob stores bytes BIT_LENGTH('str') REVERSE('str') SOUNDEX('str')
MEDIUMTEXT|MEDIUMBLOB 0…16,777,215 – text stores strings, blob stores bytes LCASE('str') UCASE('str') QUOTE('str')
LONGTEXT|LONGBLOB 0…4,294,967,295 – text stores strings, blob stores bytes LPAD('str', len, 'padstr') RPAD('str', len, 'padstr') ELT(number, 'str1', 'str2', 'str3',…)
ENUM('value1', 'value2',…) list of up to 65,535 members, can have only one value LEFT('str', length) RIGHT('str', length) FIELD('str', 'str1', 'str2', 'str3',…)
SET('value1', 'value2',…) list of up to 64 members, can have zero or more values LTRIM('str') RTRIM('str') TRIM('str') LOAD_FILE('filename')
SPACE(count) REPEAT('str', count) SUBSTRING('str', pos[, length])
REGEXP 'expression' REPLACE('str', 'from', 'to') INSERT('str', pos, length, 'newstr') SUBSTRING_INDEX('str', 'del', count)
INSTR('str', 'substr') LOCATE('substr', 'str'[, pos]) STRCMP('str1', 'str2')