Creating and Populating a MS SQLServer Database Presented By: Dr. Adam P. Anthony.

Slides:



Advertisements
Similar presentations
Stored procedures and views You can see definitions for stored procedures and views in the demo databases but you can’t change them. For views, expand.
Advertisements

Introduction to ETL Using Microsoft Tools By Dr. Gabriel.
Overview Begin 6:00 Quiz15 mins6:15 Review Table Terms25 mins6:40 Short Break10 mins6:50 SQL: Creating Tables60 mins7:50 Break10 mins8:00 Lab – Creating.
Day 3 - Basics of MySQL What is MySQL What is MySQL How to make basic tables How to make basic tables Simple MySQL commands. Simple MySQL commands.
Action Queries CS 320. Review: SQL Command Types  Data Definition Language (DDL)  Used to create and modify database objects  Data Manipulation Language.
Let’s try Oracle. Accessing Oracle The Oracle system, like the SQL Server system, is client / server. For SQL Server, –the client is the Query Analyser.
SQL components In Oracle. SQL in Oracle SQL is made up of 4 components: –DDL Data Definition Language CREATE, ALTER, DROP, TRUNCATE. Creates / Alters.
The Use of Microsoft based Technologies for the benefit of the Community Prof. Avi Mendelson – Microsoft & Technion - Taub 643.
Overview Relational Databases and SQL Pertemuan 1 Matakuliah: T0413/Current Popular IT II Tahun: 2007.
Creating Database Tables © Abdou Illia MIS Spring /21/2015.
Murali Mani SQL DDL and Oracle utilities. Murali Mani Datatypes in SQL INT (or) INTEGER FLOAT (or) REAL DECIMAL (n, m) CHAR (n) VARCHAR (n) DATE, TIME.
DT211 Stage 2 Databases Lab 1. Get to know SQL Server SQL server has 2 parts: –A client, running on your machine, in the lab. You access the database.
A Guide to MySQL 3. 2 Objectives Start MySQL and learn how to use the MySQL Reference Manual Create a database Change (activate) a database Create tables.
1 Nassau Community CollegeProf. Vincent Costa Acknowledgements: Introduction to Database Management, All Rights ReservedIntroduction to Database Management.
DAT702.  Standard Query Language  Ability to access and manipulate databases ◦ Retrieve data ◦ Insert, delete, update records ◦ Create and set permissions.
Using ER/Studio.
DAY 21: MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Akhila Kondai October 30, 2013.
Oracle Data Definition Language (DDL)
Advance Computer Programming Java Database Connectivity (JDBC) – In order to connect a Java application to a database, you need to use a JDBC driver. –
1 Working with MS SQL Server. 2 Objectives You will be able to Use Visual Studio for GUI based interactive access to a Microsoft SQL Server database.
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
SQL Maestro Hello World IQ Associates. Contents Initial setup Hello World.
IE 423 – Design of Decision Support Systems Database development – Relationships and Queries Introduction to SQL.
ASP.NET Programming with C# and SQL Server First Edition
Copyright © 2003 Pearson Education, Inc. Slide 8-1 The Web Wizard’s Guide to PHP by David Lash.
 SQL stands for Structured Query Language.  SQL lets you access and manipulate databases.  SQL is an ANSI (American National Standards Institute) standard.
Databases in Visual Studio. Database in VisualStudio An MS SQL database are built in Visual studio The Name can be something like ”(localdb)\Projects”
1 Working with MS SQL Server Textbook Chapter 14.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 Working with MSSQL Server Code:G0-C# Version: 1.0 Author: Pham Trung Hai CTD.
Database Fred Durao What is a database? A database is any organized collection of data. Some examples of databases you may encounter in.
ISM 4212 Lab Creating DB Tables 02 copyright Lars Paul Linden 2007.
SQL Data Definition Language (DDL) Using Microsoft SQL Server 1SDL Data Definition Language (DDL)
CIS 338: Using Queries in Access as a RecordSource Dr. Ralph D. Westfall May, 2011.
Present :Arezoo Mollahasani. Step 1  Define your server connection Open MySQL WorkBench and click New Server Instance on the right of the window.
SQL: DDL. SQL Statements DDL - data definition language –Defining and modifying data structures (metadata): database, tables, views, etc. DML - data manipulation.
A Guide to MySQL 3. 2 Introduction  Structured Query Language (SQL): Popular and widely used language for retrieving and manipulating database data Developed.
Information Building and Retrieval Using MySQL Track 3 : Basic Course in Database.
SQL Basics. What is SQL? SQL stands for Structured Query Language. SQL lets you access and manipulate databases.
SQL introduction 2013.
Presentation On How To Create Connection To A Database.
Creating a simple database This shows you how to set up a database using PHPMyAdmin (installed with WAMP)
IMS 4212 Lab: Lab Introduction 1 Dr. Lawrence West, MIS Dept., University of Central Florida Subject—Topics Installing.
There are two types of MySQL instructions (Data Definition Language) DDL: Create database, create table, alter table,,,. (Data Manipulation Language) DML.
Distribution of Marks For Second Semester Internal Sessional Evaluation External Evaluation Assignment /Project QuizzesClass Attendance Mid-Term Test Total.
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.
Chapter 3: Relational Databases
Intro To Oracle :part 1 1.Save your Memory Usage & Performance. 2.Oracle Login ways. 3.Adding Database to DB Trees. 4.How to Create your own user(schema).
1 A Very Brief Introduction to Relational Databases.
CSCI 3327 Visual Basic Chapter 13: Databases and LINQ UTPA – Fall 2011.
1 Working with MS SQL Server Beginning ASP.NET in C# and VB Chapter 12.
SQL Server Microsoft SQL Server 6.5 (startup menu) We’ll use two facilities –Enterprise Manager: to build your db –ISQL_w: to run queries Use this for.
Installation Oracle 11g Express 2 double click the "setup" button to install the Oracle.
MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Sravanthi Lakkimsety Mar 14,2016.
Log Shipping, Mirroring, Replication and Clustering Which should I use? That depends on a few questions we must ask the user. We will go over these questions.
3 A Guide to MySQL.
Aga Private computer Institute Prepared by: Srwa Mohammad
Creating Data Base & Sql Data Source
Visual Basic 2010 How to Program
Managing Tables, Data Integrity, Constraints by Adrienne Watt
SQL and SQL*Plus Interaction
Part 1 of 2 Creating SQL Database and Binding to GridView
ORACLE SQL Developer & SQLPLUS Statements
Downloading and Installing SQLExpress
CS1222 Using Relational Databases and SQL
Session - 6 Sequence - 1 SQL: The Structured Query Language:
Creating Data Base & Sql Data Source
SQL-Data Definition 4/21/2019.
Structured Query Language Path from Unorganized to Organized….
SQL (Structured Query Language)
Presentation transcript:

Creating and Populating a MS SQLServer Database Presented By: Dr. Adam P. Anthony

Prerequisites 1.Basic knowledge of SQL DDL (data definition language) 2.Basic knowledge of SQL DML (data manipulation language) 3.Standard professional installation of Visual Studio (incl. MS SQLServer 2005 Express)

Getting Started Ways to access SQLServer on a local machine: – Command line tool (SQLCMD) – SQLServer Management Studio Express – Running Scripts in Visual Studio Running remotely: – Not covered in this class – Depends on server configuration (ask sysadmin) – Once connected, there is no difference, functionally, from working on a local instance

SQLExpress Command Line Start  Run… – SQLCMD -S localhost\SQLExpress Load your database first: – use Type your commands at the prompt: 1> SELECT * FROM Student You can break up lines, without any trouble: 1> Select * 2> FROM STUDENT Cycle through previously typed commands using the arrow keys

The GO Command Type as much SQL as you want. Nothing will happen until you type GO Also usable in SQL scripts: – Less useful (not needed to allow line breaks) – Reports “number of rows affected” after each GO statement

Visual Studio SQL Projects Many choices, make sure you get the right one! – File  New  Project – Expand the ‘Other Project Types’ option, pick ‘Database Project’ First window: Add a database reference (OR choose data source) – “Add New Reference” Next window: New database reference – Server name: localhost\SQLExpress – Select or enter a database name: either pick an existing, or type in a new, name for DB you want to create – If you are just practicing/doing homework and don’t want the data to persist, use tempdb CAUTION: tempdb is erased when you end your session!

VS Database Project Window Three folders categorize SQL scripts: – Create (creating databases, tables) – Change (loading data, changing structures) – Queries (everything else!) To get started: – Right click on Create Scripts and choose “Add SQL Script” Create Tables.sql sounds like a good file name – DO NOT ADD A QUERY!! OK, you can add one if you want to but I’m not going to teach you how to use it. When the script is finished, right click on the file, and chose ‘run’

Writing Code (Finally!) For This Class Scripts vs. Command line: – Use command line to practice/test features you don’t understand – Use scripts to do your homework (e.g. I’ll expect.sql files) In scripts: – Type your SQL just as you see it in the book – Indentation, line breaks are your friend! – Use a double dash (--) to leave an inline comment – Comments are Required!

SQLServer 2005 Data Types Frequently-used types: int, float, numeric, datetime, varchar Some types have only subtle differences: char  max size = 8000 varchar  max size = 2 32 numeric == decimal float == real Numeric vs. float: Numeric uses soft representation, float uses IEEE hardware representation More info on types:

Creating an Entity Table Subtle difference: no colon between column name, type Primary key, foreign key syntax is same as SQL standard Naming constraints: – Sometimes SQLServer requires you to drop constraints, and to do that you need to know the name CREATE TABLE student( snum numeric(9), sname varchar(30), major varchar(25), standing varchar(2), age numeric(3), CONSTRAINT student_pk PRIMARY KEY (snum) ); GO

Inserting Data Standard notation for a single insert: INSERT INTO student (snum,sname,age) VALUES ( ,"default student",18) For more efficient bulk-inserts from a text file: BULK INSERT student FROM –- must be full path 'C:\bookTableScripts\student.txt' -- what separates the value of each field? WITH (FIELDTERMINATOR = ',')

Additional Resources SQL in a nutshell: de=ohlink&xmlId= de=ohlink&xmlId= Learning SQL on SQL Server 2005: de=ohlink&xmlId= de=ohlink&xmlId= MSDN SQL Server 2005 Reference: us/library/ms130214%28SQL.90%29.aspx us/library/ms130214%28SQL.90%29.aspx

Practice Session Student snum Numeric(9) sname Varchar(30) major Varchar(30) standing Varchar(2) age int Faculty fid Numeric(9) fname Varchar(30) deptid Varchar(4) Class fid Numeric(9) name Varchar(40) meets_at Varchar(20) room Varchar(10) Teaches Enrolled