Module 11: Programming Across Multiple Servers. Overview Introducing Distributed Queries Setting Up a Linked Server Environment Working with Linked Servers.

Slides:



Advertisements
Similar presentations
DB glossary (focus on typical SQL RDBMS, not XQuery or SPARQL)
Advertisements

Module 8 Importing and Exporting Data. Module Overview Transferring Data To/From SQL Server Importing & Exporting Table Data Inserting Data in Bulk.
The Relational Model and Relational Algebra Nothing is so practical as a good theory Kurt Lewin, 1945.
Module 17 Tracing Access to SQL Server 2008 R2. Module Overview Capturing Activity using SQL Server Profiler Improving Performance with the Database Engine.
Advantage Data Dictionary. agenda Creating and Managing Data Dictionaries –Tables, Indexes, Fields, and Triggers –Defining Referential Integrity –Defining.
Module 5: Implementing Data Integrity. Overview Types of Data Integrity Enforcing Data Integrity Defining Constraints Types of Constraints Disabling Constraints.
Module 15: Managing Transactions and Locks. Overview Introduction to Transactions and Locks Managing Transactions SQL Server Locking Managing Locks.
Introduction to Structured Query Language (SQL)
Module 9: Implementing Stored Procedures. Introduction to Stored Procedures Creating Executing Modifying Dropping Using Parameters in Stored Procedures.
SQL components In Oracle. SQL in Oracle SQL is made up of 4 components: –DDL Data Definition Language CREATE, ALTER, DROP, TRUNCATE. Creates / Alters.
ASP.NET Database Connectivity I. 2 © UW Business School, University of Washington 2004 Outline Database Concepts SQL ASP.NET Database Connectivity.
Chapter 7 Advanced SQL Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
Introduction to Structured Query Language (SQL)
Functions of a Database Management System. Functions of a DBMS C.J. Date n Indexing n Views n Security n Integrity n Concurrency n Backup/Recovery n Design.
Distributed Databases
Copying, Managing, and Transforming Data With DTS.
Administration of Users Dr. Gabriel. 2 Documentation of User Administration Part of the administration process Reasons to document: –Provide a paper trail.
DAY 21: MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Akhila Kondai October 30, 2013.
Overview What is SQL Server? Creating databases Administration Security Backup.
Module 9: Managing Schema Objects. Overview Naming guidelines for identifiers in schema object definitions Storage and structure of schema objects Implementing.
Advance Computer Programming Java Database Connectivity (JDBC) – In order to connect a Java application to a database, you need to use a JDBC driver. –
Module 3: Changes to Transact-SQL. Overview Accessing Object Information New Transact-SQL Syntax Changes to Objects Distributed Queries.
Database Technical Session By: Prof. Adarsh Patel.
ABC Insurance Co. Paul Barry Steve Randolph Jing Zhou CSC8490 Database Systems & File Management Dr. Goelman Villanova University August 2, 2004.
Module 2: Creating Efficient Replication Solutions.
Module 8: Implementing Stored Procedures. Introducing Stored Procedures Creating, Modifying, Dropping, and Executing Stored Procedures Using Parameters.
Module 9 Designing and Implementing Stored Procedures.
SQL/Lesson 4/Slide 1 of 45 Using Subqueries and Managing Databases Objectives In this lesson, you will learn to: *Use subqueries * Use subqueries with.
Populating a Data Warehouse. Overview Process Overview Methods of Populating a Data Warehouse Tools for Populating a Data Warehouse Populating a Data.
Module 10 Assigning Server and Database Roles. Module Overview Working with Server Roles Working with Fixed Database Roles Creating User-defined Database.
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Nitin Singh/AAO RTI ALLAHABAD 1 SQL Nitin Singh/AAO RTI ALLAHABAD 2 OBJECTIVES §What is SQL? §Types of SQL commands and their function §Query §Index.
Lecture # 3 & 4 Chapter # 2 Database System Concepts and Architecture Muhammad Emran Database Systems 1.
Views Lesson 7.
A Brief Documentation.  Provides basic information about connection, server, and client.
Module 4 Designing and Implementing Views. Module Overview Introduction to Views Creating and Managing Views Performance Considerations for Views.
1 Introduction to Oracle Chapter 1. 2 Before Databases Information was kept in files: Each field describes one piece of information about student Fields.
Module 3 Designing and Implementing Tables. Module Overview Designing Tables Working with Schemas Creating and Altering Tables.
Oracle 11g: SQL Chapter 4 Constraints.
Module 4: Implementing Data Integrity
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.
06 | Modifying Data in SQL Server Brian Alderman | MCT, CEO / Founder of MicroTechPoint Tobias Ternstrom | Microsoft SQL Server Program Manager.
Permissions Lesson 13. Skills Matrix Security Modes Maintaining data integrity involves creating users, controlling their access and limiting their ability.
Module 11 Authorizing Users to Access Resources. Module Overview Authorizing User Access to Objects Authorizing Users to Execute Code Configuring Permissions.
Module 5: Implementing Merge Replication. Overview Understanding Merge Replication Architecture Implementing Conflict Resolution Planning and Deploying.
Chapter 5 : Integrity And Security  Domain Constraints  Referential Integrity  Security  Triggers  Authorization  Authorization in SQL  Views 
Session 1 Module 1: Introduction to Data Integrity
Learningcomputer.com SQL Server 2008 –Views, Functions and Stored Procedures.
SQL Server 2005 Implementation and Maintenance Chapter 6: Security and SQL Server 2005.
Module 11: Managing Transactions and Locks
Starting with Oracle SQL Plus. Today in the lab… Connect to SQL Plus – your schema. Set up two tables. Find the tables in the catalog. Insert four rows.
Stored Procedures / Session 4/ 1 of 41 Session 4 Module 7: Introducing stored procedures Module 8: More about stored procedures.
Module 14: Managing Transactions and Locks. Overview Introducing Transactions and Locks Managing Transactions Understanding SQL Server Locking Architecture.
Module 10 Merging Data and Passing Tables. Module Overview Using the MERGE Statement Implementing Table Types Using Table Types As Parameters.
1 Information Retrieval and Use De-normalisation and Distributed database systems Geoff Leese September 2008, revised October 2009.
Module 8: Using Programming Objects for Data Retrieval.
1 Database Fundamentals Introduction to SQL. 2 SQL Overview Structured Query Language The standard for relational database management systems (RDBMS)
SQL Triggers, Functions & Stored Procedures Programming Operations.
 CONACT UC:  Magnific training   
Views / Session 3/ 1 of 40 Session 3 Module 5: Implementing Views Module 6: Managing Views.
In this session, you will learn to: Manage databases Manage tables Objectives.
11 Copyright © 2009, Oracle. All rights reserved. Enhancing ETL Performance.
Data Integrity & Indexes / Session 1/ 1 of 37 Session 1 Module 1: Introduction to Data Integrity Module 2: Introduction to Indexes.
SQL IMPLEMENTATION & ADMINISTRATION Indexing & Views.
Module 5: Implementing Data Integrity by Using Constraints
Contents Preface I Introduction Lesson Objectives I-2
Database Design: Relational Model
INTRODUCTION A Database system is basically a computer based record keeping system. The collection of data, usually referred to as the database, contains.
Presentation transcript:

Module 11: Programming Across Multiple Servers

Overview Introducing Distributed Queries Setting Up a Linked Server Environment Working with Linked Servers Using Partitioned Views

Lesson: Introducing Distributed Queries What Are Distributed Queries? Ad Hoc Query Execution on Remote Data Source

What Are Distributed Queries? Remote Data Access  Ad hoc query  Linked server query Specify Where to Process Distributed Queries  Local computer running SQL Server  Remote OLE DB data source (pass-through query) Verify Connection Settings

Ad Hoc Query Execution on Remote Data Source Use the OPENROWSET Function When You Do Not Expect to Use the Data Source Repeatedly Use the OPENROWSET Function to Access Remote Data Without Setting Up a Linked Server SELECT a.* FROM OPENROWSET('SQLOLEDB', 'LONDON1'; 'newcustomer';'mypassword', 'SELECT ProductID, UnitPrice FROM Northwind.dbo.Products ORDER BY UnitPrice') AS a SELECT a.* FROM OPENROWSET('SQLOLEDB', 'LONDON1'; 'newcustomer';'mypassword', 'SELECT ProductID, UnitPrice FROM Northwind.dbo.Products ORDER BY UnitPrice') AS a

Lesson: Setting Up a Linked Server Environment What Is a Linked Server? How Links Are Established Security Considerations Configuration Options Linked Server Information

What Is a Linked Server? Other Data SourcesRemote SQL Server SQL Server allows access to other data sources Remote servers must be linked to the local computer running SQL Server Local Computer Running SQL Server Remote Computer Running SQL Server

How Links Are Established Connecting to a Remote Computer Running SQL Server Connecting to an OLE DB Data Source EXEC = = 'SQL Server' EXEC = = 'SQL Server' EXEC = = = = 'OracleDB' EXEC = = = = 'OracleDB'

Security Considerations Local Server Must Log On to Remote Server on Behalf of User If User’s Logon Account Exists on Both Servers, It Can Be Used to Log On to Remote Server Use sp_addlinkedsrvlogin to Map Logon Accounts Use Security Account Delegation to Connect to Multiple Servers with One Authentication

Configuration Options Collation Compatible USE master EXEC sp_serveroption 'AccountingServer', 'collation compatible', true USE master EXEC sp_serveroption 'AccountingServer', 'collation compatible', true Collation Name and Use Remote Collation Data Access RPC and RPC out Lazy Schema Validation

System stored procedure Returns sp_linkedservers A list of linked servers defined on the local server sp_catalogs A list of catalogs and descriptions for a specific linked server sp_indexes Index information for the specified remote table sp_primarykeys The primary key columns, one row per key column, for the specified table sp_foreignkeys The foreign keys defined on the specified remote table sp_tables_ex Table information on the tables from the specified linked server sp_columns_ex The column information, for all columns or a specified column, for linked table Linked Server Information

Lesson: Working with Linked Servers Linked Server Restrictions Examples of Query Execution Pass-Through Query Execution Stored Procedure Execution Distributed Transaction Management Data Modification Best Practices

Linked Server Restrictions Referring to Objects on Linked Servers Allowed Transact-SQL Statements  SELECT, INSERT, UPDATE, DELETE Disallowed Transact-SQL Statements  CREATE, ALTER, DROP  ORDER BY on remote tables containing large objects  READTEXT, WRITETEXT, UPDATETEXT Remote Query Optimization

Examples of Query Execution Use Fully Qualified Names to Reference Objects on Linked Servers SELECT CompanyName FROM AccountingServer.NorthwindRemote.dbo.Suppliers SELECT CompanyName FROM AccountingServer.NorthwindRemote.dbo.Suppliers SELECT CompanyName, Phone INTO PhoneList FROM AccountingServer.NorthwindRemote.dbo.Suppliers SELECT CompanyName, Phone INTO PhoneList FROM AccountingServer.NorthwindRemote.dbo.Suppliers SELECT ProductName, CompanyName FROM Products p JOIN AccountingServer.NorthwindRemote.dbo.Suppliers ON p.supplierid = s.supplierid SELECT ProductName, CompanyName FROM Products p JOIN AccountingServer.NorthwindRemote.dbo.Suppliers ON p.supplierid = s.supplierid Example 1 Example 2 Example 3

Pass-Through Query Execution Use the OPENQUERY Function to Execute Pass-Through Queries on a Linked Server Use the OPENQUERY Function in a SELECT Statement in Place of a Table Name Use the Result of an OPENQUERY Function as the Target Table of an INSERT, UPDATE, or DELETE Statement SELECT * FROM OPENQUERY (AsiaServer, 'SELECT ProductID, Royalty FROM Northwind.dbo.ProductInfo')

Stored Procedure Execution User Local ServerLinked Server Stored Procedure Processing EXEC accounting.master.dbo.sp_helpntgroup Stored Procedure Call Parameters and Output

Distributed Transaction Management Managing Distributed Transactions by Using MS DTC Managing Distributed Transactions by Using Component Services

Data Modification Distribute Transactions by:  Executing BEGIN DISTRIBUTED TRANSACTION -OR-  Calling API functions from a client Consider These Facts:  BEGIN DISTRIBUTED TRANSACTION statements cannot be nested  ROLLBACK TRANSACTION rolls back entire transaction  Savepoints are not supported  Set the XACT_ABORT session option

Use Linked Servers for Frequent Remote Data Access Set Up Linked Servers to Execute Stored Procedures Remotely or to Execute Distributed Queries Restrict Access to Linked Resources Avoid Setting Up Duplicate Logon Accounts on Different Servers Use Ad Hoc Queries for Infrequent Remote Data Access Best Practices

Lesson: Using Partitioned Views Advantages of Partitioned Views Partitioned Views Implementation Steps for Partitioned Views Considerations for Partitioning Data

Advantages of Partitioned Views Scalability  Add more hardware to a single server  Divide workload and database across multiple independent computers Benefits of Partitioned Views  Results of separate tables can appear as one table  Data location is transparent to the application  Database is programmed as a single entity

Partitioned Views Member Server 2 Member Server 1 Partitioned View Table B B~~~~ ~~~~ Customer A~~~~ ~~~~ B~~~~ ~~~~ A~~~~ ~~~~ B~~~~ ~~~~ Table A A~~~~ ~~~~ CREATE VIEW Cust_View SELECT Table A UNION ALL SELECT Table B CREATE VIEW Cust_View SELECT Table A UNION ALL SELECT Table B CREATE VIEW Cust_View SELECT Table A UNION ALL SELECT Table B CREATE VIEW Cust_View SELECT Table A UNION ALL SELECT Table B

To Set Up Distributed Partitioned Views: Create multiple databases, each on a different member server 1 1 Create linked server definitions on each member server 3 3 Create a partitioned view on each member server by using the UNION ALL set operator 4 4 Horizontally partition the tables 2 2 Implementation Steps for Partitioned Views

Considerations for Partitioning Data Design Considerations  Partition data to keep related data on the same server  Minimize need to access data on other member servers  Place complete records on the same member server  Select the appropriate column to define the partition Ways to Partition Rules for Partitioning

Lab A: Using Distributed Data Exercise 1: Setting Up Linked Servers Exercise 2: Querying Remote Data If Time Permits: Managing Distributed Transactions