CSE 4701 Chapter 10-1 Chapter 10 6e: Oracle Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University of Connecticut 191.

Slides:



Advertisements
Similar presentations
9 Creating and Managing Tables. Objectives After completing this lesson, you should be able to do the following: Describe the main database objects Create.
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.
Introduction To SQL Lynnwood Brown President System Managers LLC Copyright System Managers LLC 2003 all rights reserved.
CSE 4701 Chapter 10-1 MySQL & Project Technology Overview Questions… Project Architecture (3-Tier)‏ MySQL Administration and Tools.
SQL’s Data Definition Language (DDL) n DDL statements define, modify and remove objects from data dictionary tables maintained by the DBMS n Whenever you.
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.
SQL Components DML DDL DAL. Overview u Getting the records onto the disk - mapping u Managing disk space u SQL Modes u Ceating database.
8 Copyright © Oracle Corporation, All rights reserved. Manipulating Data.
Copyright  Oracle Corporation, All rights reserved. 9 Manipulating Data: INSERT, UPDATE, DELETE.
1 Table Alteration. 2 Altering Tables Table definition can be altered after its creation Adding columns Changing columns’ definition Dropping columns.
A Guide to SQL, Seventh Edition. Objectives Understand the concepts and terminology associated with relational databases Create and run SQL commands in.
Introduction to Structured Query Language (SQL)
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.
Oracle SQL*plus John Ortiz. Lecture 10SQL: Overview2 Overview  SQL: Structured Query Language, pronounced S. Q. L. or sequel.  A standard language for.
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, Copyright © 2010 All Rights Reserved. 1.
ORACLE Using ORACLE 8 SQL using ORACLE 8 PL/SQL using ORACLE 8.
Your Oracle Account UserName is the same as your UWP username Followed Not case sensitive Initial Password: UWPstudent Password is case sensitive.
Oracle Data Definition Language (DDL)
SQL Basics. SQL SQL (Structured Query Language) is a special-purpose programming language designed from managing data in relational database management.
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.
Chapter 5 Introduction to SQL. Structured Query Language = the “programming language” for relational databases SQL is a nonprocedural language = the user.
Chapter 9 SQL and RDBMS Part C. SQL Copyright 2005 Radian Publishing Co.
ASP.NET Programming with C# and SQL Server First Edition
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor Ms. Arwa.
Chapter 7 Working with Databases and MySQL PHP Programming with MySQL 2 nd Edition.
CS 3630 Database Design and Implementation. Your Oracle Account UserName is the same as your UWP username Followed Not case sensitive Initial.
Oracle Data Definition Language (DDL) Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2008.
SQL FUNDAMENTALS SQL ( Structured Query Language )
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.
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
10-1 Copyright  Oracle Corporation, All rights reserved. Database Objects ObjectDescription TableBasic unit of storage; composed of rows and columns.
Oracle 11g DATABASE DEVELOPMENT LAB1. Introduction  Oracle 11g Database:-  Oracle 11g database is designed for some features, which helps to the organizations.
9 Copyright © Oracle Corporation, All rights reserved. Creating and Managing Tables.
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.
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.
A Guide to MySQL 3. 2 Introduction  Structured Query Language (SQL): Popular and widely used language for retrieving and manipulating database data Developed.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
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.
SQL: Part 1 Original materials supplied by the Oracle Academic Initiative (OAI). Edited for classroom use by Professor Laku Chidambaram. Not for commercial.
Manipulating Data. Objectives After completing this lesson, you should be able to do the following: Describe each DML statement Insert rows into a table.
9 Manipulating Data. 9-2 Objectives At the end of this lesson, you should be able to: Describe each DML statement Insert rows into a table Update rows.
9 Copyright © Oracle Corporation, All rights reserved. Creating and Managing Tables.
IS 380 Introduction to SQL This lectures covers material from: database textbook chapter 3 Oracle chapter: 3,14,17.
1 Chapter 2: Creating and Modifying Database Objects.
ITEC 3220A Using and Designing Database Systems Instructor: Prof. Z. Yang Course Website: 3220a.htm
Altering Tables and Constraints Database Systems Objectives Add and modify columns. Add, enable, disable, or remove constraints. Drop a table. Remove.
Creating and Managing Tables 14. ObjectivesObjectives After completing this lesson, you should be able to do the following: After completing this lesson,
Relational Database Management System(RDBMS) Structured Query Language(SQL)
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.
Basic SQL*Plus edit and execute commands SQL*Plus buffer and built-in editor holds the last SQL statement Statements are created in free-flow style and.
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.
Oracle 11g: SQL Chapter 5 Data Manipulation and Transaction Control.
CS 3630 Database Design and Implementation
Chapter 5 Introduction to SQL.
SQL and SQL*Plus Interaction
Introduction to Oracle9i: SQL
Manipulating Data Schedule: Timing Topic 40 minutes Lecture
Chapter 8 Working with Databases and MySQL
Session - 6 Sequence - 1 SQL: The Structured Query Language:
Contents Preface I Introduction Lesson Objectives I-2
Presentation transcript:

CSE 4701 Chapter 10-1 Chapter 10 6e: Oracle Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University of Connecticut 191 Auditorium Road, Box U-155 Storrs, CT (860) n All of these slides are being used with the permission of Dr. Ling Lui, Associate Professor, College of Computing, Georgia Tech.

CSE 4701 Chapter 10-2 Oracle by Example n Oracle architecture n Online book store implementation l define a simple data model l use SQL*Plus to create the DB in Oracle l overview of commands to see structure l insert, update, and delete data l more advanced Oracle SQL l SQL*Plus shell features

CSE 4701 Chapter 10-3 Oracle Architecture

CSE 4701 Chapter 10-4 Data storage in Oracle n Database l tablespaces à schema objects F data files

CSE 4701 Chapter 10-5 Logging in n Log in to acme n Add to your.profile file export FMHOME=/usr/local/lib/frame export ORACLE_HOME=/usr/local/oracle/8.1.7 export ORACLE_SID=ccdb export LD_LIBRARY_PATH=$ORACLE_HOME/lib On the prompt, l {acme:gte113x:145}. oraenv l ORACLE_SID = [ccdb] ? ccdb l {acme:gte113x:145} sqlplus l will ask for your username and password à Default password is gtxxxxxDDMM à Should change the password after first use

CSE 4701 Chapter 10-6

CSE 4701 Chapter 10-7 Things to remember n Always terminate your command with a n Semicolon (;) n Exit sqlplus by entering quit or exit at the SQL> prompt n Commands can be in lower or upper case n To execute a host operating system command without leaving SQL*Plus, type host l SQL> HOST ls *.sql l SQL> sample1.sql sample2.sql

CSE 4701 Chapter 10-8

CSE 4701 Chapter 10-9 Help Index

CSE 4701 Chapter n Book n Customer n Order n LineItem Relational Model ISBNAuthorTitlePublisherDatePrice Cust #Name StreetCityStateZip Order #Cust#CardExp.Auth Order#Book# Date

CSE 4701 Chapter Create Table

CSE 4701 Chapter Schema Creation n Oracle schema’s are based on user-name l You only get one schema per user using other schema’s requires permission ( GRANT ’s)

CSE 4701 Chapter Schema Creation - book

CSE 4701 Chapter Schema Creation - customer

CSE 4701 Chapter Schema Creation - order

CSE 4701 Chapter Schema Creation - line_item

CSE 4701 Chapter Oracle Data types n character data types : l char(x), max 256 bytes l varchar2(x), max 2000 bytes n numerical data: l number [(x, y)], length and precision l float[(b)], binary precision (up to 126) n long: up to 2GB l restricted: one long per table;no join n Date l century year month day hour min sec

CSE 4701 Chapter Browsing the catalog n view table structure l DESC book n view your tables: l SELECT table_name from user_tables;

CSE 4701 Chapter Browsing the catalog n view all objects l SELECT object_name, object_type, created from user_objects;

CSE 4701 Chapter Insert n Insert command l insert into book values (‘ ’, ‘Smith’, ‘Oracle Basics’, ‘McNeil’, sysdate, 14.99); l insert into book (isbn, author, title, publisher, pub_date, price) values (‘ ’, ‘Smith’, ‘Oracle Basics’, ‘McNeil’, sysdate, 14.99); n What is the difference?

CSE 4701 Chapter Inserted data

CSE 4701 Chapter Updating data

CSE 4701 Chapter Delete n Delete table with drop table l DROP TABLE customer; n Delete rows with delete from l DELETE FROM customer WHERE name = “Smith”; l DELETE FROM customer; n Permanently delete rows with truncate l TRUNCATE TABLE customer; à Faster: no DELETE triggers fired; no rollback available.

CSE 4701 Chapter Commit and Rollback n Modifications of tuples are temporarily stored in the database n They become permanent after commit;statement has been issued n You can undo all modifications since last commit using rollback n Any data definition command like create results in implicit commit n Termination of Oracle session also executes implicit commit

CSE 4701 Chapter Bulk Loading data Create a.sql file with insert statements or start filename.sql n Use SQL*Loader % SQLLOAD / CONTROL=BOOK.CTL LOG=BOOK.LOG LOAD DATA INFILE book.dat APPEND INTO TABLE book FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"' (isbn, author, title, publisher, pub_date DATE "DD-Month-YYYY", price)

CSE 4701 Chapter Data file Example “ ”, “Smith”, “Oracle Basics”, “McNeil”, 17-April-2000, “ ”, “Smith”, “Java Basics”, “AW”, 12-March-1998, 35

CSE 4701 Chapter Log File

CSE 4701 Chapter View Create a new view of data l CREATE VIEW clerk (id_number, person, department, position) AS SELECT empno, ename, deptno, job FROM emp WHERE job = 'CLERK’; n Why?

CSE 4701 Chapter View Command

CSE 4701 Chapter Constraints n Column constraints: l primary key l foreign key l NULL values l create table CUSTOMER (id NUMBER CONSTRAINT pk_cust PRIMARY KEY, name VARCHAR2(250), VARCHAR2(60) CONSTRAINT nn_ NOT NULL, addr NUMBER CONSTRAINT fk_addr REFERENCES address(id));

CSE 4701 Chapter Table Constraint Clause

CSE 4701 Chapter Column Constraint Clause

CSE 4701 Chapter Alter Table n Add a column, or integrity constraint n Remove an integrity constraint n Cannot rename or drop a column n Keep a copy of the SQL statements you use to create and alter tables l ALTER TABLE book MODIFY (price NUMBER(7,2)); l ALTER TABLE customer DROP PRIMARY KEY CASCADE;

CSE 4701 Chapter Alter Table command

CSE 4701 Chapter SQL*Plus Shell n Features: l scripting l variables l report formatting n Basics l commands end with a semi-colon, a single ‘/’, or two blank lines. l Repeat last command: ‘/’ l Comments begin with /* and end with */ l comments and semi-colons don’t co-exist

CSE 4701 Chapter Formatting l SQL> SELECT * from user_tables;

CSE 4701 Chapter Formatting l SQL> SELECT table_name, pct_free from user_tables;

CSE 4701 Chapter SQL*Plus Display commands l COLUMN table_name HEADING table l COLUMN pct_free HEADING free l COLUMN table_name FORMAT A10 l SET UNDERLINE = l TTITLE CENTER ‘TABLE FREE SPACE’

CSE 4701 Chapter Running commands from a file n SQL> GET filename loads a command file into the buffer n SQL> RUN executes the buffer n loads and executes a command file n % sqlplus start sqlplus and immediately runs file n login.sql like.cshrc, configures environment with SQL*Plus shell commands

CSE 4701 Chapter Oracle Errors n Oracle only provides an error number and a short message n To get an explanation: use oerr