02- DML

Data Manipulation Language

INSERT INTO (ShortHand)

ALTER TABLE FK:

ALTER TABLE RENAME COLUMN:

ALTER TABLE ADD COLUMN:

DROP TABLE:

ALTER TABLE DROP COLUMN:

ALTER TABLE ADD COLUMN AFTER COLUMN:

1 de noviemvbre

SELECT LIMIT (whith offset)

SELECT OFFSET

SELECT SEARCH(LIKE: Star with W)

SELECT SEARCH(LIKE: End with e)

SELECT SEARCH(LIKE: Contains)

SELECT SEARCH( NOT LIKE: Contains)

SELECT SEARCH(LIKE: Complete)

SELECT SEARCH(IN)

SELECT (ALIAS: Two Tables)

List all trainers with their pokemons

SELECT (ALIAS: Two Tables with ORDER BY)

List all trainers with their pokemons ordered desc

SELECT (ALIAS: Two Tables with AND OR & ORDER BY)

List all trainers with their pokemons type water or fire

SELECT (ALIAS: Two Tables - COUNT)

List trainer with number of pokemons

SELECT (ALIAS: Three Tables)

List all trainers with their pokemons and gyms

SELECT (INNER JOIN: Three Tables )

List all trainers with their pokemons and gym

SELECT (LEFT JOIN: Three Tables )

List all trainers with their pokemons and gym

SELECT (RIGHT JOIN: Three Tables )

List all trainers with their pokemons and gym

SELECT (UNION: Three Tables )

List all trainers, pokemons and gym in one column

CREATE VIEW

Create a view that contains all trainers with their pokemons and gym

SHOW VIEW

Show a view that contains all trainers with their pokemons and gym

UPDATE

One field Two or more fields

DELETE

One row ALL rows

TRANSACTION

Begin a trnsaction, delete somethinf, rollback
-- Insert Short INSERT INTO trainers VALUES ( DEFAULT, "Ash Ketchum", 2, 1); INSERT INTO trainers VALUES ( DEFAULT, "Misty", 4, 2); INSERT INTO trainers VALUES ( DEFAULT, "Brok", 6, 2); -- Insert Long INSERT INTO trainers (id, name, level, gym_id) VALUES ( DEFAULT, "Serena", 4, 2); INSERT INTO trainers (id, name, level, gym_id) VALUES ( DEFAULT, "Oak", 9, 1); INSERT INTO pokemons VALUES ( DEFAULT, 'pikachu', 'Electric', 90, 80, 96, 79, 1); INSERT INTO pokemons VALUES ( DEFAULT, 'charmander', 'Fire', 95, 78, 80, 82, 1); INSERT INTO pokemons VALUES ( DEFAULT, 'bulbasaour', 'Grass', 80, 88, 70, 75, 1); INSERT INTO pokemons VALUES ( DEFAULT, 'squirtle', 'Water', 70, 90, 75, 90, 1); INSERT INTO pokemons VALUES ( DEFAULT, 'Snorlax', 'Normal', 180, 320, 50, 180, 1); INSERT INTO pokemons VALUES ( DEFAULT, 'Vaporeon', 'Water', 186, 260, 90, 168, 1); INSERT INTO pokemons VALUES ( DEFAULT, 'Lapras', 'Water', 111, 255, 100, 168, 1); INSERT INTO pokemons VALUES ( DEFAULT, 'Blastoise', 'Water', 720, 158, 70, 222, 1); INSERT INTO pokemons VALUES ( DEFAULT, 'Golem', 'Water', 500, 160, 80, 198, 1); INSERT INTO pokemons VALUES ( DEFAULT, 'Dragonite', 'Dragon', 900, 250, 120, 182, 1); INSERT INTO pokemons VALUES ( DEFAULT, 'Exeggutor', 'Grass', 596, 190, 90, 232, 1); INSERT INTO pokemons VALUES ( DEFAULT, 'Omaster', 'Rock', 1500, 140, 112, 202, 1); INSERT INTO pokemons VALUES ( DEFAULT, 'Muk', 'Poison', 1070, 210, 112, 180, 1); INSERT INTO pokemons VALUES ( DEFAULT, 'Onix', 'Rock', 662, 70, 80, 90, 1); INSERT INTO pokemons VALUES ( DEFAULT, 'Poliwag', 'Water', 815, 80, 70, 108, 1); INSERT INTO pokemons VALUES ( DEFAULT, 'Mankey', 'Water', 563, 80, 70, 122, 2); INSERT INTO pokemons VALUES ( DEFAULT, 'Magnemite', 'Electric', 750, 50, 40, 128, 2); INSERT INTO pokemons VALUES ( DEFAULT, 'Pidgey', 'Normal', 818, 80, 95, 90, 2); INSERT INTO pokemons VALUES ( DEFAULT, 'Gastly', 'Ghost', 750, 60, 60, 82, 2); INSERT INTO pokemons VALUES ( DEFAULT, 'Rattata', 'Normal', 810, 60, 65, 22, 2);