Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
SQL
SQL What is it ?
A powerful,
set oriented,
non-procedural
Non-proprietary
Language created to perform tasks such as update or
retrieve data from relational databases
First introduced by IBM in mid 70s
First commercial version by Oracle corporation in 79,
followed by IBM in 80
Available on ALL platforms from PC to mainframes
CS 53
Ramasesha Mudigere
. Contd. 2
SQL is ..
1. An interactive query language for ad-hoc queries
2. A database programming language
3. A combo of data definition, manipulation &
administration commands
4. Provides features, for data validation and transaction
support in a multi-user environment
5. Most appropriate language for networked database
servers
6. The flexible language that can be used for any data
storage and access
CS 53
Ramasesha Mudigere
SQL is ..
1. An interactive query language for ad-hoc queries
A
T
2. A database programming language e
A
h
D
t
f
r
o
3. A combo of data definition, manipulation
&l
o
f
o
r
t
administration commands nca
n
o
c
a
r
f
d and transaction
n
4. Provides features, for
data
validation
a
a
u
g
n
n
o
support in a multi
li -usernenvironment
ti
i
i
e
f
h
e
5. Most appropriate
language
for
networked
database
T
d
,
n
o
servers
i
t
a
l
u
p
6. The flexible
i language that can be used for any data
n
a
m and access
storage
CS 53
Ramasesha Mudigere
History Of SQL
In 1974, D. Chamberlin (IBM San Jose Laboratory)
defined language called Structured English Query
Language (SEQUEL)
A revised version, SEQUEL/2, was defined in 1976 but
name was subsequently changed to SQL for legal
reasons
IBM subsequently produced a prototype DBMS called
System R, based on SEQUEL/2
In late 70s, ORACLE appeared and was probably first
commercial RDBMS based on SQL
CS 53
Ramasesha Mudigere
SQL Standards
Ramasesha Mudigere
. Contd.6
SQL Standards
SQL 1999 ( A.k.a. SQL3)
Ramasesha Mudigere
SQL Standards
s s.
u
l
p
e
r
,
SQL 1999 ( A.k.a. SQL3)
u
s at
e
r
u y fe
t
a
The current version of SQL standards
e tar
f
2 ri e
9
p
Over 5 times the size of SQL-92
L
o
r
Q lp
S
ll , ci a
Included OO features and stored
procedures
a
t spe
o
n
f
i
&features are still not
Most DBMSs conform .. but
some
,
t
s
s ard
o
implemented by some
mvendors.
d
r
n
e sta
f
f
oSQL4)
r
SQL 2003 ( A.k.a.
s
e
t
m
a
l
e
t
s
m
y
Proposed
new
Standard
o
s
r
f
l
a
s
i
t
c
e
r
XML
Extensions
and
s
e
e
m tur
m
a
-1999 bug fixes
e
Co SQL
f
g
n
i
y
r
CS v53
Ramasesha Mudigere
8
a
SQL
Today,
300+ vendors of SQL products on various platforms
like
DB2, Oracle, Sybase, Informix, Microsoft SQL Server,
MSAccess, Ingress, MYSQL etc..
Most of them also have their own additional proprietary
extensions that are usually only used on their system
Has gone ( rather going ) through several revisions and
standardizations by ANSI
CS 53
Ramasesha Mudigere
SQL Commands
Can be Grouped as:
1. DML Component ) To manipulate data in the Tables
2. DDL Component ) To Add / Change / Delete Tables
3. Admin. Component ) To Control & manage access
permissions
4. Programming Component ) To access Database
in procedural way
5. Transaction Support ) To run transactions in a
multi-user environment
CS 53
Ramasesha Mudigere
10
2. UPDATE
3. INSERT
4. DELETE
CS 53
11
2. DROP
To delete the tables
3. ALTER
To add or delete columns from a table, and
To change the specification on an existing
column
CS 53
Ramasesha Mudigere
12
2. DROP
To delete the users
3. GRANT
To provide specific access permissions to users
4. REVOKE
To withdraw access permissions from users
CS 53
Ramasesha Mudigere
13
2. OPEN
To enable / activate CURSORS
3. FETCH
To get data rows based on CURSOR
4. CLOSE
To disable /deactivate the cursor
CS 53
Ramasesha Mudigere
14
2. COMMIT
To make the changes done by a a transaction
permanent
3. ROLLBACK
To undo the changes done by a transaction
4. SAVEPOINT
To create an intermediary commit point
CS 53
Ramasesha Mudigere
15
DDL
ADMIN
Support
SELECT
CREATE
CREATE
PGM
Support
TXN
Support
DECLARE
BEGIN
OPEN
UPDATE
DROP
DROP
INSERT
ALTER
GRANT
FETCH
ROLLBACK
REVOKE
CLOSE
SAVEPOINT
DELETE
CS 53
Ramasesha Mudigere
COMMIT
16
CS 53
Ramasesha Mudigere
17
2. UPDATE
3. INSERT
4. DELETE
CS 53
18
SELECT
The most common and most used verb in SQL
The one ( and only one) basic command used to
retrieve data from column (s) of Table (s)
NOT to be confused with the SELECT operation of
Relational Algebra
So many options and flavor are available making it one
of the most versatile and powerful commands
Can vary from very simple to most Complex command
depending on options and parameters used
CS 53
Ramasesha Mudigere
19
[ WHERE
[ GROUP BY
[ HAVING
[ ORDER BY
Ramasesha Mudigere
20
SQL statement
processing order
CS 53
Ramasesha Mudigere
22
SQL statement
processing order
CS 53
Ramasesha Mudigere
23
2.
3.
4.
Ramasesha Mudigere
O/P Same As Q3
24
CS 53
Ramasesha Mudigere
25
OR
NAME
Ramasesha Mudigere
ANNUAL_SALARY
26
CS 53
Ramasesha Mudigere
27
CS 53
Ramasesha Mudigere
B
28
DNO = 4 ( 3 rows )
Comparison operators allowed are:
CS 53
Ramasesha Mudigere
29
Ramasesha Mudigere
30
CS 53
Ramasesha Mudigere
31
CS 53
Ramasesha Mudigere
32
Ramasesha Mudigere
33
CS 53
Ramasesha Mudigere
34
Ramasesha Mudigere
35
CS 53
Ramasesha Mudigere
36
Ramasesha Mudigere
37
CS 53
Ramasesha Mudigere
38
ORDER BY Clause
Generally, the order of rows is immaterial to the DBMS
Results when displayed are in no defined order
Rows can displayed in the order in which they were
entered
However:
ORDER BY clause lists data in a specific order
Last part of SQL statement that controls order of records
returned
ASC Ascending Order (Default order )
DESC Descending Order
CS 53
Ramasesha Mudigere
39
ORDER BY Example
CS 53
Ramasesha Mudigere
40
ORDER BY Example
SQL> SELECT ename, job, deptno, hiredate
2 FROM
emp
3 ORDER BY hiredate DESC;
ENAME
JOB
DEPTNO
---------- --------- --------ADAMS
CLERK
20
SCOTT
ANALYST
20
MILLER
CLERK
10
JAMES
CLERK
30
FORD
ANALYST
20
KING
PRESIDENT
10
MARTIN
SALESMAN
30
...
1453 rows selected.
CS
Ramasesha Mudigere
HIREDATE
--------12-JAN-83
09-DEC-82
23-JAN-82
03-DEC-81
03-DEC-81
17-NOV-81
28-SEP-81
41
Ramasesha Mudigere
42
CS 53
Ramasesha Mudigere
43
CS 53
ENAME
-------KING
ename, mgr
emp
mgr IS NULL;
MGR
---------
Ramasesha Mudigere
44
3. AVG
4. MIN
5. MAX
returns largest value in specified column
All operators (Except count) used only on numeric data
ignoring NULL values, if any, are encountered
CS 53
Ramasesha Mudigere
45
COUNT
CS 53
Ramasesha Mudigere
46
CS 53
Ramasesha Mudigere
47
Ramasesha Mudigere
48
GROUP BY Clause
Intimately connected with Aggregates
Allows data to be:
Ramasesha Mudigere
49
GROUP BY Example
Consider the Table
CS 53
Ramasesha Mudigere
50
GROUP BY Example
SELECT DNO, MAX (SALARY) FROM EMPLYEE
GROUP BY DNO ORDER BY DNO
DNO
1
4
5
MAX (SALARY)
5500
4300
4000
Ramasesha Mudigere
51
CS 53
Ramasesha Mudigere
52
HAVING Clause
Designed for use with GROUP BY
Restricts groups that appear in final result table
Similar to WHERE, but WHERE filters individual rows whereas
HAVING filters groups
Column names in HAVING clause must also appear in the
GROUP BY list or be contained within an aggregate function
CS 53
Ramasesha Mudigere
53
CS 53
Ramasesha Mudigere
54
INNER
Ramasesha Mudigere
Query
56
Ramasesha Mudigere
57
EMPLOYEE TABLE
CS 53
Ramasesha Mudigere
58
Ramasesha Mudigere
59
Ramasesha Mudigere
60
Ramasesha Mudigere
62
EMPLOYEE TABLE
CS 53
Ramasesha Mudigere
63
CS 53
Ramasesha Mudigere
64
Ramasesha Mudigere
65
EMPLOYEE TABLE
CS 53
Ramasesha Mudigere
66
Ramasesha Mudigere
67
EXISTS Example
Consider Employee table
List all Names & department where at least one female
employee is working
SELECT LNAME, DNO FROM EMPLOYEE E
WHERE EXISTS ( SELECT * FROM EMPLOYEE M
WHERE E.DNO = M.DNO
= F )
AND M.SEX
M.
Ramasesha Mudigere
68
Ramasesha Mudigere
69
Ramasesha Mudigere
70
Ramasesha Mudigere
71
Name
Suresh
Sheela
Milind
Rajani
Phone
4563
7749
2275
9341
Pref
House
Flat
Flat
House
MaxRent
2000
1800
2000
2500
Property
PA14
PG4
PG4
PG36
Date Viewed
24-may-03
20-may-03
26-may-03
28-may-03
Ramasesha
Mudigere
Comments
Too Small
Too far
Looks OK
72
Notes
All the above 3 replace both FROM and WHERE in the SQL
First one produces a result with ID column appearing twice
CS 53
Ramasesha Mudigere
73
Ramasesha Mudigere
74
Populated Database
2
5
4
6
CS 53
Ramasesha Mudigere
75
SELECT
FNAME, LNAME, ADDRESS
FROM EMPLOYEE, DEPARTMENT
WHERE
DNAME='Research' AND
DNUMBER=DNO
Ramasesha Mudigere
76
SELECT
E.FNAME, E.LNAME, S.FNAME, S.LNAME
FROM
EMPLOYEE AS E S
WHERE
E.SUPERSSN=S.SSN
Note the use of on table employee as two different tables
for join with two different alias names E and S
We can think of E and S as two different copies of
EMPLOYEE, representing employees in role of
supervisees and supervisors respectively
Ramasesha Mudigere
77
OUTER JOIN
If one row of a joined table is unmatched, row is
omitted from result table of a JOIN.
Outer join operations retain rows that do not satisfy the
join condition.
Outer join can be
LEFT
Rows from left Table are retained
RIGHT
Rows from the right table are retained or
FULL
Rows from the Both tables are retained
CS 53
Ramasesha Mudigere
78
Ramasesha Mudigere
79
CS 53
Ramasesha Mudigere
80
CS 53
Ramasesha Mudigere
81
CS 53
Ramasesha Mudigere
82
Ramasesha Mudigere
83
Ramasesha Mudigere
84
OR
SELECT * FROM Branch
INTERSECT CORRESPONDING BY city
SELECT * FROM Property
CS 53
Ramasesha Mudigere
85
OR
SELECT * FROM Branch
Ramasesha Mudigere
86
Ramasesha Mudigere
87
2. UPDATE
3. INSERT
4. DELETE
CS 53
88
Ramasesha Mudigere
89
UPDATE Example
1. Give all staff a 3% pay increase.
UPDATE Staff SET salary = salary*1.03;
Ramasesha Mudigere
90
2. UPDATE
3. INSERT
4. DELETE
CS 53
91
Ramasesha Mudigere
92
INSERT Example
SQL> INSERT INTO department (deptno, dname, loc)
2 VALUES
(50, 'DEVELOPMENT', 'DETROIT');
1 row created.
Ramasesha Mudigere
93
2. UPDATE
3. INSERT
4. DELETE
CS 53
95
SearchCondition is optional;
If specified, only the rows that satisfy condition are deleted
if omitted, all rows are deleted ( But not the table itself !)
1. SQL> DELETE FROM department
2 WHERE
dname = 'DEVELOPMENT'
1 row deleted.
2. SQL> DELETE FROM department;
4 rows deleted.
CS 53
Ramasesha Mudigere
96
2. UPDATE
3. INSERT
4. DELETE
CS 53
97
2. DROP
To delete the tables
3. ALTER
To add or delete columns from a table, and
To change the specification on an existing
column
CS 53
Ramasesha Mudigere
98
CS 53
Ramasesha Mudigere
99
Ramasesha Mudigere
100
CS 53
INTEGER or INT
SMALLINT
FLOAT ( Precision)
or REAL
DOUBLE PREISION
Precision on FLOAT defines the precision of mantissa
Precision & size of REAL & DOUBLE PRECISION is
implementation dependent
Ramasesha Mudigere
101
. Contd.
Ramasesha Mudigere
102
1.
2.
CS 53
Ramasesha Mudigere
103
1.
2.
3.
CS 53
Ramasesha Mudigere
104
. Contd.
Ramasesha Mudigere
105
. Contd.
Ramasesha Mudigere
106
CS 53
107
Ramasesha Mudigere
108
Ramasesha Mudigere
109
CS 53
Ramasesha Mudigere
110
Description
VARCHAR2(size)
CHAR(size)
NUMBER(p,s)
DATE
LONG
CLOB
111
Ramasesha Mudigere
112
. Contd.
2. Domain Constraint
CS 53
113
. Contd.
CS 53
UNIQUE ( Tel-No)
Ramasesha Mudigere
114
. Contd.
CS 53
115
. Contd.
CS 53
Specified using ON UPDATE and ON DELETE subclauses of FOREIGN KEY clause of CREATE Statement
1. CASCADE
2. SET NULL
4. NO ACTION
Ramasesha Mudigere
116
. Contd.
Ramasesha Mudigere
117
CS 53
Ramasesha Mudigere
118
Ramasesha Mudigere
119
Ramasesha Mudigere
120
CS 53
Ramasesha Mudigere
121
CS 53
Ramasesha Mudigere
122
CS 53
Ramasesha Mudigere
123
CS 53
Ramasesha Mudigere
124
Assertions
A predicate expressing a condition that we wish the
database always to satisfy
An assertion in SQL takes the form
create assertion <assertion-name> check
<predicate>
When an assertion is made, the system tests it for
validity, and tests it again on every update that may
violate the assertion
May introduce a significant amount of overhead; hence
assertions should be used with great care.
CS 53
Ramasesha Mudigere
125
Assertions
Every loan has at least one borrower who maintains an
account with a minimum balance or $1000.00
create assertion balance_constraint check
(not exists (
select *
from loan
where not exists (
select * from borrower, depositor, account
where loan.loan_num = borrower.loan_num
and borrower.cust_name = depositor.cust_name
and depositor.acct_num = account.acct_num
and account.balance >= 1000)))
CS 53
Ramasesha Mudigere
126
2. DROP
To delete the tables
3. ALTER
To add or delete columns from a table, and
To change the specification on an existing
column
CS 53
Ramasesha Mudigere
127
DROP Command
Removes named table and all rows within it.
Format :
DROP TABLE TableName [RESTRICT | CASCADE]
Ramasesha Mudigere
128
2. DROP
To delete the tables
3. ALTER
To add or delete columns from a table, and
To change the specification on an existing
column
CS 53
Ramasesha Mudigere
129
ALTER Command
Can be used for following functions
1. Add a new column to a table.
2. Drop a column from a table.
3. Add a new table constraint.
4. Drop a table constraint.
5. Set a default for a column.
6. Drop a default for a column.
CS 53
Ramasesha Mudigere
130
Ramasesha Mudigere
131
ALTER Examples
CS 53
Ramasesha Mudigere
132
Ramasesha Mudigere
133
VIEWS in RDBMS
A virtual table created dynamically with one or more
relational operations on base relations
Virtual relation that does not necessarily exist in the
DB, but is produced upon request, at time of request.
Contents of a view are defined as a query on one or
more base relations or other views
Allows full query operations ( With some restricitons)
Allows for limited update operations (since the table
may not physically be stored)
CS 53
Ramasesha Mudigere
134
. Contd.
VIEWS in RDBMS
Ramasesha Mudigere
135
. Contd.
Advantages:
Disadvantages
Use processing time each time view is referenced
May or may not be directly updateable
CS 53
Ramasesha Mudigere
136
Creation of VIEWS
Ramasesha Mudigere
137
CS 53
Ramasesha Mudigere
138
CS 53
Ramasesha Mudigere
139
AVG(e.sal)
FROM
WHERE
GROUP BY
View created.
CS 53
dept_sum_vu
employee e, department d
e.deptno = d.deptno
d.dname;
Ramasesha Mudigere
140
Group functions
A GROUP BY clause
The DISTINCT keyword
Ramasesha Mudigere
141
Ramasesha Mudigere
143
Removing Views
Done using DROP Command
DROP VIEW ViewName [RESTRICT | CASCADE]
Causes definition of view to be deleted from database.
For example:
DROP VIEW Manager3Staff;
NOTE:
Unlike the dropping of tables, the data rows still remain
even after View is dropped, since data rows belong to
base tables and NOT views
CS 53
Ramasesha Mudigere
144
INDEX
Manually
CS 53
145
emp_ename_idx
employee(ename);
Ramasesha Mudigere
146
Ramasesha Mudigere
147
2. DROP
To delete the tables
3. ALTER
To add or delete columns from a table, and
To change the specification on an existing
column
CS 53
Ramasesha Mudigere
148
2. DROP
To delete the users
3. GRANT
To provide specific access permissions to users
4. REVOKE
To withdraw access permissions from users
CS 53
Ramasesha Mudigere
149
User dropped.
scott
Ramasesha Mudigere
150
2. DROP
To delete the users
3. GRANT
To provide specific access permissions to users
4. REVOKE
To withdraw access permissions from users
CS 53
Ramasesha Mudigere
151
GRANT Command
Ramasesha Mudigere
152
GRANT Command
GRANT {PrivilegeList | ALL PRIVILEGES}
ON ObjectName TO {AuthorizationIdList | PUBLIC}
[WITH GRANT OPTION]
PrivilegeList consists of one or more of privileges
separated by commas.
ALL PRIVILEGES grants all privileges to a user
GRANT Can be executed by the owner of the table
PUBLIC allows access to be granted to all present and
future authorized users
WITH GRANT OPTION allows privileges to be passed
on
CS 53
Ramasesha Mudigere
153
GRANT Example
Give Scott full privileges to Staff table.
GRANT ALL PRIVILEGES
ON Staff
TO Scott WITH GRANT OPTION;
Give users Scott and Narayan SELECT and UPDATE
on column salary of Staff.
GRANT SELECT, UPDATE (salary)
ON Staff
TO Scott, Narayan ;
CS 53
Ramasesha Mudigere
154
Concept of ROLE
Users
Manager
Privileges
Allocating privileges
Without a role
CS 53
Ramasesha Mudigere
Allocating privileges
with a role
155
CREATE
CREATE ROLE
ROLE manager;
manager;
created.
created.
SQL>
SQL> GRANT
GRANT create
create table,
table, create
create view
view
22
to
to manager;
manager;
Grant
Grant succeeded.
succeeded.
SQL>
SQL> GRANT
GRANT manager
manager to
to BLAKE,
BLAKE, CLARK;
CLARK;
Grant
Grant succeeded.
succeeded.
CS 53
Ramasesha Mudigere
156
2. DROP
To delete the users
3. GRANT
To provide specific access permissions to users
4. REVOKE
To withdraw access permissions from users
CS 53
Ramasesha Mudigere
157
REVOKE Command
Takes away privileges granted with GRANT
The format is
REVOKE [GRANT OPTION FOR]
{PrivilegeList | ALL PRIVILEGES}
ON ObjectName
FROM {AuthorizationIdList | PUBLIC}
[RESTRICT | CASCADE]
ALL PRIVILEGES refers to all privileges granted to a
user by user revoking privileges.
CS 53
Ramasesha Mudigere
158
Ramasesha Mudigere
159
2. DROP
To delete the users
3. GRANT
To provide specific access permissions to users
4. REVOKE
To withdraw access permissions from users
CS 53
Ramasesha Mudigere
160
Database Programming
Objective: ) To access a database from an application
Ramasesha Mudigere
161
Ramasesha Mudigere
162
Solution
Try and match the DBMS data types to the
corresponding closest match in the language like:
CHAR datatype to CHAR in C and PIC X field in COBOL
NUMERIC to Char in C ( with external to care to store only
numbers) and PIC 9 fields in COBOL
CS 53
Ramasesha Mudigere
163
Ramasesha Mudigere
164
Steps IN DB Programming
How it all works ?
1. Client program opens a connection to the database server
2. Client program submits queries to and/or updates the DB
3. When database access is no longer needed, client program
terminates the connection
Ramasesha Mudigere
165
Embedding SQL
Embedded SQL starts with identifier,
usually EXEC SQL [ @SQL( in MUMPS].
Ends with terminator dependent on host language:
Ramasesha Mudigere
166
Save
Source
Module
precompiler
Pre-compile
Object
Module
ORACLE
Run Time
Library
CS 53
Compile
Modified
Source
Module
Compiler
Linker
Ramasesha Mudigere
Link
Application
Program
167
CS 53
Ramasesha Mudigere
168
Ramasesha Mudigere
169
CS 53
Ramasesha Mudigere
170
Indicator variables
Integer Variables Used to indicate the status of data
transfer between host variables and the database
Can be associated with any host language variable
Used immediately following associated host variable
with a colon (:) separating two variables.
0 in Indicator variable indicates successful transfer
Non-zero value to indicate conditions like
CS 53
171
addressInd = -1;
EXEC SQL UPDATE PrivateOwner
SET address = :address :addressInd
WHERE ownerNo = CO21;
CS 53
Ramasesha Mudigere
172
SQLCA Area
A data structure to be included in the program by the
programmer
Used ( initialized) by DBMS to indicate the status of
every SQL execution in the program
Set by DBMS after execution of each DBMS command
Contains several fields of which SQLCODE is of
special interest
CS 53
173
CS 53
Ramasesha Mudigere
174
Ramasesha Mudigere
175
CS 53
loop = 1;
while (loop) {
prompt (Enter SSN: , ssn);
EXEC SQL
select FNAME, LNAME, ADDRESS, SALARY
into :fname, :lname, :address, :salary
from EMPLOYEE where SSN == :ssn;
if (SQLCODE == 0) printf(fname, );
else printf(SSN does not exist: , ssn);
prompt(More SSN? (1=yes, 0=no): , loop);
END-EXEC
}
Ramasesha Mudigere
176
Cursor
Used when multiple rows are Expected to be returned
by SQL query
Allows host language to access rows of query one at a
time
Acts as a pointer to a row of query result
Can be advanced by one to access next row
Using of cursor:
CS 53
Must be declared
opened before it can be used and
Must be closed to deactivate it after it is no longer required
Ramasesha Mudigere
177
Ramasesha Mudigere
178
Ramasesha Mudigere
179
Dynamic SQL
SQL that does not need to be hard coded into the program
Built with character string on the fly
Example of using Dynamic SQL in C
char * sqlprog = update account
setbalance = balance * 1.05
where account-number = ?
EXEC SQL preparedynprogfrom :sqlprog;
characcount [10] = A-101;
EXEC SQL execute dynprogusing :account;
The dynamic SQL program contains a ?, which is a place
holder for a value that is provided when the SQL program is
executed.
CS 53
Ramasesha Mudigere
180
2. OPEN
To enable / activate CURSORS
3. FETCH
To get data rows based on CURSOR
4. CLOSE
To disable /deactivate the cursor
CS 53
Ramasesha Mudigere
181
Ramasesha Mudigere
182
etc..
Ramasesha Mudigere
183
SQL/PSM: An Example
CREATE FUNCTION DEPT_SIZE (IN deptno INTEGER)
RETURNS VARCHAR[7]
DECLARE TOT_EMPS INTEGER;
SELECT COUNT (*) INTO TOT_EMPS
FROM SELECT EMPLOYEE WHERE DNO = deptno;
IF TOT_EMPS > 100 THEN RETURN HUGE
ELSEIF TOT_EMPS > 50 THEN RETURN LARGE
ELSEIF TOT_EMPS > 30 THEN RETURN MEDIUM
ELSE RETURN SMALL
ENDIF;
CS 53
Ramasesha Mudigere
184
Ramasesha Mudigere
185
Ramasesha Mudigere
186
Ramasesha Mudigere
187
CS 53
188
ODBC (Contd.)
Very successful API, with virtually every database
vendor providing an ODBC driver for its database,
However
Each vendor have their own proprietary native API
(Oracle Oracle CLI, IBM ESQL/DRDA, Sybase
Sybase open client MS- SQL ODBC)
Ramasesha Mudigere
189
CS 53
Ramasesha Mudigere
190
End of Chapter
-4-
CS 53
Ramasesha Mudigere
192
SQL 92 Features
CS 53
. Contd.
193
New Predicates:
SIMILAR TO 'pattern'
(analogous to regular
expression matching)
DISTINCT objects
CS 53
Enhanced Security:
Roles
Active Database:
Triggers and Stored
Procedures
Object Orientation:
Ramasesha Mudigere
194
"
?
e
r
o
New Semantics:
New data types:
m
y
n classes of views
Broader
w
A
e
Large Objects (LOBs,
i
)
d tm queries
v
r
r
Recursive
a
e
h
CLOBs, BLOBS)
d
v
.
n Locators
o
1
a
0
t
n
y
a
S
h
BOOLEAN
l
s
6
a i0Enhanced
e Security:
1
e
s
v
i
r
R
/
g do
Composite Types: ARRAY
m
A
Roles
d
o
n
n
L
c
e
a
.
Q an esActive Database:
v
and ROW
l
S
a
s
d
r
r
I
t
e
.
u
"
t
,
v
Distinct Types
w
a
e
e
w
s
f
e
l ://w
y
Procedures
9
c
i
b
9
t
New Predicates:
r
9 ce
p
t
a
1
t
Object Orientation:
e
n
h
&
(
h
a
i
2
T SIMILAR TO 'pattern'
l
9
p
Structured types & UDT
9
m
1
o
(analogous
to regular
L
c
Methods, with Functional or
Q
f
o
S
expression
matching)
Dot Notations
s
t
li s
DISTINCT objects
CS 53
Ramasesha Mudigere
195
Ramasesha Mudigere
196
Character
String
UDT
Double-Byte
Char String
DateTime
Numeric
decimal
CS 53
CLOB
GRAPHIC
DBCLOB
VARCHAR
VARGRAPHIC
DECIMAL
floating
point
SMALLINT
INTEGER
Ramasesha Mudigere
REAL
DOUBLE
197
Ramasesha Mudigere
198
Populated Database
2
5
4
6
CS 53
Ramasesha Mudigere
199