Dbms
Dbms
1
SQL Overview
• Structured Query Language
2
Database Languages
3
DDL
4
Naming Convention
5
Datatype
6
CREATE
7
EXAMPLE TABLE CREATION
8
Overall table definitions
9
ALTER
10
EXAMPLE ALTER
11
EXAMPLE ALTER
12
The Database Model
13
Tasks to be Completed Before Using
a New RDBMS
14
Primary Key and Foreign
Key
• Primary key attributes contain both a NOT NULL and a UNIQUE
specification example roll no.
• RDBMS will automatically enforce referential integrity for foreign
keys
• Command sequence ends with a semicolon
15
Data Manipulation
Commands
INSERT: Command to insert data into table
• Syntax - INSERT INTO tablename VALUES();
• Used to add table rows with NULL and NOT NULL
attributes
16
Data Manipulation
Commands
SELECT: Command to list the contents
• Syntax - SELECT columnlist FROM tablename;
• Wildcard character(*): Substitute for other
characters/command
37 37
SELECT Example
• Find products with standard price less than $275
22
SELECT Example–Boolean Operators
□ AND, OR, and NOT Operators for customizing
conditions in WHERE clause
By default,
processing order
of Boolean
operators is NOT,
then AND, then
OR
24
SELECT Example–Boolean Operators
25
Boolean query Bwith use of
parentheses
26
Sorting Results with ORDER
BY Clause
• Sort the results first by STATE, and within a state by the CUSTOMER
NAME
You can use single-value fields with aggregate functions if they are
included in the GROUP BY clause. 28
Qualifying Results by
Categories Using the
HAVING Clause
29
Data Manipulation
Commands
WHERE condition
• Specifies the rows to be selected
IS NULL
• Checks whether attribute value is null
LIKE
• Checks whether attribute value matches given string pattern
IN
• Checks whether attribute value matches any value within a value list
EXISTS
• Checks if subquery returns any rows
31
SQL Data Definition
Command
38
SQL Data Manipulation
Commands
39
THANK YOU