Data language types within SQL
Outline the difference between data language types within structured query language (SQL)
In this lesson
- What data definition language (DDL) and data manipulation language (DML) are for
- The SQL statements that define data structures: CREATE, ALTER and DROP
- The SQL statements that work with the data itself: SELECT, INSERT, UPDATE and DELETE
- Where data control language (DCL) and transaction control language (TCL) fit in
LearnFour kinds of SQL statement
SQL (Structured Query Language) is the language used to work with relational databases. Its statements fall into groups according to what they act on.
LearnDefining structures with DDL
LearnWorking with data using DML
CheckWhich language?
Classify each statement.
ALTER TABLE Item RENAME COLUMN ItemDesc TO Title;UPDATE Item SET ItemCost = 99 WHERE ItemID = 7;REVOKE DELETE ON Item FROM intern;ROLLBACK;CREATE TABLE Review (ReviewID INT PRIMARY KEY, Stars INT);SELECT * FROM Review;
LabBuild and fill
Use DDL to define structures and DML to work with the data of the print shop. Each task is checked on a fresh copy of the database.
This lab runs a real PostgreSQL database inside your browser, so your SQL is never sent anywhere. Starting it downloads about 5 MB the first time.
ExamWorked exam answer
Outline one difference between DDL and DML, with an example of each.
[3]ReviewMistakes examiners see
SELECT belongs to DML even though it only reads data: it works with the data, not the structure. (Some books call SELECT data query language, DQL.)
In CREATE TABLE answers, give every column a data type and mark the primary key; examiners look for both.
Exam practiceExam-style questions
5 questions · 11 marks. Answer each one first, then mark it yourself against the markscheme. Your answers are saved in this browser only.
A climbing gym is setting up a database. Members have an ID number, a name, an email address and the date they joined. Receptionists use the database every day to record visits.
Construct an SQL statement to create the table Member, with a suitable data type for each column, MemberID as the primary key and a name that must always be given.
The gym now wants to record each member's phone number. Construct an SQL statement, with a suitable data type, to change the table.
Before the gym opens, the developer must remove the test members entered during testing. Explain whether DELETE FROM Member; or DROP TABLE Member; should be used.
Identify whether each of these statements is DDL or DML: (i) INSERT INTO Visit VALUES (…); (ii) DROP TABLE Visit;
The developer runs ALTER TABLE Member DROP COLUMN Email; Outline the effect on the data already stored in Member.
0 of 5 questions marked. Mark every question to see your total.
Exam-style questions written for Praxis IB in the format of the 2027 specimen papers. They are not IB past-paper questions.