

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Useful cheat sheet on mySQL with commands, syntax & examples, fonctions
Typology: Cheat Sheet
1 / 2
This page cannot be seen from the preview
Don't miss anything!
TINYINT[(digits)] [unsigned|zerofill] 256 BIT,BOOL,BOOLEAN synonyms for tinyint(1) SMALLINT[(digits)] [unsigned|zerofill] 65, MEDIUMINT[(digits)] [unsigned|zerofill] 16,777, INT,INTEGER[(digits)] [unsigned|zerofill] 4,294,967, BIGINT[(digits)] [unsigned|zerofill] 18,446,744,073,709,551, FLOAT[(digits, digits after decimal)] [unsigned|zerofill] 23 digits DOUBLE[(digits, digits after decimal)] [unsigned|zerofill] 24…53 digits DECIMAL[(digits, digits after decimal)] [unsigned|zerofill] a type of DOUBLE stored as a string DATE ' YYYY-MM-DD' DATETIME ' YYYY-MM-DD HH:MM:SS' TIMESTAMP[(display width)] ' YYYY-MM-DD HH:MM:SS' – display widths: 6, 8, 12 or 14 TIME 'HH:MM:SS' YEAR[(2|4)] 'YYYY' – a year in 2-digit or 4-digit format CHAR[(length)] 0…255 – fixed length, right-padded with spaces VARCHAR[(length)] 0…255 – variable length (trailing spaces removed) BINARY,VARBINARY[(length)] 0…255 – stores bytes instead of character strings TINYTEXT|TINYBLOB 0…255 – text stores strings, blob stores bytes TEXT|BLOB 0…65,535 – text stores strings, blob stores bytes MEDIUMTEXT|MEDIUMBLOB 0…16,777,215 – text stores strings, blob stores bytes LONGTEXT|LONGBLOB 0…4,294,967,295 – text stores strings, blob stores bytes ENUM('value1', 'value2',…) list of up to 65,535 members, can have only one value SET('value1', 'value2',…) list of up to 64 members, can have zero or more values
WEEK('date'[, mode]) WEEKDAY('date') DAYOFWEEK('date') DAYOFYEAR('date') MONTH('date') MONTHNAME('date') QUARTER('date') YEAR('date') YEARWEEK('date'[, mode]) HOUR('date') MINUTE('date') SECOND('date') TO_DAYS('date') FROM_DAYS(number) LAST_DAY('date') SEC_TO_TIME(seconds) TIME_TO_SEC('time') SYSDATE() CURTIME(),CURRENT_TIME(),CURRENT_TIME TIME_FORMAT('date', 'format') CURDATE(),CURRENT_DATE(),CURRENT_DATE DATE_FORMAT('date', 'format') NOW(),CURRENT_TIMESTAMP(),CURRENT_TIMESTAMP,LOCALTIME(),LOCALTIME UNIX_TIMESTAMP(['date']) FROM_UNIXTIME('unix_timestamp'[, 'format']) PERIOD_ADD('period', num) PERIOD_DIFF('period', num) EXTRACT(unit FROM 'date') ADDDATE('date', days) | ADDDATE('date', INTERVAL expr unit),DATE_ADD('date', INTERVAL expr unit) SUBDATE('date', days) | SUBDATE('date', INTERVAL expr unit),DATE_SUB('date', INTERVAL expr unit)
ASCII('str') CONV(number,from_base,to_base) BIN(num),OCT(num),HEX(num) ORD('str') CHAR(number[ USING charset],…) CONCAT('str'1, 'str1',…) LENGTH('str') CHAR_LENGTH('str') CONCAT_WS('separator', 'str1', 'str2') BIT_LENGTH('str') REVERSE('str') SOUNDEX('str') LCASE('str') UCASE('str') QUOTE('str') LPAD('str', len, 'padstr') RPAD('str', len, 'padstr') ELT(number, 'str1', 'str2', 'str3',…) LEFT('str', length) RIGHT('str', length) FIELD('str', 'str1', 'str2', 'str3',…) LTRIM('str') RTRIM('str') TRIM('str') LOAD_FILE('filename') SPACE(count) REPEAT('str', count) SUBSTRING('str', pos[, length]) REPLACE('str', 'from', 'to') INSERT('str', pos, length, 'newstr') SUBSTRING_INDEX('str', 'del', count) INSTR('str', 'substr') LOCATE('substr', 'str'[, pos]) STRCMP('str1', 'str2')
SQRT(X) RAND([seed]) PI() DEGREES(X) RADIANS(X) COT(X) COS(X) ACOS(X) SIN(X) ASIN(X) TAN(X) ATAN(X) ATAN2(X) LOG(X), LOG2(X), LOG10(X) LN(X)
REGEXP 'expression' versions 3.23, 4.0, 4.
AND, && Logical AND ||, OR Logical OR XOR Logical XOR BINARY Cast a string to binary string & Bitwise AND | Bitwise OR ^ Bitwise XOR << Left shift
Right shift
= Greater than or equal to Greater than <= Less than or equal to < Less than IS Boolean test LIKE Simple pattern matching !=, <> Not equal to NOT LIKE Negative simple match NOT RGEXP Negative regular expression NOT,! Negates value REGEXP Match on regular expression RLIKE Synonym for REGEXP SOUNDSLIKE Compare sounds
AVG(expr) SUM(expr) MIN(expr) MAX(expr) VARIANCE(expr) STD(expr) BIT_AND(expr) BIT_OR(expr) COUNT(expr) COUNT(DISTINCT expr[, expr…]) GROUP_CONCAT(expr) GROUP_CONCAT([DISTINCT] expr[, expr…] [ORDER BY {int|column|expr} [ASC | DESC] [, column …] [SEPARATOR 'string'])
IF(expression,true_result,false_result) IFNULL(expression,result) NULLIF(expression1,expression2) CASE [value] WHEN [comparison] THEN [result] [WHEN [comparison] THEN result…] [ELSE result] END
USER() CURRENT_USER() PASSWORD('string') FOUND_ROWS() ROW_COUNT() LAST_INSERT_ID([expr]) BIT_COUNT(number) FORMAT(number,digits) BENCHMARK(count, expr) CAST(expr AS type) CONVERT(expr, type) CHARSET('str') INET_NTOA(expr) INET_ATON(expr) LEAST(val1,val2,…) GET_LOCK('lock',timeout) RELEASE_LOCK('lock') GREATEST(val1,val2,…) ENCRYPT('str'[, 'salt']) DECODE('crypt', 'pass') ENCODE('str', 'password') MD5('string') SHA1('string') AES_ENCRYPT('str', 'key') COMPRESS('string') UNCOMPRESS('string') AES_DECRYPT('str', 'key') DES_ENCRYPT('str'[, {keynum|keystr}]) DES_DECRYPT('string'[, 'key'])
CREATED BY JONATHAN DAVIS