ITEC 3220M Using and Designing Database Systems

Slides:



Advertisements
Similar presentations
Access Manual 4 By Elham S.Khorasani Ismail Guneydas Dhawala Kovuri.
Advertisements

Dear Friends, I m Kartik Mali from gujarat. I prepared this presentation for who want to use oracle loader utility. I m giving here step by step knowledge.
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.
Quick-and-dirty.  Commands end in a semi-colon ◦ If you forget, another prompt line shows up  Either continue the command or…  End it with a semi-colon.
1 A GUIDE TO ORACLE8 CHAPTER 2: Creating and ModifyingDatabaseTables 2.
1 The Oracle Database System Building a Database Database Course The Hebrew University of Jerusalem.
Introduction to Structured Query Language (SQL)
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)
Entity PrimaryKey Attribute relationship Cardinality: zero to many Cardinality: one and only one Cardinality: one to many Explanation Entity Relationship.
Concepts of Database Management Sixth Edition
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)
Structured Query Language (SQL) A2 Teacher Up skilling LECTURE 2.
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.
ASP.NET Programming with C# and SQL Server First Edition
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor Ms. Arwa.
Concepts of Database Management Seventh Edition
Database A collection of related data. Database Applications Banking: all transactions Airlines: reservations, schedules Universities: registration, grades.
Concepts of Database Management, Fifth Edition Chapter 4: The Relational Model 3: Advanced Topics.
Relational Database Management Systems. A set of programs to manage one or more databases Provides means for: Accessing the data Inserting, updating and.
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.
ITBIS373 Database Development
Database control Introduction. The Database control is a tool that used by the database administrator to control the database. To enter to Database control.
Using Special Operators (LIKE and IN)
Concepts of Database Management Seventh Edition
ITEC 3220A Using and Designing Database Systems Instructor: Gordon Turpin Course Website: Office: CSEB3020.
CS 3630 Database Design and Implementation. Assignment 3 Style! Agreement between database designer and the client. UserName1_EasyDrive UserName2_EasyDrive.
Oracle 11g DATABASE DEVELOPMENT LAB1. Introduction  Oracle 11g Database:-  Oracle 11g database is designed for some features, which helps to the organizations.
1 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 8 DATABASE DESIGN AND DEVELOPMENT: A VISUAL APPROACH Chapter 8 Creating.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
Personal Oracle8i Create a new user Create a new table Enter data into a new table Export & import data Start and exit SQL Plus SQL Plus Syntax.
Creating Tables and Inserting Records -- Not easy to edit! -- check constraints! Create table test1 ( C1 char(5) primary key, C2 Varchar2(15) not null.
A Guide to MySQL 3. 2 Introduction  Structured Query Language (SQL): Popular and widely used language for retrieving and manipulating database data Developed.
1 Introduction to Oracle Chapter 1. 2 Before Databases Information was kept in files: Each field describes one piece of information about student Fields.
Concepts of Database Management Eighth Edition Chapter 3 The Relational Model 2: SQL.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
SQL: Advanced topics Prof. Weining Zhang Cs.utsa.edu.
D Copyright © Oracle Corporation, All rights reserved. Loading Data into a Database.
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:
Personal Oracle8i Create a new user Create a new table Enter data into a new table Export & import data Start and exit SQL Plus SQL Plus Syntax.
Oracle 9i. Agenda Start and exit SQL Plus (General) Start and exit SQL Plus (Tah 1006) Syntax Create a new user Create a new table Enter data into a new.
SQL LOADER. SQL*Loader (sqlldr ) is the utility to use for high performance data loads. The data can be loaded from any text file and inserted into the.
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.
Concepts of Database Management Seventh Edition Chapter 4 Keys and Relationship.
Command-line Oracle Logon to your ORACLE account using the instructions contained in this slideshow. Create the tables with your last name in place of.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
5 Copyright © 2008, Oracle. All rights reserved. Testing and Validating a Repository.
LM 5 Introduction to SQL MISM 4135 Instructor: Dr. Lei Li.
MySQL Tutorial. Databases A database is a container that groups together a series of tables within a single structure Each database can contain 1 or more.
Southern Methodist University CSE CSE 2337 Introduction to Data Management Chapter 2.
VOCAB REVIEW. A field that can be computed from other fields Calculated field Click for the answer Next Question.
CSE 4701 Chapter 10-1 Chapter 10 6e: Oracle Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University of Connecticut 191.
Concepts of Database Management, Fifth Edition Chapter 3: The Relational Model 2: SQL.
Dept. of Computer & Information Sciences
SQL in Oracle.
SQL in Oracle.
Current outstanding balance
Using SQL Server through Command Prompt
LESSON Database Administration Fundamentals Inserting Data.
Working with Big Data in SQL
Using SQL*Loader The SQL*Loader command needs to be run from a DOS window or NT. The SQL*Loader uses the following three files: control file: contains.
Using SQL*Plus.
Turn on spool and save to file a.txt
Presentation transcript:

ITEC 3220M Using and Designing Database Systems Instructor: Prof. Z. Yang Course Website: http://people.math.yorku.ca/~zyang/itec3220m.htm Office: Tel 3049

SQL*Loader

SQL*Loader SQL*Loader is a bulk loader utility used for moving data from external files into an Oracle table. Tables must exist Loader works with the control file (file.ctl)

Loader Files SQL*Loader takes either: or two input files – a control file and a data file or a single input file – a control file that contains a set of data and loads the data into a single Oracle table

Loader Files The data file contains data each record is placed in one row, fields can be delimited by ‘,’ or ‘|’ can have extensions .csv or .dat The control file contains information about the data specifies action: insert, replace, append describes the data, indicates which tables and columns the data is to be loaded has extension .ctl

The SQL*Loader Environment

The Log, Bad and Discard Files The log file (.log) records SQL*Loader's activities during a load session and contains statistics on the load, error messages for records that cause errors It is important to review the log file after a load to make sure that no errors occurred! The bad file (.bad) shows database errors, e.g. insert failure due to integrity constraint violation The discard file (.dis) holds records that do not meet selection criteria specified in the SQL*Loader control file

The Data File (ship.csv) - example “001”,”Century”,”1986”,”2000” “002”,”Galaxy”,”1989”,”1500” “003”,”Horizon”,”1992”,”1600” “004”,”Infinity”,”1995”,”2500” “005”,”Journey”,”1998”,”2500” “006”, “Mercury”,”2001”,”3000”

The Control File (ship.ctl) - example INFILE ‘ship.csv’ REPLACE INTO TABLE Ship FIELDS TERMINATED By ‘,’ OPTIONALLY ENCLOSED BY ‘”’ (shipNum, shipName, yearBuilt, capacity)

Data in the Control File - example LOAD DATA INFILE * REPLACE INTO TABLE Ship FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' (shipNum, shipName, yearBuilt, capacity) BEGINDATA "001","Century","1986","2000" "002","Galaxy","1989","1500" "003","Horizon","1992","1600" "004","Infinity","1995","2500" "005","Journey","1998","2500" "006","Mercury","2001","3000"

Execution of SQL*Loader sqlldr login/password@studb10g control=ship.ctl

SQL Queries

SQL Queries Single table query Multiple table query Nesting query Using IN Using EXISTS Join Table

Joining Database Tables Ability to combine (join) tables on common attributes is most important distinction between a relational database and other databases Join is performed when data are retrieved from more than one table at a time Join is generally composed of an equality comparison between the foreign key and the primary key of related tables

Examples SELECT Order_Num FROM ORDERS WHERE Order_Num IN FROM ORDER_LINE WHERE Part_Num =1234;

Examples (Cont’d) SELECT Order_Num FROM ORDERS WHERE EXISTS (SELECT * FROM ORDER_LINE WHERE ORDERS.Order_Num = ORDERLINE.Order_Num AND Part_Num =1234;

Examples (Cont’d) SELECT S.Last, S.First, C.Last, C.First FROM SALES_REP S, CUSTOMER C WHERE S.Srep_Num = C. Srep_Num

SQL Exercise Write SQL code that will create the relations shown. Assume the following attribute data types: Student_ID: integer Student_Name: 25 characters Faculty_ID: integer Faculty_Name: 25 characters Course_ID: 25 characters Course_Name: 15 characters Date_Qualified: date Section_ID: integer Semester: 7 characters

SQL Exercise (Cont’d) STUDENT (Primary key: Student_ID) IS_QUALIFIED (Primary key: Faculty_ID, Course_ID) Faculty_ ID Course_ID Date_ Qualified 2143 ISM3112 9/1988 3467 ISM4212 9/1995 ISM4930 9/1996 4756 ISM3113 9/1991 Student_ ID Name 38214 Letersky 54907 Altvater 66324 Aiken 70542 Marra

SQL Exercise (Cont’d) FACULTY (Primary key: Faculty_ID) SECTION (Primary key: Section_ID) Section_ID Course_ID 2712 ISM3113 2713 2714 ISM4212 2715 ISM4930 Faculty_ID Faculty_Name 2143 Birkin 3467 Berndt 4756 Collins

SQL Exercise (Cont’d) COURSE ((Primary key: Course_ID) IS_REGISTERED (Primary key: Student_ID, Section_ID) Course_ID Course_ Name ISM3113 Syst Analysis ISM3112 Syst Design ISM4212 Database ISM4930 Networking Student_ID Section_ID Semester 38214 2714 I - 2001 54907 2715 66324 2713

SQL Exercise (Cont’d) Write SQL queries to answer the following questions: Display the course ID and course name for all courses with an ISM prefix. Display all the courses (Course_Name) for which Professor Berndt has been qualified. Is any instructor qualified to teach ISM 3113 and not qualified to teach ISM 4930? How many students are enrolled in section 2714 during semester I – 2001? Which students were not enrolled in any courses during semester I – 2001?

Lab Instruction Login to sit.yorku.ca Start Oracle SQL*PLUS environment by typing the following command: sqlplus When prompted for the username/password enter your_username@studb10g (where your_username is your AML username) at the username prompt and your AML password at the password prompt.

Lab Tips To list all tables you have in your Oracle account use the following SQL command: select table_name from user_tables; To describe a given Oracle table use the following Oracle environment command (note that this is not an SQL command): desc tablename (where tablename is the name of the table that you have in your account)

SQL Plus Editing Commands Add text at end of current line: A text Change current line: type the line number Change text in current line: C/old/new Insert a line following current line: I