ORACLE SQL. Overview Personal DBMS Vs Client/Server DBMS Oracle 8 Environment SQL – syntax and examples PL/SQL-introduction.

Slides:



Advertisements
Similar presentations
BACS 485—Database Management Advanced SQL Overview Advanced DDL, DML, and DCL Commands.
Advertisements

Manipulating Data Schedule: Timing Topic 60 minutes Lecture
Virtual training week 4 structured query language (SQL)
Copyright  Oracle Corporation, All rights reserved. 10 Creating and Managing Tables.
Let’s try Oracle. Accessing Oracle The Oracle system, like the SQL Server system, is client / server. For SQL Server, –the client is the Query Analyser.
SQL components In Oracle. SQL in Oracle SQL is made up of 4 components: –DDL Data Definition Language CREATE, ALTER, DROP, TRUNCATE. Creates / Alters.
Murali Mani SQL DDL and Oracle utilities. Murali Mani Datatypes in SQL INT (or) INTEGER FLOAT (or) REAL DECIMAL (n, m) CHAR (n) VARCHAR (n) DATE, TIME.
At the end of this lesson, you should be able to: Describe each DML statement Insert rows into a table Update rows in a table Delete rows from a table.
Your Oracle Account UserName is the same as your UWP username Followed Not case sensitive Initial Password: UWPstudent Password is case sensitive.
Introduction to DBMS and SQL Introduction to DBMS and SQL GUIDED BY : MR. YOGESH SAROJ (PGT-CS) MR. YOGESH SAROJ (PGT-CS) Presented By : JAYA XII –COM.
o At the end of this lesson, you will be able to:  Describe the life-cycle development phases  Discuss the theoretical and physical aspects of a relational.
I Copyright © 2004, Oracle. All rights reserved. Introduction.
CS 3630 Database Design and Implementation. Your Oracle Account UserName is the same as your UWP username Followed Not case sensitive Initial.
Introduction to SEQUEL. What is SEQUEL? Acronym for Structural English Query Language Acronym for Structural English Query Language Standard language.
SQL SQL Server : Overview SQL : Overview Types of SQL Database : Creation Tables : Creation & Manipulation Data : Creation & Manipulation Data : Retrieving.
ACTION QUERIES (SQL COMMANDS ) STRUCTURED QUERY LANGUAGE.
SQL FUNDAMENTALS SQL ( Structured Query Language )
Lecture 2: Using DDL Statements to Create and Manage Tables & Indexes
1 Creating and Modifying Database Objects. 2 An Oracle database consists of multiple user accounts Each user account owns database objects Tables Views.
10 Creating and Managing Tables Objectives At the end of this lesson, you will be able to: Describe the main database objects Create tables Describe.
Quick review of SQL And conversion to Oracle SQL.
10-1 Copyright  Oracle Corporation, All rights reserved. Database Objects ObjectDescription TableBasic unit of storage; composed of rows and columns.
Nitin Singh/AAO RTI ALLAHABAD 1 SQL Nitin Singh/AAO RTI ALLAHABAD 2 OBJECTIVES §What is SQL? §Types of SQL commands and their function §Query §Index.
Oracle 11g DATABASE DEVELOPMENT LAB1. Introduction  Oracle 11g Database:-  Oracle 11g database is designed for some features, which helps to the organizations.
Copyright  Oracle Corporation, All rights reserved. 10 Creating and Managing Tables.
SQL: DDL. SQL Statements DDL - data definition language –Defining and modifying data structures (metadata): database, tables, views, etc. DML - data manipulation.
MySQL Database Management Systems Universitas Muhammadiyah Surakarta Yogiek Indra Kurniawan.
Session 2: SQL (A): Parts 1 and 2 Original materials supplied by the Oracle Academic Initiative (OAI). Edited for classroom use by Professor Laku Chidambaram.
SQL Basics. What is SQL? SQL stands for Structured Query Language. SQL lets you access and manipulate databases.
SQL Structured Query Language 1. Data Definition Language (DDL) is used to manage table and define data structure i.e. CREATE, ALTER, DROP Data Control.
Database Lab Lecture 1. Database Languages Data definition language ( DDL ) Data definition language –defines data types and the relationships among them.
Copyright  Oracle Corporation, All rights reserved. Introduction.
Prince Sultan University Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.
Copyright  Oracle Corporation, All rights reserved. 4 Introduction.
SQL: Part 1 Original materials supplied by the Oracle Academic Initiative (OAI). Edited for classroom use by Professor Laku Chidambaram. Not for commercial.
DBSQL 5-1 Copyright © Genetic Computer School 2009 Chapter 5 Structured Query Language.
Manipulating Data. Objectives After completing this lesson, you should be able to do the following: Describe each DML statement Insert rows into a table.
IS 380 Introduction to SQL This lectures covers material from: database textbook chapter 3 Oracle chapter: 3,14,17.
Enhanced Guide to Oracle 10g Chapter 3: Using SQL Queries to Insert, Update, Delete, and View Data.
1 Chapter 2: Creating and Modifying Database Objects.
Copyright © 2004, Oracle. All rights reserved. Lecture 2: Using DDL Statements to Create and Manage Tables & Indexes ORACLE.
Transactions, Roles & Privileges Oracle and ANSI Standard SQL Lecture 11.
Altering Tables and Constraints Database Systems Objectives Add and modify columns. Add, enable, disable, or remove constraints. Drop a table. Remove.
Relational Database Management System(RDBMS) Structured Query Language(SQL)
At the end of this lesson, you will be able to: Describe constraints Create and maintain constraints.
Introduction to Database SEM I, AY Department of Information Technology Salalah College of Technology Chapter No.3 SQL.
CSCI N311: Oracle Database Programming 5-1 Chapter 15: Changing Data: insert, update, delete Insert Rollback Commit Update Delete Insert Statement –Allows.
Installation Oracle 11g Express 2 double click the "setup" button to install the Oracle.
1 Database Fundamentals Introduction to SQL. 2 SQL Overview Structured Query Language The standard for relational database management systems (RDBMS)
LECTURE FOUR Introduction to SQL DDL with tables DML with tables.
Physical Model Lecture 11. Physical Data Model The last step is the physical design phase, In this phase data is – Store – Organized and – Access.
SQL Statements SELECT INSERTUPDATEDELETECREATEALTERDROPRENAMETRUNCATECOMMITROLLBACKSAVEPOINTGRANTREVOKE Data Retrieval Language (DRL) Data Retrieval Language.
Oracle sql Online Training By SMART MIND ONLINE TRAINING Website:
1 Copyright © 2005, Oracle. All rights reserved. Oracle Database Administration: Overview.
Oracle SQL.
The Basics of Data Manipulation
Manipulating Data.
Manipulating Data Schedule: Timing Topic 40 minutes Lecture
ORACLE SQL Developer & SQLPLUS Statements
“Introduction To Database and SQL”
DATABASE MANAGEMENT SYSTEM
لغة قواعد البيانات STRUCTURED QUERY LANGUAGE SQL))
The Basics of Data Manipulation
Data Control Language Grant, Revoke.
مقدمة في قواعد البيانات
(SQL) Manipulating Data
SQL Statements SELECT INSERT UPDATE DELETE CREATE ALTER DROP RENAME
ORACLE SQL.
Session - 6 Sequence - 1 SQL: The Structured Query Language:
Structured Query Language Path from Unorganized to Organized….
Presentation transcript:

ORACLE SQL

Overview Personal DBMS Vs Client/Server DBMS Oracle 8 Environment SQL – syntax and examples PL/SQL-introduction

Server Gets file requests from clients Sends files to client Receives files back from clients 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 Personal DBMS

Personal DBMS - Problems Demand on the client and the network Does not perform table locking automatically Not fault tolerant in the case of client failure Do not have file based transaction logging

Server Gets data requests from clients Adds, Deletes and updates data Sends results to clients 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

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

Sqlplus username/password ALTER USER user-name IDENTIFIED BY newpassword START filename filename CLEAR SCREEN HELP HELP SAVE filename[.ext] REPLACE|APPEND EXIT SQL*Plus commands

SQL Both an ANSI and ISO standard Types of commands: 1. Data Definition Language (DDL) : Create, Alter, Drop, Rename, Truncate 2. Data Manipulation Language (DML): Insert, Delete, Update 3. Data Retrieval: Select 4. Transaction Control: Commit, Rollback, Savepoint 5. Data Control Language (DCL): Grant, Revoke

PositionIDPositionDescription 1President 2Manager 3Programmer 4Accountant 5Salesman QualificationIDQualificationDescription1Doctorate 2Masters 3Bachelors 4Associates DeptIDDeptNameLocation10FinanceCharlotte 20Infosys New York 30MarketingWoodbridge 40AccountantCalifornia DEPARTMENT POSITION QUALIFICATION

EmpIDLastNameFirstNamePositionIDSuperIDHireDateSalaryCommDeptIDQualID 111SmithJohn104/15/ HoustonLarry211105/19/ RobertsSandi211112/02/ McCallAlex354305/10/ DevDereck211103/15/ ShawJinku513501/03/ ChenSunny412308/15/ GarnerStanley211102/29/ EMPLOYEE

Data Definition Language: CREATE TABLE {table} ( {column datatype [DEFAULT expr] [column_constraint]... | table_constraint} [column_constraint]... | table_constraint} [, { column datatype [DEFAULT expr] [, { column datatype [DEFAULT expr] [column_constraint]... [column_constraint]...) ALTER TABLE {table} [ADD|MODIFY {column datatype [DEFAULT expr] [column_constraint]} [DROP drop_clause] DROP TABLE {table} [cascade constraints] DESC {table}

CREATE TABLE Emp ( empid Decimal(10) NOT NULL, empid Decimal(10) NOT NULL, positionid Number(2), positionid Number(2), supervisorid Number(3), supervisorid Number(3), deptid Number(2), deptid Number(2), qualid Number(1), qualid Number(1), lname varchar2(10), lname varchar2(10), fname varchar2(10), fname varchar2(10), salary Decimal(10,2), salary Decimal(10,2), hiredate Date, hiredate Date, commission Decimal(4,2), commission Decimal(4,2), PRIMARY KEY (empid), PRIMARY KEY (empid), FOREIGN KEY (positionid) REFERENCES Position(positionid), FOREIGN KEY (positionid) REFERENCES Position(positionid), FOREIGN KEY (deptid) REFERENCES Dept(deptid), FOREIGN KEY (deptid) REFERENCES Dept(deptid), FOREIGN KEY (qualid) REFERENCES Qualification(qualid) FOREIGN KEY (qualid) REFERENCES Qualification(qualid)); ALTER TABLE EMP MODIFY Commission decimal(7,2);

Data Manipulation Language: INSERT INTO {table | view} [ (column [, column]...) ] VALUES (expr,expr...) UPDATE {table | view } SET { (column [, column] = { expr | } [WHERE condition] DELETE [FROM] {table | view} [WHERE condition]

INSERT INTO Dept( deptid,deptname,location) VALUES(50,'IT','Dallas'); INSERT INTO Emp(empid, lname,fname,positionid, supervisorid,hiredate, salary,deptid,qualid) VALUES(227,'howser','Barbara',4,111,'25-AUG-83',45000,10,3); UPDATE dept SET deptname='Sales' WHERE deptID=50; DELETE FROM dept WHERE deptid='50';

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'; dept.deptid=emp.deptid and emp.empid='111';

Transaction Control: COMMIT ROLLBACK [ to {savepoint}] SAVEPOINT {name} commit; savepoint point1; rollback to point1;

Data Control Language: GRANT [privileges] ON object TO user|public [WITH GRANT OPTION] REVOKE [privileges] ON object TO user|public [CASCADE CONSTRAINTS] grant select,update on emp to XYZ ; revoke update on emp to XYZ;

A PL/SQL Example: CREATE OR REPLACE PROCEDURE raise_salary (empno INTEGER, increase REAL) IS 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;