Structured Query Language : "Select", "Insert", "Update", "Delete", "Create", and "Drop" = Equal > Greater than < Less than >= Greater than or equal <= Less than or equal <> Not equal to LIKE *See note below Andmete pärimine: SELECT eesnimi, perenimi, vanus FROM isikuinfotabel WHERE eesnimi = 'Juhan'; SELECT * FROM isikuinfotabel WHERE vanus = 30; SELECT * FROM isikuinfotabel WHERE eesnimi LIKE 'J%'; SELECT * FROM isikuinfotabel WHERE eesnimi LIKE '%uha%'; SELECT * FROM isikuinfotabel WHERE eesnimi LIKE '%n'; Kuva unikaalsed vasted: SELECT DISTINCT vanus FROM tabelinimi; Kuva üldine keskmine: SELECT AVG(palk) FROM isikud WHERE amet = 'Arendaja'; Kuva ridade arv tabelis: SELECT Count(*) FROM isikud; Kuva max palk osakondade kaupa: SELECT max(palk), osakond FROM isikud GROUP BY osakond; Summeerimine: SELECT SUM(kogus) AS TellimusedKokku FROM tellimused; Tingimuste seadmine: SELECT osakond, avg(palk) FROM isikud GROUP BY osakond HAVING avg(palk) > 2000; Kuva linnade kaupa z-a: SELECT * FROM kliendid ORDER BY linn DESC; Kuva linnade kaupa a-z: SELECT * FROM kliendid ORDER BY linn; Valikuline linnade otsimine: SELECT * FROM kliendid WHERE linn IN ('Tallinn','Tartu'); Vahemikus otsimine: SELECT * FROM tooted WHERE hind BETWEEN 10 AND 20; Tabeli loomine: CREATE TABLE tabelinimi (eesnimi varchar(15), perenimi varchar(20), vanus number(3), aadress char(30), linn varchar(20), kuupv date(20)); Tabelisse uue rea sisestamine: INSERT INTO tabelinimi (eesnimi, perenimi, vanus) VALUES ('Juhan','Juurikas','30'); Tabeli rea uuendamine: UPDATE tabelinimi SET eesnimi ='Juhan', vanus ='50' WHERE perenimi ='Juurikas'; Kõigi andmete muutmine: UPDATE tabelinimi SET eesnimi ='Juhan', vanus ='100'; Tabelist rea kustutamine: DELETE FROM tabelinimi WHERE eesnimi ='Juhan' AND perenimi ='Juurikas'; Kõikide ridade kustutamine tabelist: DELETE FROM tabelinimi; DELETE * FROM tabelinimi; Tabeli, andmebaasi kustutamine: DROP TABLE table_name DROP DATABASE database_name Tabelist kõikide ridade kustutamine: TRUNCATE TABLE table_name Tabeli muutmine: ALTER TABLE table_name ADD column_name datatype; Tabelite ühendamine: SELECT Customers.CustomerName, Orders.OrderID FROM Customers INNER JOIN Orders ON Customers.CustomerID=Orders.CustomerID ORDER BY Customers.CustomerName; Matemaatilised funktsioonid: ABS(x) returns the absolute value of x SIGN(x) returns the sign of input x as -1, 0, or 1 (negative, zero, or positive respectively) MOD(x,y) modulo - returns the integer remainder of x divided by y (same as x%y) FLOOR(x) returns the largest integer value that is less than or equal to x CEILING(x) or CEIL(x) returns the smallest integer value that is greater than or equal to x POWER(x,y) returns the value of x raised to the power of y ROUND(x) returns the value of x rounded to the nearest whole integer ROUND(x,d) returns the value of x rounded to the number of decimal places specified by the value d SQRT(x) returns the square-root value of x