Chapter 10: Accessing Relational Databases (Self-Study)

Slides:



Advertisements
Similar presentations
Introduction to Structured Query Language (SQL)
Advertisements

Chapter 10 ADO. What is ADO? ADO is a Microsoft technology ADO stands for ActiveX Data Objects ADO is a programming interface to access data in a database.
Introduction to Structured Query Language (SQL)
A Guide to Oracle9i1 Advanced SQL And PL/SQL Topics Chapter 9.
1 Creating a Non-Conditional List A- What are you going to do? You will “list” “all of the records” in a database. (it means you will not use any condition!)
Introduction to Structured Query Language (SQL)
Chapter 7 Managing Data Sources. ASP.NET 2.0, Third Edition2.
Microsoft Access 2010 Chapter 7 Using SQL.
DAY 21: MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Akhila Kondai October 30, 2013.
Chapter 2 Basic SQL SELECT Statements
Chapter 5 Introduction to SQL. Structured Query Language = the “programming language” for relational databases SQL is a nonprocedural language = the user.
ASP.NET Programming with C# and SQL Server First Edition
Advanced Database Management System Lab no. 11. SQL Commands (for MySQL) –Update –Replace –Delete.
Chapter 2 Basic SQL SELECT Statements Oracle 10g: SQL.
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
Chapter 7 Working with Databases and MySQL PHP Programming with MySQL 2 nd Edition.
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
1 Chapter Overview Preparing to Upgrade Performing a Version Upgrade from Microsoft SQL Server 7.0 Performing an Online Database Upgrade from SQL Server.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Oracle 11g: SQL Chapter 4 Constraints.
Chapter 4 Constraints Oracle 10g: SQL. Oracle 10g: SQL 2 Objectives Explain the purpose of constraints in a table Distinguish among PRIMARY KEY, FOREIGN.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
Chapter 1: Overview of SAS System Basic Concepts of SAS System.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Visual Basic CDA College Limassol Campus COM123 Visual Programming 1 Semester B Lecture:Pelekanou Olga Week 5: Useful Functions and Procedures.
Stored Procedures / Session 4/ 1 of 41 Session 4 Module 7: Introducing stored procedures Module 8: More about stored procedures.
IMS 4212: Application Architecture and Intro to Stored Procedures 1 Dr. Lawrence West, Management Dept., University of Central Florida
Oracle Business Intelligence Foundation – Testing and Deploying OBI Repository.
CSC314 DAY 8 Introduction to SQL 1. Chapter 6 © 2013 Pearson Education, Inc. Publishing as Prentice Hall SQL OVERVIEW  Structured Query Language  The.
MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Sravanthi Lakkimsety Mar 14,2016.
Copyright 2009 The Little Engine That Could: Using EXCEL LIBNAME Engine Options to Enhance Data Transfers between SAS® and Microsoft® Excel Files William.
2 Copyright © 2008, Oracle. All rights reserved. Building the Physical Layer of a Repository.
More SQL: Complex Queries, Triggers, Views, and Schema Modification
Session 1 Retrieving Data From a Single Table
DEPTT. OF COMP. SC & APPLICATIONS
INTRODUCTION TO DATABASES (MICROSOFT ACCESS)
Tips for Mastering Relational Databases Using SAS/ACCESS®
Visual Basic 2010 How to Program
Chapter 5 Introduction to SQL.
JDBC Database Management Database connectivity
Chapter 6: Set Operators
Chapter 12 Subqueries and MERGE Oracle 10g: SQL
Prepared by : Moshira M. Ali CS490 Coordinator Arab Open University
Database Systems: Design, Implementation, and Management Tenth Edition
UNIT - V STORED PROCEDURE.
JDBC.
PROC SQL, Overview.
3 Macro Storage.
Building the Physical Layer of a Repository
Chapter 7 Working with Databases and MySQL
Chapter 8 Working with Databases and MySQL
Exploring Microsoft Access 2003
Integrity Constraints
Sirena Hardy HRMS Trainer
A Guide to SQL, Eighth Edition
Lisa Mendez, PhD & Andrew Kuligowski
Introduction to Database Programs
Chapter 10 ADO.
Database Applications
Contents Preface I Introduction Lesson Objectives I-2
Chapter 8 Advanced SQL.
Setting SQL Procedure Options
3 Views.
Database Systems: Design, Implementation, and Management Tenth Edition
Introduction to Database Programs
Updating Databases With Open SQL
Objectives In this lesson, you will learn to:
Shelly Cashman: Microsoft Access 2016
Updating Databases With Open SQL
Presentation transcript:

Chapter 10: Accessing Relational Databases (Self-Study) 2 Chapter 10: Accessing Relational Databases (Self-Study) 10.1 LIBNAME Access to DBMS Data 10.2 Executing DBMS-specific SQL Using the SQL Pass-Through Facility

Chapter 10: Accessing Relational Databases (Self-Study) 2 Chapter 10: Accessing Relational Databases (Self-Study) 10.1 LIBNAME Access to DBMS Data 10.2 Executing DBMS-specific SQL Using the SQL Pass-Through Facility

Objectives Connect to a database management system (DBMS) using the LIBNAME statement. Use DBMS tables in PROC SQL statements. Disconnect from the DBMS.

The LIBNAME Statement (Review) The LIBNAME statement can do the following: establish a libref that acts as a nickname pointing to a collection of data sets (SAS data library) enable referencing of data sets by a two-level name make operating environment-specific references in the remaining program code unnecessary Accessing a SAS library via a libref does not override authentication/permissions restrictions set by the operating system.

The LIBNAME Statement (Review) General form of the LIBNAME statement: LIBNAME libref 'SAS-data-library location' <options>; ...

The LIBNAME Statement (Review) General form of the LIBNAME statement: LIBNAME libref 'SAS-data-library location' <options>; Example (Windows operating system): O/S-specific information libname orion 's:\workshop'; customer.sas7bdat employee_addresses.sas7bdat employee_data.sas7bdat employee_donations.sas7bdat … s:\workshop ...

The LIBNAME Statement (Review) General form of the LIBNAME statement: LIBNAME libref 'SAS-data-library location' <options>; Example (Windows operating system): O/S-specific information libname orion 's:\workshop'; proc sql; select * from orion.customer; quit; customer.sas7bdat employee_addresses.sas7bdat employee_data.sas7bdat employee_donations.sas7bdat … s:\workshop ...

The LIBNAME Statement (Review) General form of the LIBNAME statement: LIBNAME libref 'SAS-data-library location' <options>; Example (Windows operating system): O/S-specific information libname orion 's:\workshop'; proc sql; select * from orion.customer; quit; customer.sas7bdat employee_addresses.sas7bdat employee_data.sas7bdat employee_donations.sas7bdat … s:\workshop ...

The LIBNAME Statement (Review) General form of the LIBNAME statement: LIBNAME libref 'SAS-data-library location' <options>; Example (Windows operating system): O/S-specific information libname orion 's:\workshop'; proc sql; select * from orion.customer; quit; customer.sas7bdat employee_addresses.sas7bdat employee_data.sas7bdat employee_donations.sas7bdat … s:\workshop ...

The LIBNAME Statement (Review) General form of the LIBNAME statement: LIBNAME libref 'SAS-data-library location' <options>; Example (Windows operating system): O/S-specific information libname orion 's:\workshop'; proc sql; select * from orion.customer; quit; customer.sas7bdat employee_addresses.sas7bdat employee_data.sas7bdat employee_donations.sas7bdat … s:\workshop Portable code: No O/S-specific information ...

The LIBNAME Statement (Review) General form of the LIBNAME statement: LIBNAME libref 'SAS-data-library location' <options>; Example (Windows operating system): O/S-specific information libname orion 's:\workshop'; proc sql; select * from orion.customer; quit; customer.sas7bdat employee_addresses.sas7bdat employee_data.sas7bdat employee_donations.sas7bdat … s:\workshop Portable code: No O/S-specific information

LIBNAME Statements Using Access Engines Syntax is modified to provide information required by the DBMS and SAS/ACCESS engine. The assigned libref acts as a nickname for the DBMS. DBMS tables are referenced using two-level names, in the same manner as native SAS data sets. Read access and Write access are controlled by the DBMS authentication/authorization system.  SAS/ACCESS engines can be licensed separately from Base SAS. Check with your SAS Administrator for details specific to your site.

The LIBNAME Statement (Review) General form of the LIBNAME statement using a SAS/ACCESS engine: LIBNAME libref <engine> <engine-specific-options>; ...

The LIBNAME Statement (Review) General form of the LIBNAME statement using a SAS/ACCESS engine: LIBNAME libref <engine> <engine-specific-options>; Example (Windows O/S - Microsoft Access): libname mydbms ACCESS "s:\workshop\sql1.mdb"; Microsoft Access Data Customer Customer ...

The LIBNAME Statement (Review) General form of the LIBNAME statement using a SAS/ACCESS engine: LIBNAME libref <engine> <engine-specific-options>; Example (Windows O/S - Microsoft Access): libname mydbms ACCESS "s:\workshop\sql1.mdb"; Microsoft Access Data proc sql; select * from mydbms.customer; quit; Customer Customer ...

The LIBNAME Statement (Review) General form of the LIBNAME statement using a SAS/ACCESS engine: LIBNAME libref <engine> <engine-specific-options>; Example (Windows O/S - Microsoft Access): libname mydbms ACCESS "s:\workshop\sql1.mdb"; Microsoft Access Data proc sql; select * from mydbms.customer; quit; Customer Customer ...

The LIBNAME Statement (Review) General form of the LIBNAME statement using a SAS/ACCESS engine: LIBNAME libref <engine> <engine-specific-options>; Example (Windows O/S - Microsoft Access): libname mydbms ACCESS "s:\workshop\sql1.mdb"; Microsoft Access Data proc sql; select * from mydbms.customer; quit; Customer Customer ...

The LIBNAME Statement (Review) General form of the LIBNAME statement using a SAS/ACCESS engine: LIBNAME libref <engine> <engine-specific-options>; Example (Windows O/S - Microsoft Access): libname mydbms ACCESS "s:\workshop\sql1.mdb"; Microsoft Access Data proc sql; select * from mydbms.customer; quit; Customer Portable code: No O/S-specific information

SAS/ACCESS LIBNAME Statement Examples Oracle: libname mylib oracle user=UserID pw=password path=dbmspath schema=dbms_schema; DB2 (z/OS): libname mylib db2 authid=UserID ssid=db2; DB2 (UNIX/PC): libname mylib db2 user=UserID pw=password schema=dbms_schema; ODBC: libname libname mylib odbc datasrc=sql1;  Syntax varies by DBMS engine and operating system. Contact your SAS Administrator for information specific to your site.

The LIBNAME Statement – Disconnecting General form of the LIBNAME statement when de-allocating a SAS library or disconnecting from a DBMS: LIBNAME libref CLEAR; Example: libname mydbms clear;

Accessing DBMS Data with the LIBNAME Statement This demonstration includes the following tasks: assigning a libref to a Microsoft Access database creating, querying, and dropping a table in the DBMS using standard PROC SQL syntax s110d01

Chapter 10: Accessing Relational Databases (Self-Study) 2 Chapter 10: Accessing Relational Databases (Self-Study) 10.1 LIBNAME Access to DBMS Data 10.2 Executing DBMS-specific SQL Using the SQL Pass-Through Facility

Objectives Connect to a DBMS using the CONNECT statement. Issue native SQL statements to the DBMS for execution. Disconnect from the DBMS.

Overview The SQL Procedure Pass-Through Facility communicates with the DBMS through the SAS/ACCESS engine. The facility enables you to do the following: pass native DBMS SQL statements to a DBMS display query results formatted by PROC SQL save query results as SAS data files create SAS data views containing pass-through queries

Overview SQL statements you can submit to the DBMS include these statements: SELECT statements (pass-through queries), which return output to SAS in a manner similar to in-line views EXECUTE statements, which include SQL statements that do not produce output (for example, CREATE TABLE, UPDATE, and DELETE)

SQL Procedure Pass-Through Queries An SQL pass-through query consists of the statements listed below: a CONNECT statement a SELECT expression a DISCONNECT statement

Connecting to the DBMS The CONNECT statement can do the following: specify the DBMS name provide other DBMS-specific connection information (optional for some databases) establish the connection to the DBMS specify an alias for the connection (optional)

Connecting to the DBMS General form of the CONNECT statement: CONNECT TO dbms-engine <AS alias> (options);

Connecting to Microsoft Access Example: Connect to a Microsoft Access table. proc sql; connect to ACCESS as mydbms (path="./sql1.mdb"); s110d02

The SELECT Expression The PROC SQL SELECT expression for SQL pass-through consists of these elements: a PROC SQL SELECT expression a FROM CONNECTION TO component the SQL code to be passed to the DBMS other PROC SQL clauses necessary to finish processing the data returned by the pass-through query

The SELECT Expression The query passed to the DBMS uses DBMS-specific SQL syntax that will be processed inside the DBMS and not by SAS must reference only DBMS table column names is enclosed in matching parentheses.  A pass-through query must have valid DBMS SQL syntax. PROC SQL does not evaluate the syntax of pass-through queries.

SELECT from Microsoft Access Example: Select from pass-through to Microsoft Access. The SELECT statement containing the FROM CONNECTION TO clause uses the data returned by the pass-through query in a manner similar to an in-line view. proc sql; connect to ACCESS as mydbms (path="./sql1.mdb"); title "Report using SQL Passthrough"; select * from connection to mydbms (select Product_Name, Price from Catalog_2007 order by Product_Name) ; s110d02

SELECT from Microsoft Access Example: Combine a pass-through and SAS data. proc sql; connect to ACCESS as mydbms (path="./sql1.mdb"); title "SQL Passthrough and SAS Tables"; select of.Product_ID, Product_Name, Price, count(*) as Number_Sold from connection to mydbms (select Product_ID, Product_Name, Price from Catalog_2007 order by Product_Name) as pt, orion.Order_Fact as of where of.Product_ID=pt.Product_ID group by of.Product_ID ; s110d02

Closing the DBMS Connection You can close the connection to the DBMS by either of these methods: submitting a DISCONNECT statement terminating the SQL procedure, for example, with a QUIT statement General form of the DISCONNECT statement: DISCONNECT FROM dbms-engine | alias;

Closing the Connection to Microsoft Access Example: Disconnect from Microsoft Excel or Access. proc sql; connect to ACCESS as mydbms (path="./sql1.mdb"); title "Report using SQL Passthrough"; select * from connection to mydbms (select Product_Name, Price from Catalog_2007 order by Product_Name) ; disconnect from mydbms; quit; s110d02

Accessing DBMS Data with the LIBNAME Statement This demonstration includes the following: using a CONNECT statement to access DBMS data from a PROC SQL invocation using the SQL Pass-Through Facility to execute DBMS-specific SQL to do the tasks: modify a DBMS table’s structure create and drop a DBMS view query DBMS tables and views s110d02