quick review of sql and conversion to oracle sql

12
Quick review of SQL And conversion to Oracle SQL

Upload: vanessa-johnston

Post on 03-Jan-2016

216 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Quick review of SQL And conversion to Oracle SQL

Quick review of SQL

And conversion to Oracle SQL

Page 2: Quick review of SQL And conversion to Oracle SQL

Assuming…

• You know how to model data using– An ER diagram– A class diagram

• You know how to translate entity-relationship models into:– Tables– With constraints

Page 3: Quick review of SQL And conversion to Oracle SQL

SQL

• Structured Query Language• Made up of the following components:

– Data Manipulation Language (DML)– Data Definition Language (DDL)– Transaction control– Data Control Language (DCL)

• Oracle SQL complies with the core ANSI/ISO standard for SQL:2003, but is not completely compliant.

• It also has extensions, that are not compliant, so are not portable to non-Oracle databases.

Page 4: Quick review of SQL And conversion to Oracle SQL

DML

• SELECT

• INSERT

• UPDATE

• DELETE

Page 5: Quick review of SQL And conversion to Oracle SQL

DDL

• CREATE

• ALTER

• DROP– Any object in the database.

• TRUNCATE– Deletes all rows in a table.

Page 6: Quick review of SQL And conversion to Oracle SQL

Transaction control

• A database transaction is a unit of work that leaves the database in a consistent state.

• To ensure consistency, ongoing work can be committed, rolled back to a checkpoint, or rolled back completely.

• COMMIT

• ROLLBACK

Page 7: Quick review of SQL And conversion to Oracle SQL

Data Control Language

• These control user access to an Oracle database.

• These instructions include:– GRANT– REVOKE– SET ROLE…

Page 8: Quick review of SQL And conversion to Oracle SQL

Exercises Lab 1, Week 1• Learn the datatypes that are used in Oracle 10g.• Retrieve all columns and rows• Retrieve specific columns• Use SQL*Plus DESCRIBE command• Specify an alias for a column• Learn the SQL built-in functions provided by Oracle.• Learn about the DUAL table.• Build SELECT clause expressions

– with the Concatenation String operator– with arithmetic operators– with SQL built-in functions.

• Work with NULLs in a SELECT clause expression• Implement conditional log in SELECT clause expressions.• Retrieve specific rows from tables.

Page 9: Quick review of SQL And conversion to Oracle SQL

Exercises Lab 2, Week 1

• Building WHERE clause conditions– with relational operators– With subqueries

• Building composite WHERE Clause conditions with logical operators

• Grouping records in a query’s result set.• Rolling up groups into supergroups.• Ordering records in a query’s result set• Building an inner join of two tables• Building an outer join of two tables.• Inserting new rows in a table• Deleting rows from a table.

Page 10: Quick review of SQL And conversion to Oracle SQL

Lab 1 Week 2

• Committing and Rolling back transactions

• Writing and storing scripts.

Page 11: Quick review of SQL And conversion to Oracle SQL

Lab 2 Week 2

• Data Definition Language

• DCL

Page 12: Quick review of SQL And conversion to Oracle SQL

References

‘Hands-on Oracle Database 10g Express Edition for Windows’, Bobrowski, S., Oracle Press, McGraw Hill / Osborne, 2006.

‘Oracle Database 10g A Beginner’s guide’, Abramson, I., Abbey, M., Corey, M., Oracle Press, McGraw Hill / Osborne, 2004.