SQL (Structured Query Language)

4.10.4 (7 questions). Public Notes: AQA's A Level Computer Science

Delete syntax SQL

DELETE FROM table WHERE attribute = “A”

Update syntax SQL

UPDATE table SET attribute = 2, attr2 = 3 WHERE pKey = 000

Insert new record syntax SQL

INSERT INTO table(attr1, attr2, attr3) VALUES (1,2,3)

Remove a table syntax SQL

ALTER TABLE table DROP attr

Add an column to a table syntax SQL

ALTER TABLE table ADD attr3

Change the data type of a column syntax SQL

ALTER TABLE MODIFY attr INT, NOT NULL

Create a table syntax SQL

CREATE TABLE table (
Attr1 INT, NOT NULL
Attr2 VARCHAR(20), NOT NULL
Attr3 CHAR(5), NOT NULL
PRIMARY KEY (Attr1, attr2)
FOREIGN KEY attr3 REFERENCES table2(attr3) )