SQL in Oracle.

Slides:



Advertisements
Similar presentations
Relational Algebra Relational algebra consists of a set of relational operators Each operator has one or more relations as input and creates a new relation.
Advertisements

Basic SQL Introduction Presented by: Madhuri Bhogadi.
Midterm Review Lecture 14b. 14 Lectures So Far 1.Introduction 2.The Relational Model 3.Disks and Files 4.Relational Algebra 5.File Org, Indexes 6.Relational.
Introduction to Structured Query Language (SQL)
Structured query language This is a presentation by JOSEPH ESTRada on the beauty of Structured Query Language.
Design process Identify entities and attributes –What do you want to know? –Note that the question of whether something is an attribute or an entity may.
Fundamentals, Design, and Implementation, 9/e Chapter 6 Introduction to Structured Query Language (SQL)
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.
SQL in Access S511. Create Table Schema CREATE TABLE student ( student_id INTEGER NOT NULL, name CHAR(25), major CHAR(10), gpa INTEGER, CONSTRAINT index1.
A Guide to MySQL 3. 2 Objectives Start MySQL and learn how to use the MySQL Reference Manual Create a database Change (activate) a database Create tables.
PostgreSQL S511. SLIS Postgresql server PHP PGAdmin – – Get.
Concepts of Database Management Sixth Edition
1ISM - © 2010 Houman Younessi Lecture 3 Convener: Houman Younessi Information Systems Spring 2011.
Chapter 7: SQL, the Structured Query Language Soid Quintero & Ervi Bongso CS157B.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
ITEC 3220A Using and Designing Database Systems Instructor: Gordon Turpin Course Website: Office: CSEB3020.
Introduction to Structured Query Language (SQL) COM S Fall Instructor: Ying Cai Iowa State University 1.
Database A collection of related data. Database Applications Banking: all transactions Airlines: reservations, schedules Universities: registration, grades.
Relational Database Management Systems. A set of programs to manage one or more databases Provides means for: Accessing the data Inserting, updating and.
CS 3630 Database Design and Implementation. Your Oracle Account UserName is the same as your UWP username Followed Not case sensitive Initial.
Oracle Database Administration Lecture 2 SQL language.
CPS120: Introduction to Computer Science Lecture 19 Introduction to SQL.
Using Special Operators (LIKE and IN)
Concepts of Database Management Seventh Edition
1 Structured Query Language (SQL). 2 Contents SQL – I SQL – II SQL – III SQL – IV.
Quick review of SQL And conversion to Oracle SQL.
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.
Topic 1: Introduction to SQL. SQL stands for Structured Query Language. SQL is a standard computer language for accessing and manipulating databases SQL.
BACS 287 Structured Query Language 1. BACS 287 Visual Basic Table Access Visual Basic provides 2 mechanisms to access data in tables: – Record-at-a-time.
Features of SQL SQL is an English-like language . It uses words such as select , insert , delete as part of its commend set. SQL is an a non-procedural.
Information Building and Retrieval Using MySQL Track 3 : Basic Course in Database.
SQL Basics. What is SQL? SQL stands for Structured Query Language. SQL lets you access and manipulate databases.
Database Management COP4540, SCS, FIU Structured Query Language (Chapter 8)
DBSQL 5-1 Copyright © Genetic Computer School 2009 Chapter 5 Structured Query Language.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 (Part II) INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor.
ITEC 3220A Using and Designing Database Systems Instructor: Prof. Z. Yang Course Website: 3220a.htm
SQL in Oracle. Set up Oracle access at IU You need to install Oracle Client: – – For windows:
ECMM6018 Enterprise Networking For Electronic Commerce Tutorial 6 CGI/Perl and databases.
Starting with Oracle SQL Plus. Today in the lab… Connect to SQL Plus – your schema. Set up two tables. Find the tables in the catalog. Insert four rows.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
Installation Oracle 11g Express 2 double click the "setup" button to install the Oracle.
Databases and SQL CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
Chapter Four Objectives Introduction to SQL Introduction to iSQL*PLUS Types of SQL statements Concepts of DDL & DML Data Manipulation Language (DML)
Oracle 11g: SQL Chapter 5 Data Manipulation and Transaction Control.
Concepts of Database Management, Fifth Edition Chapter 3: The Relational Model 2: SQL.
Big Data Yuan Xue CS 292 Special topics on.
D Copyright © 2009, Oracle. All rights reserved. Using SQL*Plus.
SQL SQL Ayshah I. Almugahwi Maryam J. Alkhalifa
3 A Guide to MySQL.
PostgreSQL S511.
Database Languages.
MySQL S511.
CS 3630 Database Design and Implementation
SQL and SQL*Plus Interaction
Using SQL*Plus.
Principles of Software Development
SQL: Advanced Options, Updates and Views Lecturer: Dr Pavle Mogin
Using SQL*Plus.
ORACLE SQL Developer & SQLPLUS Statements
SQL 101.
مقدمة في قواعد البيانات
Database systems Lecture 3 – SQL + CRUD
SQL .. An overview lecture3.
Chapter 1 Introduction.
Contents Preface I Introduction Lesson Objectives I-2
MySQL.
MySQL S511.
Using SQL*Plus.
SQL (Structured Query Language)
Presentation transcript:

SQL in Oracle

Set up Oracle access at IU You need to install Oracle Client: http://kb.iu.edu/data/anhl.html For windows: http://kb.iu.edu/data/aznp.html Connecting to Oracle with SQL*Plus http://kb.iu.edu/data/aznp.html#connecting Go to Start->All programs->Oracle->Application Development->SQL*Plus Your username should be: username@oed1prd.world

Relational Model Data stored in relations (tables) attributes (or columns) course_ID course_name department_ID CIS3100 Database CIS CIS4500 Network MKT3400 Advertising MKT MKT4100 Marketing tuples (or rows) course

SQL Data Definition Language (DDL) Data Manipulation Language (DML) CREATE TABLE ALTER TABLE DROP TABLE Data Manipulation Language (DML) INSERT INTO SELECT UPDATE DELETE

SQL Basic structure – query block SELECT – FROM – WHERE clauses GROUP BY clause HAVING clause ORDER BY clause Aggregate functions COUNT, MIN, MAX, AVG, SUM

SQL in Oracle SQL*Plus Start SQL*Plus Command line interface to access Oracle database Enter, edit, store, retrieve, and run SQL statements Start SQL*Plus Go to Start->All programs->Oracle->Application Development->SQL*Plus Your username should be: username@oed1prd.world

SQL*Plus Commands DESCRIBE: list the columns with data types of a table EXIT: exit the SQL*Plus program GET: load a SQL statement into the buffer LIST: list the current statement in the buffer RUN: execute the current SQL statement in the buffer SAVE: save the current SQL statement to a script file SPOOL: send the output from a SQL statement to a file START: load a SQL statement located in a script file and then run that SQL statement Commit: save your input from buffer to disk. Note the distinction between SQL*Plus Commands and SQL statements. http://download.oracle.com/docs/cd/B10501_01/server.920/a90842/ch13.htm http://download.oracle.com/docs/cd/B19306_01/server.102/b14357/ch4.htm#CHDGEEFE

Example student_id name major GPA 101 Bill CIS 3.45 102 Mary 3.10 103 Sue MKT 3.90 student_id course_id grade 101 CIS3100 A CIS3500 B+ 102 A- CIS3400 103 MKT3000 MKT3200 B MKT4200 course_id name department_id CIS3100 Database CIS CIS3400 Network I CIS3500 Network II MKT3000 Advertising MKT MKT3200 Marketing I MKT4200 Marketing II

DDL in Oracle Basic data types CHAR(size) VARCHAR2(size) NUMBER(p, s) DATE BLOB/CLOB See: http://www.techonthenet.com/oracle/datatypes.php

DDL in Oracle CREATE TABLE ALTER TABLE DROP TABLE CREATE TABLE student ( student_id NUMBER(10), name VARCHAR2(25), major VARCHAR2(15), CONSTRAINT pk_students PRIMARY KEY (student_id) ); ALTER TABLE student ADD (GPA NUMBER(6,3)); DROP TABLE student;

DML in Oracle INSERT UPDATE DELETE SELECT INSERT INTO student VALUES (101, 'Bill', 'CIS', 3.45); UPDATE student SET GPA=3.55 where student_id=101; DELETE FROM student where student_id=101; SELECT * FROM student;

Create tables

Queries SELECT * FROM course WHERE rownum<=3; SELECT * FROM enroll WHERE grade=‘A’;

Queries SELECT * FROM student WHERE student.student_id=(SELECT enroll.student_id FROM enroll WHERE grade='A-'); SELECT student.name FROM student, enroll WHERE student.student_id=enroll.student_id AND enroll.grade=‘A’;

Sorting and Grouping SELECT * FROM enroll ORDER BY grade, course_id; SELECT major, max(gpa) FROM student GROUP BY major HAVING max(gpa)>3.40; SELECT DISTINCT grade FROM enroll;

Joining tables SELECT student.name, enroll.course_id, enroll.grade FROM student INNER JOIN enroll ON student.student_id=enroll.student_id;

Joining tables SELECT * FROM student LEFT JOIN enroll ON student.student_id=enroll.student_id;

Joining tables SELECT * FROM student RIGHT JOIN enroll ON student.student_id=enroll.student_id;

References www.oracle.com Oracle tutorial: http://dbis.ucdavis.edu/courses/sqltutorial/tutorial.pdf http://cisnet.baruch.cuny.edu/holowczak/oracle/sqlplus/