SQL Server Administration Class 4 of 4. Activant Prophet 21. Basic Data Manipulation

Similar documents
Activant Solutions Inc. SQL 2005: Basic Data Manipulation

Activant Prophet 21. Understanding Prophet 21 Databases

Understanding Prophet 21 Databases

CSC Web Programming. Introduction to SQL

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 7 Introduction to Structured Query Language (SQL)

Prophet 21 World Wide User Group Webinars. Barry Hallman. SQL Queries & Views. (Basic Skill Level)

SQL functions fit into two broad categories: Data definition language Data manipulation language

Relational Database Management Systems for Epidemiologists: SQL Part I

Exact Numeric Data Types

Chapter-14 SQL COMMANDS

Chapter # 7 Introduction to Structured Query Language (SQL) Part II

1) Introduction to SQL

Unit Assessment Guide

T-SQL Training: T-SQL for SQL Server for Developers

Advanced SQL Tribal Data Workshop Joe Nowinski

Querying Data with Transact SQL

Chapter 7. Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel

Data Manipulation Language (DML)

SIT772 Database and Information Retrieval WEEK 6. RELATIONAL ALGEBRAS. The foundation of good database design

BEGINNING T-SQL. Jen McCown MidnightSQL Consulting, LLC MinionWare, LLC

Querying Data with Transact SQL Microsoft Official Curriculum (MOC 20761)

INDEX. 1 Basic SQL Statements. 2 Restricting and Sorting Data. 3 Single Row Functions. 4 Displaying data from multiple tables

Introduction to SQL. IT 5101 Introduction to Database Systems. J.G. Zheng Fall 2011

618 Index. BIT data type, 108, 109 BIT_LENGTH, 595f BIT VARYING data type, 108 BLOB data type, 108 Boolean data type, 109

Introduction. Sample Database SQL-92. Sample Data. Sample Data. Chapter 6 Introduction to Structured Query Language (SQL)

tablename ORDER BY column ASC tablename ORDER BY column DESC sortingorder, } The WHERE and ORDER BY clauses can be combined in one

30. Structured Query Language (SQL)

Microsoft Office Illustrated Introductory, Building and Using Queries

Relational Database Management Systems for Epidemiologists: SQL Part II

Microsoft Access Illustrated. Unit B: Building and Using Queries

MTA Database Administrator Fundamentals Course

Appendix A. Using DML to Modify Data. Contents: Lesson 1: Adding Data to Tables A-3. Lesson 2: Modifying and Removing Data A-8

Activant Prophet 21. Using Fast Edits on Your Database

HKTA TANG HIN MEMORIAL SECONDARY SCHOOL SECONDARY 3 COMPUTER LITERACY. Name: ( ) Class: Date: Databases and Microsoft Access

Index. Bitmap Heap Scan, 156 Bitmap Index Scan, 156. Rahul Batra 2018 R. Batra, SQL Primer,

AVANTUS TRAINING PTE LTD

This course is aimed at those who need to extract information from a relational database system.

Querying Data with Transact-SQL

Jarek Szlichta

Lesson 2. Data Manipulation Language

CST272 SQL Server, SQL and the SqlDataSource Page 1

Announcements (September 14) SQL: Part I SQL. Creating and dropping tables. Basic queries: SFW statement. Example: reading a table

20461: Querying Microsoft SQL Server 2014 Databases

COURSE OUTLINE: Querying Microsoft SQL Server

20461D: Querying Microsoft SQL Server

Querying Microsoft SQL Server 2008/2012

Oracle Database 11g: SQL and PL/SQL Fundamentals

Introduction to SQL. From Rob and Coronel (2004), Database Systems: Design, Implementation, and Management

SQL Fundamentals. Chapter 3. Class 03: SQL Fundamentals 1

Relational Database Language

DS Introduction to SQL Part 1 Single-Table Queries. By Michael Hahsler based on slides for CS145 Introduction to Databases (Stanford)

20761C: Querying Data with Transact-SQL

SQL Queries. for. Mere Mortals. Third Edition. A Hands-On Guide to Data Manipulation in SQL. John L. Viescas Michael J. Hernandez

How to use SQL to work with a MySQL database

Activant Prophet 21 SQL Server Data Storage. SQL Server Administration suite: course 2 of 4

Course Modules for MCSA: SQL Server 2016 Database Development Training & Certification Course:

Test Bank for Database Processing Fundamentals Design and Implementation 13th Edition by Kroenke

Sql Server Syllabus. Overview

SELECT Product.name, Purchase.store FROM Product JOIN Purchase ON Product.name = Purchase.prodName

20461: Querying Microsoft SQL Server

Full file at

Exam #1 Review. Zuyin (Alvin) Zheng

Unit 1 - Chapter 4,5

Querying Microsoft SQL Server (MOC 20461C)

Oracle Database: SQL and PL/SQL Fundamentals NEW

SQL Joins and SQL Views

Teradata SQL Features Overview Version

Implementing Table Operations Using Structured Query Language (SQL) Using Multiple Operations. SQL: Structured Query Language

Oracle Database: SQL and PL/SQL Fundamentals Ed 2

Concepts of Database Management Eighth Edition. Chapter 2 The Relational Model 1: Introduction, QBE, and Relational Algebra

COURSE OUTLINE MOC 20461: QUERYING MICROSOFT SQL SERVER 2014

Introduction to SQL 2000: Installation and Implementation. SQL Server Administration suite: course 1 of 4

Course Outline. Querying Data with Transact-SQL Course 20761B: 5 days Instructor Led

COPYRIGHTED MATERIAL. Contents. Chapter 1: Introducing T-SQL and Data Management Systems 1. Chapter 2: SQL Server Fundamentals 23.

STOP DROWNING IN DATA. START MAKING SENSE! An Introduction To SQLite Databases. (Data for this tutorial at

Querying Data with Transact-SQL

Querying Microsoft SQL Server

Querying Microsoft SQL Server

Based on the following Table(s), Write down the queries as indicated: 1. Write an SQL query to insert a new row in table Dept with values: 4, Prog, MO

Querying Microsoft SQL Server

20761B: QUERYING DATA WITH TRANSACT-SQL

SQL. SQL Functions. SQL Aggregate Functions. SQL Scalar functions. SQL Aggregate Functions. The AVG() Function

ASSIGNMENT NO Computer System with Open Source Operating System. 2. Mysql

CSE 344 Introduction to Data Management. Section 2: More SQL

Structured Query Language: Introduction

SQL - Subqueries and. Schema. Chapter 3.4 V4.0. Napier University

20761 Querying Data with Transact SQL

Types. Inner join ( Equi Joins ) Outer(left, right, full) Cross. Prepared By : - Chintan Shah & Pankti Dharwa 2

Chapter 3. Introduction to relational databases and MySQL. 2010, Mike Murach & Associates, Inc. Murach's PHP and MySQL, C3

Querying Data with Transact-SQL

Language. f SQL. Larry Rockoff COURSE TECHNOLOGY. Kingdom United States. Course Technology PTR. A part ofcenqaqe Learninq

Database Management Systems by Hanh Pham GOALS

Microsoft Querying Microsoft SQL Server 2014

Querying Microsoft SQL Server

Querying Data with Transact-SQL

HPCC JDBC Driver. Boca Raton Documentation Team

CSCI-UA: Database Design & Web Implementation. Professor Evan Sandhaus Lecture #17: MySQL Gets Done

QUERYING MICROSOFT SQL SERVER COURSE OUTLINE. Course: 20461C; Duration: 5 Days; Instructor-led

Prophet 21 World Wide User Group Webinars. Barry Hallman. SQL Queries & Views. (Part 2)

Using SQL with SQL Developer Part I

Transcription:

SQL Server Administration Class 4 of 4 Activant Prophet 21 Basic Data Manipulation

This class is designed for Beginner SQL/Prophet21 users who are responsible for SQL Administration as it relates to Prophet 21

Objectives System stored procedures System functions SQL statements Retrieving data through the SELECT statement Inserting data through the INSERT statement Updating data through the UPDATE statement

This course will NOT cover Windows Navigation Installation of SQL Server SQL Server Data Storage Performance Tuning

Using System Stored Procedures System stored procedure overview Common system stored procedures Using system stored procedures to retrieve information

System Stored Procedure Compiled set of Transact-SQL statements used for data retrieval or manipulation The name of the procedure usually begins with sp You can run them from any database using the EXEC statement in a query window They are useful for retrieving information about objects in the database

Common System Stored Procedures Syntax Sp_help {object name} Sp_helptext {object_name} Result List of all objects in the current database with their object types Actual Transact-SQL code that is executed when a stored proc,trigger or view is run

Using System Stored Procedures to Retrieve Information Command EXEC sp_help oe_line EXEC sp_help EXEC sp_helptext myproc Results stored procedure information about the table called oe_line list of all the objects in the current database code that is in a stored procedure called myproc

Understanding System Functions System function overview System functions vs. system stored procedures

System Function Compiled procedures provided by SQL Server to perform complex mathematical calculations, or to manipulate data Rowset Functions Aggregate Functions Scalar Functions

Aggregate Functions SUM AVG MIN MAX COUNT Sums a column of values and returns the result Averages a set of values and returns the results Returns the minimum value from a list of values Returns the maximum value from a list of values Return the count of values in a list

Aggregate Functions To return the average value of the extended price column in the oe_line table SELECT AVG(extended_price) FROM oe_line To return the number of invoices in the inv_hdr table which have an invoice_amount above $1000.00 SELECT count(invoice_no) FROM invoice_hdr WHERE total_amount > 1000

Scalar Functions Getdate() Substring Convert Returns the current system date Used to take only a certain part of a longer string Used to convert data from one data type to another SELECT substring(customer_name, 1, 5) FROM customer

System Functions vs. System Stored Procedures A system function is a compiled function Resides in the SQL Server program itself Does not reside in any database but rather in the shared dynamic link library files that are installed with SQL Server Used in queries to: retrieve summary data from a list of values, perform complex mathematics, or convert data

System Functions vs. System Stored Procedures A system stored procedure is a collection of Transact-SQL statements Returns information about database objects or the current environment Reside in the master database and be used in any database on the server The most common system stored procedures are sp_help and sp_helptext

SELECT Statement Overview Choosing columns Choosing rows Sorting results Grouping Results Implementing Joins

Basic Syntax SELECT column_list Column_list is a commaseparated list of the columns you want in your result set FROM table WHERE where_clause Table which the columns in the select list or the where clause reside. Additional tables can be joined to the FROM Where_clause specifies the criteria for the rows you want to see

Choosing Columns SELECT * FROM oe_hdr SELECT order_no, ship2_name FROM oe_hdr SELECT order_no, 'My Literal', ship2_name FROM oe_hdr SELECT 'Order Number' = order_no, 'Ship To Name' = ship2_name FROM oe_hdr

Choosing Rows Comparison Operators Ranges Lists String Matches =, >, <, >=, <=, <>,!=,!<,!> BETWEEN, NOT BETWEEN IN, NOT IN LIKE, NOT LIKE Unknown Values IS NULL, IS NOT NULL Combinations Negations AND, OR NOT

Choosing Rows SELECT * from oe_hdr where order_no = 10000 SELECT * from oe_hdr where ship2_add1 = 1234 Any Street Put a single quote mark around all literal constants for the columns of char, varchar, text, datetime, and smalldatetime data types

Choosing Rows SELECT * from oe_hdr where order_no in (100000, 100010, 100020) SELECT * from oe_hdr where ship2_add1 LIKE '1234 Market%'

Wildcards % Any string of zero or more characters _ Any single character [] Any single character within a range/set [^] Single character not with a range or set

Wildcards SELECT * from oe_hdr where ship2_add1 LIKE '%Ave% SELECT * from oe_hdr where order_no in (100000, 100005, 100006) OR ship2_add1 IS NULL

Sorting Results ORDER BY clause sorts the results of your query in a specified order SELECT * from oe_hdr where order_no > 150000 ORDER BY ship2_name SELECT * from oe_hdr where order_no > 150000 ORDER BY ship2_name DESC

Grouping Results Commonly used in conjunction with aggregate functions to produce summary data SELECT order_no, AVG(extended_price) from oe_line GROUP BY order_no SELECT order_no, SUM(qty_ordered) from oe_line GROUP BY order_no

HAVING SELECT order_no, AVG(extended_price) FROM oe_line GROUP BY order_no HAVING AVG(extended_price) >= 70

Implementing Joins In a relational database environment, the information you need often resides in more than one table In order to retrieve this data, you must join to tables

Joins INNER JOIN CROSS JOIN OUTER JOIN Includes only rows that satisfy the join condition Includes every combination of all of the rows between the two tables Includes the rows that satisfy the join condition, plus the remaining rows in one of the tables

Joins SELECT column_list FROM table join_operator ON table_name.column_name = table_name.column_name WHERE table_name.column_name

Allowed Join Operators = Equal to > Greater than < Less than >= Greater or equal to <= Less or equal to <> Not equal to

Inner Joins Connect two tables to create a third table that includes only the rows satisfying the join condition

INNER JOIN Example SELECT oe_hdr.customer_id, oe_line.qty_invoiced, oe_line.commission_cost FROM oe_hdr INNER JOIN oe_line ON oe_hdr.order_no = oe_line.order_no WHERE oe_hdr.customer_id = 100000

Cross Joins Result set containing all the combinations of the rows between tables in the join 5 rows, 9 cols = 45 rows in result set Cross Join Example SELECT customer_id, qty_invoiced FROM oe_hdr CROSS JOIN oe_line

Outer Joins - ANSI Left Outer Join Right Outer Join Full Outer Join Includes all rows from the table on the left, while only including related records from the table on the right Includes all rows from the table on the right, while only including related records from the table on the left Includes all non-matching rows for both the left side table and the right side table

Outer Joins SELECT inv_mast.item_id, sum(oe_line.qty_ordered) FROM inv_mast LEFT OUTER JOIN oe_line ON inv_mast.inv_mast_uid = oe_line.inv_mast_uid GROUP BY inv_mast.item_id

Outer Joins Outer joins include all rows in the outer table and only those related rows from the inner table Outer joins can be done between only two tables

INSERT Statement Overview Basic syntax Inserting rows with SELECT

INSERT Statement Data modification statement that inserts rows into a table while still observing constraints on the columns of the table Basic Syntax INSERT INTO table_name (column_list) VALUES (value_list)

INSERT statement INSERT INTO oe_hdr (order_id, customer_id, ship_to_address) VALUES ( 100050, 107543, 1234 Any Street)

Inserting with SELECT Insert more than one row at a time into a table SELECT * INTO oe_line_copy FROM oe_line (table does not exist) INSERT INTO oe_line_copy SELECT * FROM oe_line (table already exists)

UPDATE Statement Overview Basic Syntax Updating data based on other tables

UPDATE Statement Updates data that already exists in tables Observes column and table constraints that reside on the table UPDATE table SET Specifies the columns and the new values WHERE Specifies the exact rows to update

UPDATE syntax UPDATE table_name SET column_name = expression, column_name2 = expression WHERE where_clause

UPDATE statement UPDATE inv_mast SET price1 = price1 + (price1 *.10) UPDATE inv_mast SET description = Discontinued Item WHERE inactive = Y

Summary System stored procedures System functions Select statements SELECT statement INSERT statement UPDATE statement

Visit Activant on the web: distribution.activant.com View Educational Services training course offerings Microsoft SQL Server: three-day classroom training Browse Documentation Search the Solutions database Submit a web case Email Professional Services Sales: pss@activant.com