Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Overview
Personal DBMS Vs Client/Server DBMS
Oracle 8 Environment
SQL syntax and examples
PL/SQL-introduction
Server
Personal
DBMS
NETWORK
Client A
Sends file requests to server
Receives files from server
Updates data
Sends files back to server
Client B
Sends file requests to server
Receives files from server
Updates data
Sends files back to server
Server
Client/server
DBMS
NETWORK
Client A
Sends data requests to server
Receives results from server
Sends new data or changes to server
Client B
Sends data requests to server
Receives results from server
Sends new data or changes to server
Client/Server DBMS
Minimal load on the client and the network
Performs table locking automatically
Fault tolerant in the case of client failure
File based transaction logging
Oracle 8 Environment
SQL * Plus
PL/SQL
Query Builder
Developer
Enterprise Manager
Web application server
SQL*Plus commands
Sqlplus username/password
ALTER USER user-name IDENTIFIED BY newpassword
START filename | @ filename
CLEAR SCREEN
HELP <command>
SAVE filename[.ext] REPLACE|APPEND
EXIT
SQL
Both an ANSI and ISO standard
Types of commands:
1.
2.
3.
4.
5.
DEPARTMENT
Dept
ID
Dept
Name
Location
10
Finance
Charlotte
20
Infosys
New York
30
Marketing
Woodbridge
40
Accountant
California
POSITION
Position
ID
Position
Description
QUALIFICATION
President
Qualification
ID
Qualification
Description
Manager
Doctorate
Programmer
Masters
Accountant
Bachelors
Salesman
Associates
EMPLOYEE
Emp
ID
Last
Name
First
Name
Position
ID
111
Smith
John
246
Houston
Larry
123
Roberts
Sandi
433
McCall
543
Super
ID
Hire
Date
Salary
Comm
Dept
ID
Qual
ID
04/15/60
265000
3500
10
111
05/19/67
150000
1000
40
111
12/02/91
75000
10
Alex
543
05/10/97
66500
20
Dev
Dereck
111
03/15/95
80000
2000
20
200
Shaw
Jinku
135
01/03/00
24500
3000
30
222
Chen
Sunny
123
08/15/99
35000
135
Garner
Stanley
111
02/29/96
45000
5000
10
30
Data Retrieval:
SELECT [DISTINCT | ALL] {table|view}
FROM {table | view}
[WHERE condition ]
[GROUP BY expr [, expr]]
[ORDER BY {expr} [ASC | DESC]]
select * from dept;
select deptname from dept where deptid='10';
select lname,fname from emp order by lname desc;
select max(salary) from emp group by positionid;
select deptname from dept,emp where
dept.deptid=emp.deptid and emp.empid='111';
Transaction Control:
COMMIT
ROLLBACK [ to {savepoint}]
SAVEPOINT {name}
commit;
savepoint point1;
rollback to point1;
A PL/SQL Example:
CREATE OR REPLACE PROCEDURE raise_salary (empno INTEGER,
increase REAL) IS
current_salary REAL;
salary_missing EXCEPTION;
BEGIN
SELECT salary INTO current_salary FROM emp WHERE emp.empid =
empno;
IF current_salary IS NULL THEN
RAISE salary_missing;
ELSE
UPDATE emp SET salary = salary + increase WHERE emp.empid
= empno;
END IF;
EXCEPTION
WHEN salary_missing THEN
UPDATE emp SET salary=0 where emp.empid=empno;
END raise_salary;