Module 3: Changes to Transact-SQL. Overview Accessing Object Information New Transact-SQL Syntax Changes to Objects Distributed Queries.

Slides:



Advertisements
Similar presentations
9 Creating and Managing Tables. Objectives After completing this lesson, you should be able to do the following: Describe the main database objects Create.
Advertisements

Data Definition Language (DDL)
Copyright  Oracle Corporation, All rights reserved. 10 Creating and Managing Tables.
Module 4: Creating Data Types and Tables. Overview Creating Data Types Creating Tables Generating Column Values Generating Scripts.
9 Copyright © Oracle Corporation, All rights reserved. Creating and Managing Tables.
Creating and Altering Tables cis 407 Object Names Create Statement Alter statement Drop Statement.
Chapter 5 Data Manipulation and Transaction Control Oracle 10g: SQL
Chapter 10 Overview  Implement Microsoft Windows Authentication Mode and Mixed Mode  Assign login accounts to database user accounts and roles  Assign.
DAT702.  Standard Query Language  Ability to access and manipulate databases ◦ Retrieve data ◦ Insert, delete, update records ◦ Create and set permissions.
Administration of Users Dr. Gabriel. 2 Documentation of User Administration Part of the administration process Reasons to document: –Provide a paper trail.
Module 2: Using Transact-SQL Querying Tools. Overview SQL Query Analyzer Using the Object Browser Tool in SQL Query Analyzer Using Templates in SQL Query.
© 2002 by Prentice Hall 1 David M. Kroenke Database Processing Eighth Edition Chapter 13 Managing Databases with SQL Server 2000.
IMS 4212: Application Architecture and Intro to Stored Procedures 1 Dr. Lawrence West, Management Dept., University of Central Florida
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
Module 8: Implementing Stored Procedures. Introducing Stored Procedures Creating, Modifying, Dropping, and Executing Stored Procedures Using Parameters.
Module 1: Introduction to Transact-SQL
PL/SQLPL/SQL Oracle10g Developer: PL/SQL Programming Chapter 7 PL/SQL Packages.
Module 4: Managing Security. Overview Implementing an Authentication Mode Assigning Login Accounts to Users and Roles Assigning Permissions to Users and.
Module 11: Programming Across Multiple Servers. Overview Introducing Distributed Queries Setting Up a Linked Server Environment Working with Linked Servers.
ISM 4212 Lab Creating DB Tables 02 copyright Lars Paul Linden 2007.
Chapter 2: SQL – The Basics Objectives: 1.The SQL execution environment 2.SELECT statement 3.SQL Developer & SQL*Plus.
SQL Data Definition Language (DDL) Using Microsoft SQL Server 1SDL Data Definition Language (DDL)
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.
Module 5: Upgrading to SQL Server 7.0. Overview Planning an Upgrade Preparing to Upgrade Verifying the Upgrade Setting a Compatibility Level.
10 Creating and Managing Tables Objectives At the end of this lesson, you will be able to: Describe the main database objects Create tables Describe.
1 Chapter Overview Preparing to Upgrade Performing a Version Upgrade from Microsoft SQL Server 7.0 Performing an Online Database Upgrade from SQL Server.
Oracle 11g DATABASE DEVELOPMENT LAB1. Introduction  Oracle 11g Database:-  Oracle 11g database is designed for some features, which helps to the organizations.
PRACTICE OVERVIEW PL/SQL Part Examine this package specification and body: Which statement about the V_TOTAL_BUDGET variable is true? A. It must.
Copyright  Oracle Corporation, All rights reserved. 10 Creating and Managing Tables.
Module 3: Creating Data Types and Tables. Overview Working with Data Types Working with Tables Generating Column Values Generating Scripts.
Module 4 Designing and Implementing Views. Module Overview Introduction to Views Creating and Managing Views Performance Considerations for Views.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Module 3 Designing and Implementing Tables. Module Overview Designing Tables Working with Schemas Creating and Altering Tables.
SQL Server 2005 Implementation and Maintenance Chapter 3: Tables and Views.
Visual Programing SQL Overview Section 1.
Module 11 Authorizing Users to Access Resources. Module Overview Authorizing User Access to Objects Authorizing Users to Execute Code Configuring Permissions.
9 Copyright © Oracle Corporation, All rights reserved. Creating and Managing Tables.
SQL CREATING AND MANAGING TABLES lecture4 1. Database Objects ObjectDescription TableBasic unit of storage; composed of rows and columns ViewLogically.
Chapter 5 : Integrity And Security  Domain Constraints  Referential Integrity  Security  Triggers  Authorization  Authorization in SQL  Views 
1 CS 430 Database Theory Winter 2005 Lecture 10: Introduction to SQL.
Creating and Managing Tables 14. ObjectivesObjectives After completing this lesson, you should be able to do the following: After completing this lesson,
SQL Server 2012 Session: 1 Session: 12 Triggers Data Management Using Microsoft SQL Server.
PRACTICE OVERVIEW PL/SQL Part Your stored procedure, GET_BUDGET, has a logic problem and must be modified. The script that contains the procedure.
Stored Procedures / Session 4/ 1 of 41 Session 4 Module 7: Introducing stored procedures Module 8: More about stored procedures.
DML Statements contd.. SQL Server CURSORS Cursor is used in handling results of select query for data calculations Cursors are used as buffered.
Module 8: Using Programming Objects for Data Retrieval.
Advanced Database & Client Server Introduction to MS SQL Server 2000 and Transact SQL -
Presented by Zap Riecken Using SQL Server to Query Active Directory Wednesday March 18, 2015 Olympia, WA.
Views / Session 3/ 1 of 40 Session 3 Module 5: Implementing Views Module 6: Managing Views.
Oracle9i Developer: PL/SQL Programming Chapter 6 PL/SQL Packages.
Introduction to Structured Query Language (SQL) By Techandmate.comTechandmate.com Learn SQL Server With US.
Module 1: SQL Server Overview
SQL and SQL*Plus Interaction
Module 2: Creating Data Types and Tables
SQL Creating and Managing Tables
Dynamic SQL: Writing Efficient Queries on the Fly
ORACLE SQL Developer & SQLPLUS Statements
DATABASE MANAGEMENT SYSTEM
SQL Creating and Managing Tables
Overview Implementing Triggers Implementing XML Schemas.
Chapter 8 Working with Databases and MySQL
SQL Creating and Managing Tables
Dynamic SQL: Writing Efficient Queries on the Fly
PRACTICE OVERVIEW PL/SQL Part - 1.
Using SQL*Plus.
IST 318 Database Administration
Prof. Arfaoui. COM390 Chapter 7
Dynamic SQL Konstantin Osipov, MySQL AB.
Presentation transcript:

Module 3: Changes to Transact-SQL

Overview Accessing Object Information New Transact-SQL Syntax Changes to Objects Distributed Queries

Accessing Object Information Referencing Objects Viewing Metadata

Referencing Objects Longer Object Names Fully-Qualified Object Names Bracketed Identifiers Changing Object Ownership northwind.dbo.[order details] server.database.owner.object EXEC sp_changedobjectowner 'products', 'Arturo'

Viewing Metadata Use System Stored Procedures Use Information Schema Views Use Metadata Functions SELECT * FROM information_schema.tables USE northwind IF OBJECTPROPERTY (object_id('products'), 'ISTABLE') IS NULL PRINT 'Products is not an object' USE northwind IF OBJECTPROPERTY (object_id('products'), 'ISTABLE') IS NULL PRINT 'Products is not an object'

 New Transact-SQL Syntax New Statements, Functions, and Options Changes for ANSI Compliance

New Statements, Functions, and Options SET Statements and Options SET SHOWPLAN_ALL SET SHOWPLAN_TEXT local_variable = constant SET QUERY_GOVERNOR_COST_LIMIT Functions VAR, STDEV SELECT Statement Options TOP, PERCENT, WITH TIES

Changes for ANSI Compliance ANSI Support CAST COMMIT WORK and ROLLBACK WORK PRIVILEGES Default ANSI Settings OFF for DB-Library ON for ODBC

 Changes to Objects Data Types Tables Stored Procedures Views Triggers Transact-SQL Cursors

Data Types Changes to Existing Data Types decimal and numeric char, varchar, and binary sysname text and image New Types of Data Unicode character Unicode text Global identifier Cursor

Tables Changes to ALTER TABLE Statement Can add a column with a default Can specify NOT NULL Can drop a column with ALTER TABLE New Features for Columns IDENTITY with NOT FOR REPLICATION uniqueidentifier with NEWID Computed columns ALTER TABLE mytable ADD city varchar(20) NOT NULL DEFAULT “Tokyo” ALTER TABLE mytable ADD city varchar(20) NOT NULL DEFAULT “Tokyo”

Stored Procedures Delayed Name Resolution Allows reference to objects created after stored procedure is created ALTER PROCEDURE Modifies existing stored procedure without changing permissions sp_procoption Sets and reports options that affect stored procedure execution

Views Delayed Name Resolution ALTER VIEW Maintains column permissions USE northwind GO CREATE VIEW productview AS SELECT productname FROM products GO ALTER VIEW productview AS SELECT productname FROM products WHERE categoryid = 1 GO USE northwind GO CREATE VIEW productview AS SELECT productname FROM products GO ALTER VIEW productview AS SELECT productname FROM products WHERE categoryid = 1 GO

Triggers Syntax Changes Delayed name resolution supported Prevent trigger execution for replication Can change trigger definition using ALTER TRIGGER Multiple Triggers Nested Triggers Trigger Recursion

Transact-SQL Cursors New cursor Data Type and Cursor Variables New Options for DECLARE CURSOR Statement LOCAL, GLOBAL, FORWARD_ONLY, STATIC, KEYSET, DYNAMIC, FAST_FORWARD, SCROLL_LOCKS, OPTIMISTIC, TYPE_WARNING Retrieving Information About Cursors CURSOR_STATUS Function

Upgrade Considerations for Transact-SQL Remove References to System Tables from Scripts Replace New Reserved Keywords in Scripts Specify Object Owner Name in Scripts Use Binary and Character Data Types for Data 8000 Bytes or Less Check ANSI Settings Alter Objects Rather Than Drop and Recreate Them

Lab 3.1: Changes to Transact-SQL and Objects

 Distributed Queries Linked Server Environments Setting Up a Linked Server Establishing Linked Server Security Getting Information About Linked Servers Executing Linked Server Queries Executing Ad Hoc Queries

Linked Server Environments Other Data Sources Linked SQL Server SQL Server allows access to other data sources Linked servers must be linked to the local computer running SQL Server Local SQL Server

Setting Up a Linked Server Connecting to a Remote SQL Server Connecting to an OLE DB Data Source EXEC = = 'SQL Server' EXEC = = 'SQL Server' EXEC = = = = 'OracleDB' -- 'OracleDB’ is the SQL*Net alias EXEC = = = = 'OracleDB' -- 'OracleDB’ is the SQL*Net alias

Establishing Linked Server Security EXEC = = = = 'allcustomers', EXEC = = = = 'allcustomers', Local Server Logs In to Remote Server on User’s Behalf To Establish Linked Server Security, You Can Use the same user login accounts on both servers Map login IDs between servers

Getting Information About Linked Servers sp_linkedservers sp_catalogs sp_indexes sp_primarykeys sp_foreignkeys sp_tables_ex sp_columns_ex USE master EXEC sp_indexes 'CAIRO', 'employees', 'dbo', 'northwind', NULL, 0 USE master EXEC sp_indexes 'CAIRO', 'employees', 'dbo', 'northwind', NULL, 0

Executing Linked Server Queries Using Transact-SQL Using Pass-through Queries SELECT companyname FROM AccountingServer.northwindremote.dbo.suppliers SELECT companyname FROM AccountingServer.northwindremote.dbo.suppliers SELECT * FROM OPENQUERY (AsiaServer, ' SELECT productid, FROM northwind.dbo.ProductInfo ' ) SELECT * FROM OPENQUERY (AsiaServer, ' SELECT productid, FROM northwind.dbo.ProductInfo ' )

Executing Ad Hoc Queries Use the OPENROWSET Function: To Access Remote Data Without Setting Up a Linked Server When You Do Not Expect to Use the Data Source Repeatedly 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

Lab 3.2: Distributed Queries

Review Accessing Object Information New Transact-SQL Syntax Changes to Objects Distributed Queries