SQL DATABASE PROGRAMMING (PL/SQL AND T-SQL)



Similar documents
UC BERKELEY EXTENSION

Module 2: Database Architecture

ORACLE DATABASE 11G: COMPLETE

COURCE TITLE DURATION. Oracle Database 11g: Administration Workshop I

UNIVERSITY AUTHORISED EDUCATION PARTNER (WDP)

Oracle Database: SQL and PL/SQL Fundamentals NEW

SQL Server to Oracle A Database Migration Roadmap

Oracle. Brief Course Content This course can be done in modular form as per the detail below. ORA-1 Oracle Database 10g: SQL 4 Weeks 4000/-

Oracle 11g Database Administration

Oracle Database 12c: Admin, Install and Upgrade Accelerated

D12C-AIU Oracle Database 12c: Admin, Install and Upgrade Accelerated NEW

Oracle Architecture, Concepts & Facilities

Oracle Database 11g: Administration Workshop I

Oracle Database 12c: Administration Workshop NEW

Oracle Database 12c: Administration Workshop NEW. Duration: 5 Days. What you will learn

Microsoft SQL Server for Oracle DBAs Course 40045; 4 Days, Instructor-led

AV-004: Administering and Programming with ORACLE

6231B: Maintaining a Microsoft SQL Server 2008 R2 Database

Oracle Database 11 g Performance Tuning. Recipes. Sam R. Alapati Darl Kuhn Bill Padfield. Apress*

Oracle Database 11g: Administration Workshop I Release 2

MyOra 3.5. User Guide. SQL Tool for Oracle. Kris Murthy

MS-40074: Microsoft SQL Server 2014 for Oracle DBAs

SQL Server What s New? Christopher Speer. Technology Solution Specialist (SQL Server, BizTalk Server, Power BI, Azure) v-cspeer@microsoft.

RARITAN VALLEY COMMUNITY COLLEGE COMPUTER SCIENCE (CS) DEPARTMENT. CISY-294, Oracle: Database Administration Fundamentals Part I

Oracle Database 10g: New Features for Administrators

Introduction. Part I: Finding Bottlenecks when Something s Wrong. Chapter 1: Performance Tuning 3

ORACLE DATABASE: ADMINISTRATION WORKSHOP I

Mind Q Systems Private Limited

SQL Server 2012 Database Administration With AlwaysOn & Clustering Techniques

Oracle Database 11g: Administration Workshop I Release 2

Objectif. Participant. Prérequis. Pédagogie. Oracle Database 11g - Administration Workshop I Release 2. 5 Jours [35 Heures]

AV-005: Administering and Implementing a Data Warehouse with SQL Server 2014

Oracle Database 11g: New Features for Administrators DBA Release 2

Oracle DBA Course Contents

Oracle 11g DBA Training Course Content

SQL Databases Course. by Applied Technology Research Center. This course provides training for MySQL, Oracle, SQL Server and PostgreSQL databases.

MyOra 3.0. User Guide. SQL Tool for Oracle. Jayam Systems, LLC

Oracle Database 12c: Performance Management and Tuning NEW

Oracle Database 10g: Administration Workshop II Release 2

Topics Advanced PL/SQL, Integration with PROIV SuperLayer and use within Glovia

Oracle Database 12c Administration Workshop

Beginning SQL Server Administration. Apress. Rob Walters Grant Fritchey

Querying Microsoft SQL Server 2012

Course 10774A: Querying Microsoft SQL Server 2012 Length: 5 Days Published: May 25, 2012 Language(s): English Audience(s): IT Professionals

FIFTH EDITION. Oracle Essentials. Rick Greenwald, Robert Stackowiak, and. Jonathan Stern O'REILLY" Tokyo. Koln Sebastopol. Cambridge Farnham.

Administering Microsoft SQL Server 2012 Databases

Introducing Microsoft SQL Server 2012 Getting Started with SQL Server Management Studio

Course 10774A: Querying Microsoft SQL Server 2012

Sivakumar Software Engg, Zagro Singapore Pte Ltd .

Would-be system and database administrators. PREREQUISITES: At least 6 months experience with a Windows operating system.

MS SQL Server 2014 New Features and Database Administration

<Insert Picture Here> Oracle SQL Developer 3.0: Overview and New Features

Oracle Database 11g: SQL Tuning Workshop

Oracle 11g New Features - OCP Upgrade Exam

Below are the some of the new features of SQL Server that has been discussed in this course

Oracle Database Creation for Perceptive Process Design & Enterprise

Getting to Know the SQL Server Management Studio

Module 15: Monitoring

W I S E. SQL Server 2012 Database Engine Technical Update WISE LTD.

Objectif. Participant. Prérequis. Pédagogie. Oracle Database 11g - New Features for Administrators Release 2. 5 Jours [35 Heures]

Outline. MCSE: Data Platform. Course Content. Course 10776C: MCSA: Developing Microsoft SQL Server 2012 Databases 5 Days

Oracle vs. SQL Server. Simon Pane & Steve Recsky First4 Database Partners Inc. September 20, 2012

SQL Server Administrator Introduction - 3 Days Objectives

SQL Server Developer Training Program. Topics Covered

Oracle Database: Develop PL/SQL Program Units

$99.95 per user. SQL Server 2005 Database Administration CourseId: 152 Skill level: Run Time: 30+ hours (158 videos)

Oracle 11g PL/SQL training

Module 1: Getting Started with Databases and Transact-SQL in SQL Server 2008

W I S E. SQL Server 2008/2008 R2 Advanced DBA Performance & WISE LTD.

- An Oracle9i RAC Solution

Oracle Database 11g Comparison Chart

Writing Queries Using Microsoft SQL Server 2008 Transact-SQL

Customer evaluation guide Toad for Oracle v12 Database administration

Oracle Database Security and Audit

1. This lesson introduces the Performance Tuning course objectives and agenda

ORACLE DBA 11G TRAINING

10775A Administering Microsoft SQL Server 2012 Databases

Oracle Database: Program with PL/SQL

10775 Administering Microsoft SQL Server Databases

Real-time Data Replication

Oracle and Sybase, Concepts and Contrasts

Course ID#: W 35 Hrs. Course Content

Oracle Architecture. Overview

$99.95 per user. SQL Server 2008/R2 Database Administration CourseId: 157 Skill level: Run Time: 47+ hours (272 videos)

Administering Microsoft SQL Server 2012 Databases

Querying Microsoft SQL Server 20461C; 5 days

Concepts of Database Management Seventh Edition. Chapter 7 DBMS Functions

Monitoring and Diagnosing Oracle RAC Performance with Oracle Enterprise Manager. Kai Yu, Orlando Gallegos Dell Oracle Solutions Engineering

Upgrading to Microsoft SQL Server 2008 R2 from Microsoft SQL Server 2008, SQL Server 2005, and SQL Server 2000

Writing Queries Using Microsoft SQL Server 2008 Transact-SQL

Oracle 11g DBA Online Course - Smart Mind Online Training, Hyderabad. Oracle 11g DBA Online Training Course Content

Many DBA s are being required to support multiple DBMS s on multiple platforms. Many IT shops today are running a combination of Oracle and DB2 which

Oracle Database 11g: Administration Workshop II DBA Release 2

Oracle Database 10g. Page # The Self-Managing Database. Agenda. Benoit Dageville Oracle Corporation benoit.dageville@oracle.com

MS-10775: Administering Microsoft SQL Server 2012 Databases. Course Objectives. Required Exam(s) Price. Duration. Methods of Delivery.

Transcription:

Technology & Information Management Instructor: Michael Kremer, Ph.D. Database Programming SQL DATABASE PROGRAMMING (PL/SQL AND T-SQL)

WHO AM I? Michael Kremer Currently: Federal Reserve Bank San Francisco Previously: Lawrence Berkeley National Laboratory Department of Energy Database/Application Developer dbase, Access Developer for over 20 years Instructor for UC Extension since 1998 DB: Oracle, SQL Server, Access Prog.: ASP.net. C#, VB/VBA, Java/Javascript Reporting: Cognos, Actuate

WHO ARE YOU? Name/Company/Organization What do you do? Computer Experience (OS, Application SW, Other Classes Taken, etc.) Database Platform/Experience Expectations/Goals Any other information about you such as hobbies, special interests, fun facts, etc.

AGENDA 1. Introduction to Oracle/SQL Server Database Programming 1.1 SQL and Database Programming 1.2 Structure of Database Programs 1.3 Differences between Oracle and SQL Server 1.4 Graphical Database Management Tools

SQL Database Programming (PL/SQL and T-SQL) 1. INTRODUCTION TO ORACLE/SQL SERVER DATABASE PROGRAMMING

1.1 SQL AND DATABASE PROGRAMMING 1 Limitations of non-procedural SQL lead to programmatic extensions SQL is set-based and non-procedural, you specify the What but not the how. You specify your requirement for a processed result to be obtained from a set of data. Database engine internally resolves exactly how to get to the end result. Using a Procedural approach, you specify the What and the How. You write data operational and manipulation logic using loops, conditions, and processing statements to produce the final result.

1.1 SQL AND DATABASE PROGRAMMING 2 Using a cursor that executes on a result set row by row is a procedural approach. Also using a user-defined function in your SQL is procedural. Whenever possible, use non-procedural SQL since internal database engine is optimized for set-based processing. When using procedural SQL on a row-by-row basis the database engine optimizes each row separately causing significant overhead (I/O processing). The underlying message here is to minimize the amount of procedural SQL due to performance reasons. Many procedural SQL code can be rewritten into non-procedural SQL statements using subqueries, With clause, and other sophisticated constructs.

1.2 STRUCTURE OF DATABASE PROGRAMS 3 Structure of database programs is similar to other procedural programs. Header: Program has a distinct name, you may pass arguments into it, and it also may return values back to the calling environment. Oracle PL/SQL SQL Server T-SQL Declaration: Variables and other special directives. Execution: Actual programming code. Exception: Handling of errors. IS Begin Header Declaration Execution Exception AS Header Begin Try End Try Execution Begin Catch Exception End; Exception End Catch

1.2 STRUCTURE OF DATABASE PROGRAMS 4 Breaking up large code into smaller, manageable units. Oracle PL/SQL Header Oracle only: Nesting of procedures IS Declaration Procedures are nested within a main program. In SQL Server, use procedures that can be called from each other. Main Program IS Begin Header Declaration Execution Sub Program End; Begin Execution End;

5 1.3 DIFFERENCES BETWEEN ORACLE AND SQL SERVER Versions and Editions SQL Server runs only on Windows platform, whereas Oracle runs additionally on Unix/Linux. Current Versions: SQL Server 2012, Oracle 12c R1 SQL Server Editions: Enterprise: Mission critical applications and data warehousing Business Intelligence: Premium corporate and self-service Business Intelligence capabilities Standard: Basic database capabilities, reporting and analytics. Express, Developer

6 1.3 DIFFERENCES BETWEEN ORACLE AND SQL SERVER Oracle Editions: Enterprise: Top performance for top money, all features enabled Standard: Major features enabled, suitable for most business applications, Standard Edition One: For small workgroups, licensed for min. 5 users. Personal Edition: Single-user development and deployment environments, full Oracle version Express: Low footprint, SQL Server 2012 Oracle 12c R1 Enterprise Edition Enterprise Edition small-scale, starter DB Business Intelligence Edition Standard Edition Express Edition Developer Edition Standard Edition Standard Edition One Express Edition Personal Edition

7 1.3 DIFFERENCES BETWEEN ORACLE AND SQL SERVER Instances and Databases/Tablespaces Major architectural difference between SQL Server and Oracle: Instance and Database. SQL Server Instance: Self-contained application service involving operating system files, memory structures, background processes and registry information Service running in Windows. SQL Server database is repository of data and program code. If instance not running, database cannot be accessed. Oracle instance is comprised of memory structures (SGA) and background processes. An instance can be running without a database running. Oracle database is a collection of OS files, Oracle db does not represent the logical grouping of objects.

8 1.3 DIFFERENCES BETWEEN ORACLE AND SQL SERVER Oracle files: Data files, Redo log, Control file SQL Server files: Database files, Transaction log, no control file! Oracle instance starts (without a database), then connecting to database. SQL Server instance cannot start without its system database being online. Oracle and SQL Server database cannot be accessed without an instance running. Logical Oracle: Tablespaces SQL Server: Databases Oracle: Segments SQL Server: N/A Physical Oracle: Data Files SQL Server: DB Files Oracle: Extents SQL Server: Extents Oracle: Data Blocks SQL Server: Pages OS Block

9 1.3 DIFFERENCES BETWEEN ORACLE AND SQL SERVER In general, one-to-one relationship between instance and DB. SQL Server logical grouping is done by the database itself. In Oracle, it is done through tablespaces. Tablespaces are logical structures that group tables, views, indexes, SP, etc. together. Tablespace for payroll, within HR, for example. Oracle Tablespace = SQL Server Database Databases and tablespaces do differ in the following areas: SQL Server database files can be logically grouped into filegroups. In Oracle, no such concept for tablespaces. Each SQL Server database has its own transaction log and log file. In Oracle, one transaction log for all tablespaces. SQL Server database can be configure for simple recovery mode. In Oracle, only possible at the db level (meaning for all tablespaces).

10 1.3 DIFFERENCES BETWEEN ORACLE AND SQL SERVER Instance Name vs. SIDs Both SQL Server and Oracle allow multiple instances to run concurrently on the same machine. SQL Server: Default instance (backward compatibility for version 2000) and named instances. Oracle: System ID (SID) names the instance. SQL Server and Oracle instances must be unique and cannot be changed later. SQL Server Host Instance: Self-contained application service involving os files, memory, processes. Oracle Host Instance: Only memory allocation and processes. Schema: Logical grouping of database objects, owner and user of objects Database: Collection of OS files. Database: System databaes(needed for instance to run) and user databases. Tablespace: Logical structure for grouping db objects.

11 1.3 DIFFERENCES BETWEEN ORACLE AND SQL SERVER To find out the instance name: SQL Server: SELECT @@SERVERNAME Oracle: SELECT instance_name, host_name, version, database_status FROM V$INSTANCE System Databases and System Tablespaces One SQL Server Instance needs 5 databases: Master and Resource db are central repositories for SQL Server to manage itself. Model db is template used for every new db created. Tempdb is kind of scratchpad, created when instance is started and destroyed when it is shut down. msdb is used for SQL Server agents, such as job scheduling, alerts, logging and replication.

12 1.3 DIFFERENCES BETWEEN ORACLE AND SQL SERVER One Oracle database needs 3 tablespaces: SYSTEM tablespace is similar to SQL Server master db. It holds the data dictionary about the database itself (Meta data). TEMP tablespace is used for sort operations. SYSAUX tablespace is used for Oracle s Automatic Workload Repository (AWR), spatial and multimedia data, XML database, etc. SQL Server (since version 2008) uses tempdb for row versioning (consistent read). Oracle rebuilds previous row version data from UNDO tablespace. UNDO tablespace is used for several features: ROLLBACK, READ CONSISTENCY and FLASHBACK technology.

1.4 GRAPHICAL DATABASE MANAGEMENT TOOLS 13 Graphical Database Management Tools: Oracle SQL Developer SQL Server Management Studio SQL Server Management Studio (SSMS) Hierarchical structure contains the following nodes: Databases: System Databases Additional nodes for user databases

1.4 GRAPHICAL DATABASE MANAGEMENT TOOLS 14 Security: Manage users, roles, credentials Server Objects: Backup devices, linked servers, and server triggers. Replication: For managing database replication Management: Policy management, server logs, legacy services such as DTS (replaced by SISS) in 2008. Most important node: Database node Under the Database node, for the scope of this course, the Programmability node. Database Node Programmability Node

1.4 GRAPHICAL DATABASE MANAGEMENT TOOLS 15

1.4 GRAPHICAL DATABASE MANAGEMENT TOOLS 16

1.4 GRAPHICAL DATABASE MANAGEMENT TOOLS 17

1.4 GRAPHICAL DATABASE MANAGEMENT TOOLS 18 Oracle SQL Developer Free, Oracle Java-based Database Management tool.

1.4 GRAPHICAL DATABASE MANAGEMENT TOOLS 19

1.4 GRAPHICAL DATABASE MANAGEMENT TOOLS 20 Organization of database objects is very different compared to SQL Server. Most important nodes for the scope of this course are: Procedures Functions Triggers