Department of Computer Science University of Cyprus. EPL342 Databases. Lab 1. Introduction to SQL Server Panayiotis Andreou

Similar documents
Department of Computer Science University of Cyprus. EPL342 Databases. Lab 2

Lab 4: Tables and Constraints

Code Centric: T-SQL Programming with Stored Procedures and Triggers

Microsoft SQL Server - Concepts 2 005

How to Migrate Microsoft SQL Server Connections from the OLE DB to the ODBC Provider Type

Angela Henry. Data Types Do Matter

Basis Data Terapan. Yoannita

Constraints. Primary Key Foreign Key General table constraints Domain constraints Assertions Triggers. John Edgar 2

Information Systems Engineering. SQL Structured Query Language DDL Data Definition (sub)language

HOW TO CREATE AND MAINTAIN DATABASES AND TABLES. By S. Sabraz Nawaz Senior Lecturer in MIT FMC, SEUSL

Private Institute of Aga NETWORK DATABASE LECTURER NIYAZ M. SALIH

Course Topics. Microsoft SQL Server. Dr. Shohreh Ajoudanian. 01 Installing MSSQL Server Data types

5. SQL Query Syntax 1. Select Statement. 6. CPS: Database Schema

System Pages (Setup Admins Only)

Introduction to SQL Server 2005/2008 and Transact SQL

New Features Bulletin Replication Server Options 15.6

Exact Numeric Data Types

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

Introduction to SQL on GRAHAM ED ARMSTRONG SHARCNET AUGUST 2018

1SQL Server 2012 Architecture

Tasks for Installation / Introduction Concepts. 1. What are the Advantages of SQL Server? Data Integrity

ColumnStore Indexes UNIQUE and NOT DULL

RDBMS Basics: What Makes Up a SQL Server Database?

Oracle SQL Developer. Supplementary Information for Microsoft SQL Server and Sybase Adaptive Server Migrations Release 2.

PERSİSTENCE OBJECT RELATİON MAPPİNG

Building Better. SQL Server Databases

1RDBMS Basics: What Makes Up a SQL Server Database?

New Features Bulletin Replication Server Options

ColdFusion Summit 2016

SQL Server 2008 Tutorial 3: Database Creation

APPENDIX A Selected Tables

Database and table creation

Every Byte Counts. Why Datatype Choices Matter. Andy Yun, Database Architect/Developer

Creating Tables, Defining Constraints. Rose-Hulman Institute of Technology Curt Clifton

Mirror Replication Agent

Documentation Accessibility. Access to Oracle Support. Supported Browsers

BEAWebLogic. Integration. RDBMS Event Generator User Guide

Tables. Tables. Physical Organization: SQL Server Partitions

BaanBIS Decision Manager 2.0. Modeler User's Guide

Physical Organization: SQL Server 2005

Outsourcer Administrator Guide Document Date

Introduction to IBM DB2

Building Better. SQL Server Databases

Survey of the Azure Data Landscape. Ike Ellis

Programming and Database Fundamentals for Data Scientists

Creating and Configuring Databases

Chapter - 1 INTRODUCTION TO DATABASES

Cardholder data synchronization between an IDM system and Salto DB based on a staging table

[MS-BCP]: Bulk Copy File Format Structure Specification

Introduction to Relational Database Management Systems

TINYINT[(M)] [UNSIGNED] [ZEROFILL] A very small integer. The signed range is -128 to 127. The unsigned range is 0 to 255.

Lab # 2 Hands-On. DDL Basic SQL Statements Institute of Computer Science, University of Tartu, Estonia

Senturus Analytics Connector. User Guide Cognos to Tableau Senturus, Inc. Page 1

Senturus Analytics Connector. User Guide Cognos to Power BI Senturus, Inc. Page 1

[MS-BCP]: Bulk Copy Format. Intellectual Property Rights Notice for Open Specifications Documentation

About System Setup Pages

1. SQL Overview. Allows users to access data in the relational database management systems.

Informatica Cloud Spring Data Integration Hub Connector Guide

sqoop Automatic database import Aaron Kimball Cloudera Inc. June 18, 2009

Department of Computer Science University of Cyprus. EPL342 Databases. Lab 11 SQL-DML 4. (Stored Procedures, Cursors) Panayiotis Andreou

SharePlex for Oracle Installation and Setup Guide for a SQL Server Source

MTAT Introduction to Databases

Installation and Configuration Guide

This lab will introduce you to MySQL. Begin by logging into the class web server via SSH Secure Shell Client

Database Driver Sybase CT Library. Release 4.25

Get Table Schema In Sql Server 2005 Modify. Column Datatype >>>CLICK HERE<<<

IBM DB2 UDB V7.1 Family Fundamentals.

Basic SQL. Basic SQL. Basic SQL

Lab 6 SQL-DDL Advanced in SQL Server 2008

EGCI 321: Database Systems. Dr. Tanasanee Phienthrakul

SQL. Often times, in order for us to build the most functional website we can, we depend on a database to store information.

SYBASE Chapter,First Edition

SQL Data Definition and Data Manipulation Languages (DDL and DML)

Installation and Configuration Guide

ICM DBLookup Function Configuration Example

About the Tutorial. Audience. Prerequisites. Compile/Execute SQL Programs. Copyright & Disclaimer SQL

SharePlex for Oracle Installation and Setup Guide for a SQL Server Source

Chapter 3 Introduction to relational databases and MySQL

sqoop Easy, parallel database import/export Aaron Kimball Cloudera Inc. June 8, 2010

Oracle TimesTen In-Memory Database SQL Reference Guide Release 7.0 B

12 Rules Defined by Dr.Codd for a Relational Database Management System

Using IBM-Informix datatypes with IDS 10 and web application server Keshava Murthy, IBM Informix Development

Database Management Systems,

Chapter 8 How to work with data types

Oracle TimesTen In-Memory Database SQL Reference Guide Release 7.0 B

Strings Dates and DateTimes Identifiers

COPYRIGHTED MATERIAL. Introducing Transact-SQL and Data Management Systems. Transact-Structured Query Language

Full file at

Tranquility Publications. Web Edition MAC

Index. Special Characters # prefix, temporary tables, 362 $IDENTITY option in SELECT statement, 267 $ROWGUID option in SELECT statement, 267

Activant Solutions Inc. SQL Server 2005: Data Storage

Lab # 4. Data Definition Language (DDL)

Database Migration with MySQL Workbench. Alfredo Kojima, Team Lead MySQL Workbench Mike Frank, Product Manager

Lab # 2. Data Definition Language (DDL) Eng. Alaa O Shama

MTAT Introduction to Databases

Data Types in MySQL CSCU9Q5. MySQL. Data Types. Consequences of Data Types. Common Data Types. Storage size Character String Date and Time.

About the Tutorial. Audience. Prerequisites. Compile/Execute SQL Programs. Copyright & Disclaimer SQL

SQL Server 2016 installation/setup instructions

Microsoft SQL Server (Spatial) Reader/Writer

GridDB Advanced Edition SQL reference

Transcription:

Department of Computer Science University of Cyprus EPL342 Databases Lab 1 Introduction to SQL Server 2008 Panayiotis Andreou http://www.cs.ucy.ac.cy/courses/epl342 1-1

Before We Begin Start the SQL Server Management Studio Start All Programs Microsoft SQL Server SQL Server Management Studio Server: APOLLO.IN.CS.UCY.AC.CY Authentication: SQL Server Authentication Username: <check your email> Password: <check your email> 1-2

What is SQL Server? Relational Model Database Server Manages two types of databases Online Transaction Processing (OLTP) databases Online Analytical Processing (OLAP) Primary Languages: T-SQL, ANSI-SQL 1-3

A brief history of SQL Server Year Version Name 1989 1 SQL Server 1.0 1993 4.21 SQL Server 4.21 1995 6 SQL Server 6 1996 6.5 SQL Server 6.5 (Hydra) 1998 7 SQL Server 7 (Sphinx) 1999 7 SQL Server 7 OLAP (Plato) 2000 8 SQL Server 2000 (Shiloh) 2003 8 SQL Server 2000 64-bit (Liberty) 2005 9 SQL Server 2005 (Yukon) 2008 10 SQL Server 2008 (Katmai) 1-4

Useful Links SQL Server 2008 Home http://www.microsoft.com/sqlserver/2008/en/us/default.aspx SQL Server 2008 Learning Resources http://www.microsoft.com/sqlserver/2008/en/us/learningresources.aspx Download SQL Server 2008 Express Edition http://www.microsoft.com/express/database/ 1-5

Communicating with SQL Server Client SQL Server Query Results Client application Relational Database Management System 1-6

Communicating with SQL Server Client Client Application Database API (Native, OLEDB, ODBC, Other) Communication Communication Open Data Services Relational Engine Storage Service Processor Memory SQL Server 1-7

Authentication SQL Server 2008 supports two types of authentication: Windows Authentication SQL Server Authentication 1-8

Logging-in to SQL Server Server Address Instance Name Server Name You can have multiple server instances installed on the same PC Connecting to UCY SQL Server is installed on APOLLO. Username and password will be send to your email Authentication Type Two authentication types: Windows authentication Logs in with the Windows credentials SQL Server authentication Requires SQL Server user/pass 1-9

Logging-in to SQL Server Connection Specifics Port Configuration: SQL Server uses dynamic port configuration. To check the port number go to SQL Server Configuration Manager SQL Server 2008 Network Configuration Protocols for SQL Express TCP/IP IP Adresses IP All TCP Dynamic Ports: (e.g., 52468) Remote TCP/IP connections: by default disabled Local connection: When connecting locally on your PC you can use (local) for Server Address Connecting from home: only through VPN (Good luck with that!) 1-10

Object Explorer Object Explorer A component that provides a view of all objects in the services and presents a user interface to manage them. 1-11

Databases Two types of Databases System Databases: master msdb model Resource tempdb Records all the system-level information for an instance of SQL Server. Is used by SQL Server Agent for scheduling alerts and jobs. Is used as the template for all databases created on the instance of SQL Server. Is a read-only database that contains system objects that are included with SQL Server. Is a workspace for holding temporary objects or intermediate result sets. User Databases 1-12

Creating a database Database Consists of two files: <name>.mdf Data file: stores all data <name>_log.ldf Log file: stores all actions performed on database 1-13

Inside a database (AdventureWorks) Database Diagrams design and visualize a database Tables System table + user tables Views, Synonyms, Programmability, Security Will talk about them in upcoming lectures 1-14

Database Diagram Available here in html and visio formats 1-15

Tables System Tables The information used by SQL Server and its components is stored in special tables known as system tables. User Tables Tables created by the user 1-16

Table Data To view table data right-click on a table and select open table (e.g., Person.Address) 1-17

Table Information Columns Data stored on the table, e.g., Firstname, Lastname, Address Keys Special columns e.g., columns with unique values (PersonID) Constraints Rules applied to the table, e.g., PersonID must be unique Indexes, Statistics Will talk about them in upcoming lectures 1-18

Table - Columns Primary Key Value that uniquely identifies each row of the table Foreign Key The primary key of another table Column Name Data Type Allow Nulls 1-19

SQL Server 2008 Data Types Exact Numerics Integers bigint Integer (whole number) data from -2^63 (- 9,223,372,036,854,775,808) through 2^63-1 (9,223,372,036,854,775,807). int Integer (whole number) data from -2^31 (- 2,147,483,648) through 2^31-1 (2,147,483,647). smallint Integer data from -2^15 (-32,768) through 2^15-1 (32,767). tinyint Integer data from 0 through 255. bit bit Integer data with either a 1 or 0 value. decimal and numeric decimal Fixed precision and scale numeric data from - 10^38 +1 through 10^38 1. numeric Functionally equivalent to decimal. money and smallmoney money Monetary data values from -2^63 (- 922,337,203,685,477.5808) through 2^63-1 (+922,337,203,685,477.5807), with accuracy to a ten-thousandth of a monetary unit. smallmoney Monetary data values from -214,748.3648 through +214,748.3647, with accuracy to a ten-thousandth of a monetary unit. 1-20

SQL Server 2008 Data Types Approximate Numerics float Floating precision number data with the following valid values: -1.79E + 308 through - 2.23E - 308, 0 and 2.23E + 308 through 1.79E + 308. real Floating precision number data with the following valid values: -3.40E + 38 through - 1.18E - 38, 0 and 1.18E - 38 through 3.40E + 38. datetime and smalldatetime datetime Date and time data from January 1, 1753, through December 31, 9999, with an accuracy of three-hundredths of a second, or 3.33 milliseconds. smalldatetime Date and time data from January 1, 1900, through June 6, 2079, with an accuracy of one minute. 1-21

SQL Server 2008 Data Types Character Strings char Fixed-length non-unicode character data with a maximum length of 8,000 characters. varchar Variable-length non-unicode data with a maximum of 8,000 characters. text Variable-length non-unicode data with a maximum length of 2^31-1 (2,147,483,647) characters. Unicode Character Strings nchar Fixed-length Unicode data with a maximum length of 4,000 characters. nvarchar Variable-length Unicode data with a maximum length of 4,000 characters. sysname is a system-supplied user-defined data type that is functionally equivalent to nvarchar(128) and is used to reference database object names. ntext Variable-length Unicode data with a maximum length of 2^30-1 (1,073,741,823) characters. 1-22

SQL Server 2008 Data Types Binary Strings binary Fixed-length binary data with a maximum length of 8,000 bytes. varbinary Variable-length binary data with a maximum length of 8,000 bytes. image Variable-length binary data with a maximum length of 2^31-1 (2,147,483,647) bytes. Other Data Types cursor A reference to a cursor. sql_variant A data type that stores values of various SQL Server-supported data types, except text, ntext, timestamp, and sql_variant. table A special data type used to store a result set for later processing. timestamp A database-wide unique number that gets updated every time a row gets updated. uniqueidentifier A globally unique identifier (GUID). 1-23

Command prompt access SQL Server 2008 support command-line access to databases with SQLCMD.exe Login with sqlcmd -U someuser -P s0mep@ssword Execute queries: sqlcmd -d AdventureWorks -q "SELECT FirstName, LastName FROM Person.Contact sqlcmd -d AdventureWorks -q "SELECT TOP 5 FirstName FROM Person.Contact;SELECT TOP 5 LastName FROM Person.Contact;" More info @ http://msdn.microsoft.com/enus/library/ms162773.aspx 1-24

Other Information Have you send your lab group details? 1-25