Mysql cheatsheet -

Numeric Type
BIT
BIT(1-64)
TINYINT
Very small integer
Value(-128 to 127)
TINYINT UNSIGNED
Very small integer
Value(0 - 255)
BOOL, BOOLEAN
the values TRUE and FALSE are merely aliases for 1 and 0
SMALLINT
Small integer
Value(-32768 to 32767)
SMALLINT UNSIGNED
Small integer
Value(0 - 65535)
MEDIUMINT
Medium-sized integer
Value(-8388608 to 8388607)
MEDIUMINT UNSIGNED
Medium-sized integer
Value(0 - 16777215)
INT
Normal-size integer
Value(-2147483648 to 2147483647)
INT UNSIGNED
Normal-size integer
Value(0 - 4294967295)
INTEGER
The synonym for "INT"
BIGINT
Large integer
Value(-2^63 to 2^63-1)
BIGINT UNSIGNED
Large integer
Value(0 - 2^64-1)
TINYINT
Alias for "BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE"
DECIMAL
DECIMAL[(M[,D])],
M(0 to 65digits),
D(0 to 30digits)
DEC
The synonym for "DECIMAL"
NUMERIC
The synonym for "DECIMAL"
FLOAT[M,[,D]]
Value(-3.402823466E+38 to -1.175494351E-38),
( 0 ),
(1.175494351E-38 to 3.402823466E+38)
FLOAT(d)
FLOAT(0-23) =>"4-byte single-precision FLOAT column",
FLOAT(24-53) =>" 8-byte double-precision DOUBLE column"
DOUBLE
Value(-1.7976931348623157E+308 to -2.2250738585072014E-308),
( 0 ),
( 2.2250738585072014E-308 to 1.7976931348623157E+308)
management
list databases
SHOW DATABASES;
select a database
USE database_name;
list tables in a db
SHOW TABLES;
describe the format of a table
DESCRIBE table;(desc table_name)
create a database
CREATE DATABASE db_name;
create a table
CREATE TABLE table_name (field1_name TYPE(size), field2_name TYPE(size));
load data into a table
LOAD DATA LOCAL INFILE "data.txt" INTO TABLE table_name;
insert data
INSERT INTO table_name VALUES ('name', 'age', 'dep');
select
SELECT from_columns FROM table_name WHERE conditions;
select all values
SELECT * FROM table_name
select some values
SELECT * FROM table_name WHERE field_name = "value"
select values filtered by multiple critera
SELECT * FROM TABLE WHERE filed1_name= "value1" AND filed2_name= "value2"
update data
UPDATE table_name SET column_name = "new_value" WHERE field_name = "value"
sort
SELECT field1, field2 FROM table_name ORDER BY field2
counting rows
SELECT COUNT(*) FROM table_name
counting by group
SELECT dept, COUNT(*) FROM tbl_name GROUP BY dept;