Structured Query Language (SQL)
Structured Query Language (SQL)
(SQL)
Introduction
• Also pronounced as “Sequel”
• A de-facto standard for relational DBMS
• Standard accepted by bodies like ANSI and
ISO
Introduction
• First commercial DBMS that support SQL in
1979 was Oracle
• Another form of query language is
Query-by-Example (QBE) supported by
PC-based DBMSs
History
• Relational data model introduced by
Codd in 1970
• A relational DBMS project started by
IBM was system R that included
sequel as manipulation language
History
• First commercial DBMS launched was
Oracle in 1979
• Other early DBMSs DB2, INGRES
• ANSI and ISO defined first standard of
SQL in 1986 known as SQL-86 that was
further extended to SQL-89
History
• Later two more standards known as
SQL-92 and SQL-99 were defined
• Almost all of the current DBMSs support
SQL-92 and many support SQL-99 partially
or completely
• SQL today is supported in all sort of
machines
Benefits of Standard SQL
• Reduced training cost
• Application portability
• Application longevity
• Reduced dependence on a single
vendor
• Cross-system communication
SQL
STUDENT CRS_OFFERED
SEMESTER
TEACHER
PROGRAM (prName, totSem, prCredits)
COURSE (crCode, crName, crCredits, prName)
SEMESTER (semName, stDate, endDate)
CROFRD (crCode, semName, facId)
FACULTY (facId, fName, fQual, fSal, rank)
STUDENT (stId, stName, stFName, stAdres,
stPhone, prName, curSem, cgpa)
ENROLL (stId, crCode, semName, mTerm,
sMrks, fMrks, totMrks, grade, gp)
SEM_RES (stId, semName, totCrs, totCrdts,
totGP, gpa)
SQL Commands Types
SQL commands are categorized in
three broad classes
• Data definition language (DDL)
• Data manipulation language (DML)
• Data control language (DCL)
DDL
•Create
•Alter
•Drop
Create Command
• Creating database
CREATE DATABASE db_name
Create database exam
• Next step is to create tables
• Two approaches (In Microsoft SQL Server):
– Through SQL Create command
– Through Enterprise Manager
Create Table Command