Structured Query Language (SQL)
Structured Query Language (SQL)
(SQL)
1
Attribute (or)
Field
Record (or)
Tuple
3
Data Manipulation Language (DML):
4
Data type
VARCHAR2
5
Number data type
Date
DDL Commands
-CREATE
-ALTER
-DROP
-TRUNCATE
7
CREATE command
Syntax:
CREATE TABLE table-name (Fieldname1 data_type ,
Fieldname2 data_type , …. ….. ….)
Example
CREATE TABLE Sailors (sid NUMBER(2), sname
VARCHAR2(20), rating NUMBER(2))
ALTER command
DROP command
▪Used to delete an existing table
Syntax: DROP TABLE tablename
Example: DROP TABLE Sailors
TRUNCATE command
▪TRUNCATE Removes all rows from a table without
backup
INSERT command
Inserting record into a table
Syntax: INSERT INTO table-name VALUES
(field1,field2,…)
Example:
INSERT INTO Sailors values (22,'Dustin',7,45.0)
UPDATE command
For modifying attribute values of (some) tuples in a table
Syntax: UPDATE tablename SET column1=value1,…,
columnn=valuen WHERE condition
Example: UPDATE Sailors SET age=34.5 WHERE sid=22
DELETE command
Removing specified rows from a table
Syntax: DELETE FROM tablename WHERE condition
Example: DELETE FROM Sailors WHERE sid=22
12
Removing all rows from a table
Syntax: DELETE FROM tablename
Example: DELETE FROM Sailors
13
Fig 4.3 Reserves table
14