DELETE FROM table_name
WHERE some_column=some_value;
UPDATE Customers
SET City='Hamburg'
WHERE CustomerID=1;
SELECT column_name(s)
FROM table_name
WHERE column_name LIKE pattern;
SELECT column_name(s)
FROM table_name
WHERE column_name IN (value1,value2,...);
SELECT column_name(s)
FROM table_name
WHERE column_name BETWEEN value1 AND value2;
SELECT column_name AS alias_name
FROM table_name;
SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate
FROM Orders
INNER JOIN Customers
ON Orders.CustomerID=Customers.CustomerID;
SELECT column_name(s)
FROM table1
INNER JOIN table2
ON table1.column_name=table2.column_name;
SELECT column_name(s)
FROM table1
LEFT JOIN table2
ON table1.column_name=table2.column_name;
SELECT column_name(s)
FROM table1
RIGHT JOIN table2
ON table1.column_name=table2.column_name;
CREATE DATABASE dbname;
CREATE TABLE table_name
(
column_name1 data_type(size),
column_name2 data_type(size),
column_name3 data_type(size),
....
);
CREATE TABLE Persons
(
P_Id int NOT NULL,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Address varchar(255),
City varchar(255),
PRIMARY KEY (P_Id)
)
CREATE TABLE Orders
(
O_Id int NOT NULL,
OrderNo int NOT NULL,
P_Id int,
PRIMARY KEY (O_Id),
FOREIGN KEY (P_Id) REFERENCES Persons(P_Id)
)
CREATE TABLE Persons
(
P_Id int NOT NULL,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Address varchar(255),
City varchar(255),
CHECK (P_Id>0)
)
DROP INDEX index_name ON table_name
ALTER TABLE table_name DROP INDEX index_name
ALTER TABLE table_name
ADD column_name datatype
ALTER TABLE table_name
DROP COLUMN column_name
CREATE VIEW view_name AS
SELECT column_name(s)
FROM table_name
WHERE condition
SELECT * FROM Orders WHERE OrderDate='2008-11-11'
SELECT LastName,FirstName,Address FROM Persons
WHERE Address IS NULL
SELECT AVG(column_name) FROM table_name
SELECT COUNT(column_name) FROM table_name;
SELECT FIRST(column_name) FROM table_name;
SELECT LAST(column_name) FROM table_name;
SELECT MAX(column_name) FROM table_name;
sELECT MIN(column_name) FROM table_name;
SELECT SUM(column_name) FROM table_name;
SELECT column_name, aggregate_function(column_name)
FROM table_name
WHERE column_name operator value
GROUP BY column_name;
SELECT column_name, aggregate_function(column_name)
FROM table_name
WHERE column_name operator value
GROUP BY column_name
HAVING aggregate_function(column_name) operator value;
SELECT UCASE(column_name) FROM table_name;
WHERE some_column=some_value;
UPDATE Customers
SET City='Hamburg'
WHERE CustomerID=1;
SELECT column_name(s)
FROM table_name
WHERE column_name LIKE pattern;
SELECT column_name(s)
FROM table_name
WHERE column_name IN (value1,value2,...);
SELECT column_name(s)
FROM table_name
WHERE column_name BETWEEN value1 AND value2;
SELECT column_name AS alias_name
FROM table_name;
SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate
FROM Orders
INNER JOIN Customers
ON Orders.CustomerID=Customers.CustomerID;
SELECT column_name(s)
FROM table1
INNER JOIN table2
ON table1.column_name=table2.column_name;
SELECT column_name(s)
FROM table1
LEFT JOIN table2
ON table1.column_name=table2.column_name;
SELECT column_name(s)
FROM table1
RIGHT JOIN table2
ON table1.column_name=table2.column_name;
CREATE DATABASE dbname;
CREATE TABLE table_name
(
column_name1 data_type(size),
column_name2 data_type(size),
column_name3 data_type(size),
....
);
CREATE TABLE Persons
(
P_Id int NOT NULL,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Address varchar(255),
City varchar(255),
PRIMARY KEY (P_Id)
)
CREATE TABLE Orders
(
O_Id int NOT NULL,
OrderNo int NOT NULL,
P_Id int,
PRIMARY KEY (O_Id),
FOREIGN KEY (P_Id) REFERENCES Persons(P_Id)
)
CREATE TABLE Persons
(
P_Id int NOT NULL,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Address varchar(255),
City varchar(255),
CHECK (P_Id>0)
)
DROP INDEX index_name ON table_name
ALTER TABLE table_name DROP INDEX index_name
ALTER TABLE table_name
ADD column_name datatype
ALTER TABLE table_name
DROP COLUMN column_name
CREATE VIEW view_name AS
SELECT column_name(s)
FROM table_name
WHERE condition
SELECT * FROM Orders WHERE OrderDate='2008-11-11'
SELECT LastName,FirstName,Address FROM Persons
WHERE Address IS NULL
SELECT AVG(column_name) FROM table_name
SELECT COUNT(column_name) FROM table_name;
SELECT FIRST(column_name) FROM table_name;
SELECT LAST(column_name) FROM table_name;
SELECT MAX(column_name) FROM table_name;
sELECT MIN(column_name) FROM table_name;
SELECT SUM(column_name) FROM table_name;
SELECT column_name, aggregate_function(column_name)
FROM table_name
WHERE column_name operator value
GROUP BY column_name;
SELECT column_name, aggregate_function(column_name)
FROM table_name
WHERE column_name operator value
GROUP BY column_name
HAVING aggregate_function(column_name) operator value;
SELECT UCASE(column_name) FROM table_name;
ConversionConversion EmoticonEmoticon