More SQL Data Definitions: Database Systems Lecture 6
More SQL Data Definitions: Database Systems Lecture 6
• Example:
Student Student
Student
INSERT INTO Student
VALUES (2, ‘Mary’, ID Name Year
3) 1 John 1
2 Mary 3
More SQL Data Definition
Duplicates?
• Remember that a relation (table) is just a set.
DELETE FROM
• Some versions of SQL also have TRUNCATE TABLE <T>
<table>
which is like DELETE FROM <T> but it is quicker as it
doesn’t record its actions
[WHERE
<condition>]
Student
DELETE FROM ID Name Year
Student Student 1 John 1
ID Name Year WHERE Year = 2 2 Mark 3
1 John 1
2 Mark 3
3 Anne 2
4 Mary 2
Student
DELETE FROM Student
or ID Name Year
TRUNCATE TABLE Student
• Detailsare
These differ
useful
between
as primary
versions
keys
• Using integers
Usually the firsttoentry
reference
is assigned
rows is1,more
the next
efficient
2, and
• so
Weon.
would like the DBMS to do this
• Using a sequence
SELECT mySeq.nextVal FROM DUAL;