SQL(1.3.2 d) Flashcards
SQL
declarative query language
standardised way to add/remove/change/read data from a relational database
interacts with the abstract concept of tables
DBMS stands for
DataBase Management System
SQL select
simplest operation to find data from a single table
* = everything
SELECT * FROM Person
WHERE FirstName = “Douglas”;
SQL boolean
combining conditions with boolean
behaves as you would expect (AND, OR)
SELECT Surname FROM Person
WHERE Surname = “Adams OR PersonID = “24601”
SQL wildcards
using % as a wildcard
% means “any character(s)”
D% = D then any character(s)
SELECT Surname FROM Person
WHERE FirstName LIKE “%o”
SQL inserting
specify the table (and fields)
provide the value to insert
INSERT INTO Person (PersonID, FirstName, Surname)
VALUES (18989,, “Techno”, “Tronics”);
SQL deleting
specify the table
specify the conditions to find records to delete
DELETE FROM Person
WHERE FirstName = “Techno”;
SQL update
specify the table
specify the field to change
identify the specific record(s) you want to change
UPDATE Person
SET FirstName = “Atari”
WHERE Surname = “Sinclair”;
SQL drop
specify the table
gets banished to shadow realm
DROP TABLE Person;
SQL joins
select each field you want (from either table)
join the two tables together with a common field (e.g primary and foreign key)
JOIN many also be called INNER JOIN
SELECT ProductID, ProductName.CategoryName
FROM Product
JOIN Category ON Product.CategoryID = Category.CategoryID;