370 likes | 629 Vues
SQL Review. Just Enough to Get Us Started!!!. Learning Objectives. IST359 Refresher course Comparison Microsoft SQL Server to Oracle 11g in “Death Match” Cover some of the improvements and annoyances between the two. References to learn more on your own. The Relational Database Model.
E N D
SQL Review Just Enough to Get Us Started!!!
Learning Objectives IST359 Refresher course Comparison Microsoft SQL Server to Oracle 11g in “Death Match” Cover some of the improvements and annoyances between the two. References to learn more on your own.
Relational Terminology Categories Table / Relation Row Column Attribute Null Primary Key Candidate Key Composite Key Unique Constraint Check Constraint Default Foreign Key Entity Integrity Referential Integrity
Tables Metadata Structured buckets for your data Columns have data types (physical domain) Columns have acceptable values (logical domain)
Tables VS
SQL - Language Data Definition Language Data Manipulation Language Data SELECT INSERT UPDATE DELETE Metadata • CREATE • ALTER • DROP
Data Types VS SQL Server Oracle Id int State char(2) Name varchar2(50) Gpa decimal(4,3) Dob date Resume clob NO BIT TYPE!!! • Id int • State char(2) • Name varchar(50) • Gpa decimal(4,3) • Dob datetime • Resume text • IstMajor bit
Boolean Types VS • There is no bit type in oracle. • Workaround: • char(1) • Check constraint
Sequences VS • There is noint identity in oracle. • You create a sequenceobject and use thesequence during theinsert…. …How about a demo?
Alter table VS You cannot manipulate more than column or constraint with alter table
SQL - Language Data Definition Language Data Manipulation Language Data SELECT INSERT UPDATE DELETE Metadata • CREATE • ALTER • DROP
No Auto Commit VS SQL Server defaults to“Auto Commit” Mode. INSERT, UPDATE, and DELETE statementsare permanent. In Oracle they are NOT You must explicitly COMMIT or ROLLBACK …How about a few demos?
Varchar2 VS Why VARCHAR2? Only Oracle knows for sure. Empty String ‘’ is the same as NULL,in Oracle. … Demo?
Date Data VS To Insert a date value in Oracle you need touse the to_date()function
Dual Table VS You Can’tMake This Stuff Up! In Oracle you cannot useSELECT without the from clause so you need to use an empty table called dual. NO: YES:
SELECT Processing HOW WE SAY IT HOW IT IS PROCESSED FROM WHERE GROUP BY HAVING SELECT (Projection) ORDER BY DISTINCT • SELECT (Projection) • DISTINCT • FROM • WHERE • GROUP BY • HAVING • ORDER BY
SELECT - Demos • Aliasing • WHERE • ORDER BY • JOIN • MULTI-TABLE • OUTER • GROUP BY • HAVING
No TOP VS Oracle has no TOP clause. So you need to use an addition to your where clause.
Tooling VS SQL Server Oracle Oracle Enterprise Manager, Oracle SQL Developer OEM is for Database Administration SQL Dev is for Script and Query Writing • SQL Server Management Studio • SSMS does it all.
VS SYSDATE or GETDATE http://www.dba-oracle.com/oracle_news/2005_12_16_sql_syntax_differences.htm
Summary VS • Must end each SQL statement in ; No “go” • No INT Identity • (must use sequences, which are better anyways, imo) • Every INSERT, UPDATE and DELETE is a TRANSACTION • (SET IMPLICIT_TRANSACTIONS ON in SQL Server) • VARCHAR2 datatype NULL == “” • The Dual table….oy.
SQL Review Questions? Comments?