MySQL Flashcards
SQL
RDBMS?
MySQL FTW!
Start MySQL
mysql -h localhost -u root -p
Create new database
CREATE DATABASE database_name;
Change database
USE database_name;
Create new table
CREATE TABLE newTable (field1 VARCHAR(30), field2 CHAR(1) NOT NULL, field3 INT NOT NULL DEFAULT 0, field4 DATE, field5 DEC (1,2), field6 BLOB);
Describe a table
DESC newTable;
Insert data to a table
INSERT INTO myTable (field1, field2, field3) VALUES (‘val’, ‘v’, ‘1’);
Selecting data
SELECT field1 FROM myTable WHERE field2 = ‘ammatasiri’;
Arithmetic operators
AND, OR, <>, =, <, >
Arithmetic selection
SELECT field1 FROM myTable WHERE field2 = ‘ammatasiri’ AND field3 = 2;
Like? No Facebook shit!
SELECT field1 FROM myTable WHERE field2 LIKE‘ammatahu%’;
I’ve got “%” but WTF is “_” ?
SELECT * FROM myTable WHERE field2 LIKE‘_utto’;
Single quotes?
Fuck yeah! But not for INT, DEC numbers when selecting
”*” is asterisk right?
It’s a “star” retard. ESS KIU EL.
Between
SELECT * FROM myTable WHERE field5 BETWEEN 5 and 10;