RDBMS using Oracle

2+1 Relational Database Management System Using Oracle

E-mail: kamran@niit.edu.pk

RDBMS Using Oracle
This course will cover….
n n n n n n

Oracle RDBMS Environment Advance Structured Query language (SQL) Procedural Language / Structured Query language (PL/SQL) Oracle Developer Forms (GUI) Oracle Developer Reports (GUI) Oracle database Administration

1

SQL

PL/SQL

Oracle Form Builder

Oracle Graph & Procedure Builder

Oracle Report Builder

SQL/PLSQL
n n

n

n n n n n n n

Data Types & Oracle RDBMS limits Getting information, Adding, Updating & Deleting information SQL Arithmetic, Group, Character and Date functions Creating and using views Creating Index Functions Procedures Implicit and Explicit Cursors Triggers etc.

2

Front-end Development n Oracle Forms/Reports Development • • • • Creating front -end forms and menus frontWorking with form objects Creating buttons. text items. images. blocks etc Creating reports and graphs After completion of this course you will be able to develop complete database applications using Oracle database and Oracle development Suit by writing SQL and PL/SQL reusable code 3 .

Books n OCA/OCP Introduction to Oracle 9i SQL Study Guide Exam IZ0-007 IZ0by Chip Dawes. Biju Thomas n Oracle 9i PL/SQL A Developer’s Guide By Bulusu Lakshman Oracle 9i Development by Example By Dan Hatka n Reference Books n n n n n Introduction to Oracle: SQL and PLSQL Build Internet Applications I by Oracle Press Build Internet Applications II by Oracle Press Oracle Reports by Oracle Press Oracle 8i/9i by Oracle press (OCP track student guide) 4 .

Lets begin……… Installation 5 .

5) ver. Developer 6i Free space required (approx.g for ORACLE Home Name à ora_home For Developer 6i Home Name à dev_home 6 . n e. (8.1.2 GB) Install Oracle and developer by giving different home names and at different locations.Oracle 8/8i Windows NT/2000/xp n n Oracle 8 for NT or Oracle8i ver. 1.

5 or higher and Developer 6i or Oracle 8/8i Database and Oracle 9i Development suit Oracle Database Architecture Oracle Server Instance User User Process SQL*Plus.Oracle 9i n n Oracle 9i Database Oracle 9i Development Suite Free space required (approx. … Data Files System Files 7 . VB. 3 GB) Min RAM required is 512Mb Recommended for Personal Computers Oracle 8/8i ver 8. Triggers. Constraints.1. … Server Process SQL. PL/SQL Background Processes Shared Global Area Database Tables. Indexes.

6. 5. 4. 2. Overview of the Oracle RDBMS Overview of SQL* Plus Data Types in Oracle SQL Plus Oracle RDBMS limits Getting information from a table Selecting limited rows/columns Comparison Operators 8 .SQL In Oracle RDBMS PL/SQL Oracle Form Builder Oracle Graph & Procedure Builder Oracle Report Builder Relational Database Management System Using Oracle Lecture 1 1. 3. 7.

SQL queries n What is query? Answer can be…. “Query is a request towards the database in order to retrieve information from tables” SQL Query User Query Analyzer Output Database 9 .

Database Oracle RDBMS Limits n n n n n n n n Tables Rows Columns in a table Characters in a character field Number Field Tables joined in a query Level of nested sub queries Characters in a name No Limit No Limit 254 240 105 No limit 255 30 10 .

SQL is not case sensitive. n SQL Plus SQL Plus is a program for working with an ORACLE database by using SQL language. v Create tables in a database v Store . change & retrieve information in/form the table v Perform calculations 11 .SQL n SQL (Structural Query Language) is a language which is used to manipulate data in any RDBMS.

write etc.) Transaction Control Commands v Commit & Rollback à to save or undo changes 12 . Alter. Revoke (Related to tables) (For Permissions e. read.) (Remove rows from a table.SQL commands categories SQL commands are divided into three main categories • Data Definition Language (DDL) • Data Manipulation Language (DML) • Transaction Control Commands (TCC) n Data definition language (DDL commands) Commands that are performed on a table or user v Create.) (Change data in a table. Drop v Grant.) Data Manipulation Language (DML commands) Commands that are performed on table data v SELECT DELETE INSERT UPDATE v v v (Select data in rows and columns from one or more tables.) (Add new rows to a table..g.

13 .ORACLE Sample tables n n n n EMP Bonus Dept Salgrade Connect Oracle SQL user name: Password: Database string: orcl scott tiger orcl Scott is the default user of ORACLE In you home computer use null or your computer name as Host String.

• Displays data stored in emp table 14 .The system table “tab” tab: It’s the table of tables. i. <tablename >. emp. SQL> Select * from emp . SQL> Select * from emp .e. stores the names of all the tables created by the user select * from tab. • lists all the tables created n n SELECT statement Display all data from a table SQL> Select * from <tablename>.

emp. emp.SELECT statement Display specified data from a table SQL> Select <column-name> from <table-name>. 15 . SQL> select * from dept. SQL> select empno from emp .g. <column<table- e. (Here empno is a column in Emp table) SELECT statement More Examples SQL> select ename from emp. SQL> select deptno from dept.

Suppose we have a CAR table CarNo 2344 3445 3467 9878 Color RED BLACK RED BLUE Table CAR -------------CarNo Number(4) Color char(15) 16 . The WHERE Clause WHERE clause is used when we want to select few records from a table (based on condition/criteria).. ……….Table description command SQL> desc <table-name> <tableWe use this command to display the structure (columns & data -types) of specified table.g SQL> desc emp . datae. (where emp is the table name) SQL> desc dept.

For this we will write this query SQL> select * from cars where Color = ‘RED’.CAR table CarNo 2344 3445 3467 9878 Color RED BLACK RED BLUE Suppose we want to select RED cars only.What will be the query if we want to select car whose number is 2344? 2. 1.Select car-numbers from car table carwhose color is RED? Comparison Operators n n n n n n n n n = ! = or <> > >= < <= BETWEEN …AND… IN (list) LIKE Equal to Not equal to Grater then Grater then equal to less then less then equal to between two values any of a list of values Match a character pattern 17 .

SQL> select * from emp where sal != 800.= (Equal to) SQL> select * from emp where sal = 800. Display records with salary is not equal to 800 18 . Display records with salary is equal to 800 n ! = or <> Not equal to n n SQL> select * from emp where sal <> 800.

Display records with salary is grater then 800 < less then n SQL> select * from emp where sal < 800.> Grater then n SQL> select * from emp where sal > 800. Display records with salary is less then 800 19 .

Display records where salary is from 200 to 800 NOTE: Records with salary 200 and 800 are also included. 20 . Display records with salary >= 800 BETWEEN …AND n SQL> select * from emp where sal between 200 and 800.>= Grater then equal to n SQL> select * from emp where sal >= 800.

IN (list) any of a list of values n select * from emp where sal in (200. n select * from emp where ename like ‘A%’. Display records where ename begins with ‘A’.800. Display records where salary is either 200 or 800 or 600 LIKE n match a character pattern select * from emp where ename like ‘_dam’. 21 . Display records where ename column has “dam” at the end and there is one character at the beginning of ename.600).

Display records where salary is equal to 800 and ename begins with ‘A’ Lab Practice 22 . or n SQL> select * from emp where sal = 800 or sal = 600 Display records where salary is either 600 to 800 n SQL> select * from emp where sal is 800 and ename like ‘A%’.and …….

List all commission. Display records where salary is either 200 or 800 or 600 Write a SQL statement which selects list of employees whose salary is between 200 to 800 or their name ends with ‘m’. mgr from emp table. Part 2 n Display records where salary is either 600 or 800. n n n n 23 . Display the structure of the table emp. List all salaries from emp table.Practice Following SQL Queries PERFORM THE FOLLOWING QUERIES: Part 1 n n n n n n n List all rows of the table emp. Display records where ename column has “dam” at the end and there is one character missing at the beginning of ename . emp. emp. Write a SQL statement which selects names of the employees whose salary is either 200 or 800 or the character ‘d’ comes in their name. List all employees name from table emp. List all jobs from emp table. emp. Display the structure of the table dept. ename.

jobs. jobs. hiredate from emp table. salaries. mgr. mgr from table emp . emp. salaries from table emp . List all employees number. List all employees number. employee name. emp.Part 3 n List all departments number from table emp . Write a SQL statement which selects list of employees whose salary is either 200 or 800 (By using in operator) and/or their name starts with ‘A’. employees name. emp. jobs. List all employees number. mgr. n n n n Be Happy J 24 . employees name.

Sign up to vote on this title
UsefulNot useful

Master Your Semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master Your Semester with a Special Offer from Scribd & The New York Times

Cancel anytime.