SQL Quries
SQL Quries
Introduction
2
5
SQL Indexes
6
INSERT
Used to enter data into table
Syntax:
INSERTINTO columnname
VALUES (value1, value2, … , valuen);
Adding Table Rows (continued)
9
SELECT
Used to list contents of table
Syntax:
SELECTcolumnlist
FROM tablename;
Columnlist represents one or more attributes,
separated by commas
Asterisk can be used as wildcard character to list
all attributes
Updating Table Rows
11
UPDATE
Modify data in a table
Syntax:
UPDATE tablename
SET columnname = expression [, columname = expression]
[WHERE conditionlist];
If more than one attribute is to be updated in row,
separate corrections with commas
Deleting Table Rows
12
DELETE
Deletes a table row
Syntax:
DELETE
FROM tablename
[WHERE conditionlist ];
WHERE condition is optional
If WHERE condition is not specified, all rows from
specified table will be deleted
Selecting Rows with
13
Conditional Restrictions
Select partial table contents by placing restrictions
on rows to be included in output
Addconditional restrictions to SELECT statement, using
WHERE clause
Syntax:
SELECTcolumnlist
FROM tablelist
[ WHERE conditionlist ] ;
Selecting Rows with
Conditional Restrictions (continued)
14
Arithmetic Operators:
15
The Rule of Precedence
Perform operations within parentheses
Perform power operations
Perform multiplications and divisions
Perform additions and subtractions
Arithmetic Operators:
The Rule of Precedence (continued)
16
Special Operators
17
BETWEEN
Used to check whether attribute value is within a range
IS NULL
Used to check whether attribute value is null
LIKE
Used to check whether attribute value matches given
string pattern
Special Operators (continued)
18
IN
Used to check whether attribute value matches any
value within a value list
EXISTS
Used to check if subquery returns any rows
Advanced Data Definition Commands
19
DROP
Deletes table from database
Syntax:
DROP TABLE tablename;
Advanced Select Queries
26
27