Creating a Table Create a table, “emp”, containing: –empno – a 4 digit employee number –ename – up to 10 character string –job – up to 9 character string.

Slides:



Advertisements
Similar presentations
Oracle 10g & 11g for Dev Virtual Columns DML error logging
Advertisements

BACS 485—Database Management Advanced SQL Overview Advanced DDL, DML, and DCL Commands.
Copyright  Oracle Corporation, All rights reserved. 10 Creating and Managing Tables.
9-1 Copyright  Oracle Corporation, All rights reserved. Data Manipulation Language A DML statement is executed when you: – Add new rows to a table.
Introduction To SQL Lynnwood Brown President System Managers LLC Copyright System Managers LLC 2003 all rights reserved.
Restricting and sorting data 16 May May May Created By Pantharee Sawasdimongkol.
1Eyad Alshareef Enhanced Guide to Oracle 10g Chapter 3: Using SQL Queries to Insert, Update, Delete, and View Data.
Copyright  Oracle Corporation, All rights reserved. 2 Restricting and Sorting Data.
Dale Roberts 1 Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Computer Science, IUPUI
Copyright  Oracle Corporation, All rights reserved. 6 Writing Correlated Subqueries.
Writing Basic SQL Statements
Copyright  Oracle Corporation, All rights reserved. 9 Manipulating Data: INSERT, UPDATE, DELETE.
Writing Basic SQL statement 2 July July July Create By Pantharee Sawasdimongkol.
Logical Operators Operator AND OR NOT Meaning Returns TRUE if both component conditions are TRUE Returns TRUE if either component condition is TRUE Returns.
SELECT Advanced. Sorting data in a table The ORDER BY clause is used for sorting the data in either ascending or descending order depending on the condition.
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.
4-1 Copyright  Oracle Corporation, All rights reserved. Data Manipulation Language (DML)
1 Theory, Practice & Methodology of Relational Database Design and Programming Copyright © Ellis Cohen Introduction to Relational Databases &
1 Theory, Practice & Methodology of Relational Database Design and Programming Copyright © Ellis Cohen Cursors These slides are licensed under.
ACTION QUERIES (SQL COMMANDS ) STRUCTURED QUERY LANGUAGE.
2 Writing Basic SELECT Statements. 1-2 Copyright  Oracle Corporation, All rights reserved. Capabilities of SQL SELECT Statements Selection Projection.
Copyright  Oracle Corporation, All rights reserved. Writing Basic SQL Statements.
IT The Relational DBMS Section 07. Relational Database Theory Using a Relational DBMS.
Joins & Sub-queries. Oracle recognizes that you may want data that resides in multiple tables drawn together in some meaningful way. One of the most important.
Copyright س Oracle Corporation, All rights reserved. I Introduction.
Copyright  Oracle Corporation, All rights reserved. 4 Accessing a Database Using JBCL.
SQL FUNDAMENTALS SQL ( Structured Query Language )
RELATSIOONILISED ANDMEBAASID(alg) SQLi VÕIMALUSED.
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.
Copyright  Oracle Corporation, All rights reserved. 10 Creating and Managing Tables.
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.
8 Producing Readable Output with SQL*Plus. 8-2 Objectives At the end of this lesson, you should be able to: Produce queries that require an input variable.
SQL: Part 1 Original materials supplied by the Oracle Academic Initiative (OAI). Edited for classroom use by Professor Laku Chidambaram. Not for commercial.
1 Writing Basic SQL Statements. 1-2 Objectives At the end of this lesson, you should be able to: List the capabilities of SQL SELECT statements Execute.
I-1 Copyright س Oracle Corporation, All rights reserved. Data Retrieval.
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.
Copyright  Oracle Corporation, All rights reserved. 12 Creating Views.
Copyright  Oracle Corporation, All rights reserved. 8 Producing Readable Output with SQL*Plus.
1 Theory, Practice & Methodology of Relational Database Design and Programming Copyright © Ellis Cohen Subqueries These slides are licensed under.
An Introduction To SQL Part 2 (Special thanks to Geoff Leese)
1 Information Retrieval and Use (IRU) An Introduction To SQL Part 2.
Copyright س Oracle Corporation, All rights reserved. I Introduction.
Oracle CONNECT BY function JAVA WEB Programming. Emp 테이블의 내용 ( 상 / 하급자 계층구조 ) SQL> select * from emp; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
2-1 Limiting Rows Using a Selection “…retrieve all employees in department 10” EMP EMPNO ENAME JOB... DEPTNO 7839KINGPRESIDENT BLAKEMANAGER CLARKMANAGER.
1 Theory, Practice & Methodology of Relational Database Design and Programming Copyright © Ellis Cohen Grouping These slides are licensed under.
ORDER BY clause in SELECT command: Normally, the result of the query will not be in ordered format. If we want to get the result of the query in specific.
Creating and Managing Tables 14. ObjectivesObjectives After completing this lesson, you should be able to do the following: After completing this lesson,
Agenda for Class - 03/04/2014 Answer questions about HW#5 and HW#6 Review query syntax. Discuss group functions and summary output with the GROUP BY statement.
Copyright س Oracle Corporation, All rights reserved. 12 Creating Views.
4/2/16. Ltrim() is used to remove leading occurrences of characters. If we don’t specify a character, Oracle will remove leading spaces. For example Running.
CSCI N311: Oracle Database Programming 5-1 Chapter 15: Changing Data: insert, update, delete Insert Rollback Commit Update Delete Insert Statement –Allows.
Copyright  Oracle Corporation, All rights reserved. 2 Restricting and Sorting Data.
Writing Basic SQL Statements. Objectives After completing this lesson, you should be able to do the following: –List the capabilities of SQL SELECT statements.
Advanced SQL. SQL - Nulls Nulls are not equal to anything - Null is not even equal to Null where columna != ‘ABC’ --this will not return records where.
Copyright  Oracle Corporation, All rights reserved. Introduction.
Copyright س Oracle Corporation, All rights reserved. 1 Writing Basic SQL Statements.
Communicating with a RDBMS Using SQL Database SQL> SELECT loc 2 FROM dept; SQL> SELECT loc 2 FROM dept; SQL statement is entered Statement is sent to database.
Relational Normalization Theory
Manipulating Data Schedule: Timing Topic 40 minutes Lecture
Interacting with the Oracle Server
Generalization.
جملة الاستعلام الأساسية
What Is a View? EMPNO ENAME JOB EMP Table EMPVU10 View
(SQL) Manipulating Data
SQL Subquery.
Restricting and Sorting Data
Copyright © Ellis Cohen
Database Programming Using Oracle 11g
Presentation transcript:

Creating a Table Create a table, “emp”, containing: –empno – a 4 digit employee number –ename – up to 10 character string –job – up to 9 character string –mgr – a 4 digit employee number –hiredate – a date –salary – a 7 digit number with two decimal places after the decimal point –comm – a 7 digit number with two decimal places after the decimal point –deptno – a 2 digit number

Inserting into a Table empnoenamejobmgrhiredatesalarycommdeptno 7369'SMITH''CLERK'7902'17-DEC- 80' 800NULL 'ALLEN'‘SALESM AN' 7698'20-FEB- 81' ‘WARD''CLERK'7698‘22-FEB- 81'

Selecting from a Table Return a list of all employees and associated data List all employees with salary less than 1000

Executing.sql files Goto the following URL: /sqlplus5.htmlhttp:// /sqlplus5.html

More SQL Get the list of all employees again… how many are there now? What is the largest monthly salary? What is the name of the employee who makes that salary? How many times greater is the largest salary compared to the smallest salary?

More SQL: Update What job type makes the lowest salary? Get the ename, job, and salary for all employees with this job type. Give all employees with this job type a 10% raise. Get the ename, job, and salary for all employees with this job type again to observe your raise. Type “rollback;” Get the ename, job, and salary for all employees with this job type again… what happened?

More SQL: Delete Let’s downsize the company! Find all employees that have names that start with the letter ‘B’ –use like ‘ %’ in the where clause What is going to happen if we delete this employee?

More SQL: Delete Who are BLAKE’s employees? Who are the other managers? Jones is about to move up… assign all of BLAKE’s employees to Jones. Delete the employee BLAKE COMMIT your changes

More SQL: Groups & Joins Rank by department name, the best departments to work for in terms of average salary

SQL*PLUS Misc. Find out what tables you have: –select * from user_catalog Find out attributes for a specific table: –desc emp; Save your sql*plus session to a file: –spool session –… –spool off –results of session will be in session.lst

1.List products in order of popularity. 2.List in order of popularity, and include a description of the product. 3.What is the most popular product (include its description), and how much of the product has been sold? 4.List products in order by revenue generated. 5.List products in order by revenue and include a description of the product. 6.What product (including description) generated the most revenue and what was that revenue? 7.What is the total number of orders and average revenue of an order for each customer ranked by average revenue of an order? 8.What is the name of the customer who buys the most product? 9.What is the name of the customer who buys the lest product? 10.Rank sales people by revenue generated.