1 SQL Server Management Studio SQL DDL CREATE TABLE Constraints ALTER TABLE DROP TABLE The GUI way Steen Jensen, autumn 2013.

Slides:



Advertisements
Similar presentations
Data Definition Language (DDL)
Advertisements

Relational Database. Relational database: a set of relations Relation: made up of 2 parts: − Schema : specifies the name of relations, plus name and type.
Virtual training week 4 structured query language (SQL)
Introduction to Structured Query Language (SQL)
STRUCTURED QUERY LANGUAGE SQL Fact of the Week: According to the 2010 outlook from the BLS 286,600 new Computer, Network, and Database administrator jobs.
Introduction to Structured Query Language (SQL)
SQL components In Oracle. SQL in Oracle SQL is made up of 4 components: –DDL Data Definition Language CREATE, ALTER, DROP, TRUNCATE. Creates / Alters.
System Administration Accounts privileges, users and roles
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.
Introduction to Structured Query Language (SQL)
SQL DDL constraints Restrictions on the columns and tables 1SQL DDL Constraints.
Working with SQL and PL/SQL/ Session 1 / 1 of 27 SQL Server Architecture.
Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium SQL Fundamentals Introduction.
Your Oracle Account UserName is the same as your UWP username Followed Not case sensitive Initial Password: UWPstudent Password is case sensitive.
Module 9: Managing Schema Objects. Overview Naming guidelines for identifiers in schema object definitions Storage and structure of schema objects Implementing.
SQL Basics. SQL SQL (Structured Query Language) is a special-purpose programming language designed from managing data in relational database management.
Chapter 9 SQL and RDBMS Part C. SQL Copyright 2005 Radian Publishing Co.
Project Implementation for COSC 5050 Distributed Database Applications Lab2.
ASP.NET Programming with C# and SQL Server First Edition
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor Ms. Arwa.
 SQL stands for Structured Query Language.  SQL lets you access and manipulate databases.  SQL is an ANSI (American National Standards Institute) standard.
SQL data definition using Oracle1 SQL Data Definition using Oracle.
Constraints  Constraints are used to enforce rules at table level.  Constraints prevent the deletion of a table if there is dependencies.  The following.
SQL data definition using Oracle1 SQL Data Definition using Oracle.
Deanery of Business & Computer Sciences SQL Structured Query Language Implementation Lecture – 8 Database Technology Level I.
SQL Data Definition Language (DDL) Using Microsoft SQL Server 1SDL Data Definition Language (DDL)
SQL SQL Server : Overview SQL : Overview Types of SQL Database : Creation Tables : Creation & Manipulation Data : Creation & Manipulation Data : Retrieving.
FEN  Data Definition: CREATE TABLE, ALTER TABLE  Data Manipulation: INSERT, UPDATE, DELETE  Queries: SELECT SQL: Structured Query Language.
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
SQL: DDL. SQL Statements DDL - data definition language –Defining and modifying data structures (metadata): database, tables, views, etc. DML - data manipulation.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 7 (Part a): Introduction to SQL Modern Database Management 9 th Edition Jeffrey A.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
SQL Basics. What is SQL? SQL stands for Structured Query Language. SQL lets you access and manipulate databases.
Chapter 9 Constraints. Chapter Objectives  Explain the purpose of constraints in a table  Distinguish among PRIMARY KEY, FOREIGN KEY, UNIQUE, CHECK,
Database Lab Lecture 1. Database Languages Data definition language ( DDL ) Data definition language –defines data types and the relationships among them.
Chapter 4 Constraints Oracle 10g: SQL. Oracle 10g: SQL 2 Objectives Explain the purpose of constraints in a table Distinguish among PRIMARY KEY, FOREIGN.
DBSQL 5-1 Copyright © Genetic Computer School 2009 Chapter 5 Structured Query Language.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
SQL introduction 2013.
SQL Structured Query Language. Aims  To introduce the implementation of a Physical design using SQL.  To introduce SQL Data Definition Language (DDL).
IS 380 Introduction to SQL This lectures covers material from: database textbook chapter 3 Oracle chapter: 3,14,17.
DATA AND SCHEMA MODIFICATIONS CHAPTERS 4,5 (6/E) CHAPTER 8 (5/E) 1.
Oracle 11g: SQL Chapter 7 User Creation and Management.
Relational Database Management System(RDBMS) Structured Query Language(SQL)
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
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Sravanthi Lakkimsety Mar 14,2016.
LECTURE TWO Introduction to Databases: Data models Relational database concepts Introduction to DDL & DML.
CDT/1 Creating data tables and Referential Integrity Objective –To learn about the data constraints supported by SQL2 –To be able to relate tables together.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Relational Model Chapter 3.
SQL Basics Review Reviewing what we’ve learned so far…….
Understanding Core Database Concepts Lesson 1. Objectives.
Fundamentals of DBMS Notes-1.
Structured Query Language
Introduction to SQL Karolina muszyńska
The Basics of Data Manipulation
Teaching slides Chapter 8.
The Basics of Data Manipulation
مقدمة في قواعد البيانات
CS122 Using Relational Databases and SQL
Chapter 2 Views.
CS1222 Using Relational Databases and SQL
Data Definition Language
Data Definition Language
Chapter # 7 Introduction to Structured Query Language (SQL) Part I.
DATABASE Purpose of database
Understanding Core Database Concepts
CS122 Using Relational Databases and SQL
Presentation transcript:

1 SQL Server Management Studio SQL DDL CREATE TABLE Constraints ALTER TABLE DROP TABLE The GUI way Steen Jensen, autumn 2013

 A lot of the time you will be working in the Query window  Most of the commands can be executed in a graphical way, but start training typing in the SQL commands  The management studio is huge and a lot of functionality is aimed for administrators  And now for a live demo! 2

 SQL stands for Structured Query Language and can be divided into two groups of commands: DDL: Data Definition Language for handling the structure DML: Data Manipulation Language for handling the content  In SQL Server Management Studio you will be using a dialect of SQL called T-SQL (Transact SQL), which is largely compliant with ANSI/ISO SQL standards  All queries work on objects – a fully qualified object name: [ServerName.[DatabaseName.[SchemaName.]]]ObjectName A schema can be used for separating database objects into logical groups – default schema = dbo (= database owner) An object name must always be part of a query – the rest are optional 3

 The command CREATE TABLE is used to create a table and have the below general structure: 4

 Identity: SQL Server automatically assigns a sequenced number for every inserted/new row (other DBMS’s calls this “auto_increment”) Seed is the start value, and increment how much it should be increased  Computed columns: Used for derived attributes/columns  Column constraints: Covered in chapter 6 (e.g. Primary key) 5

 Selected rules for table & column names: Capitalization: start each word with a capital letter (“camel casing”) Name length: keep names as short as possible Limit abbreviations: only use well-known abbreviations (e.g. “no” ) Eliminate spacing between words: use camel casing Avoid underscore : “tricky” to type, difficult to read (underline) 6

7

8

9

10

 The below create command creates a table called Employees 11

 Different constraints can be added for a table  Primary key constraints: 12

 Foreign key constraints: 13

 Foreign key constraints – self-referencing: 14

 Unique constraints: Often referred as alternate keys 15

 Check constraints: Can make a lot of validation 16

 Below is a little subset of, what is possible using the check constraint 17

 Default constraints: If a value is supplied in an insert, then no default value will be used If no value is supplied in an insert, then the default value will be used 18

 Continue with your Amazon system and create the necessary tables in SQL Server Management Studio 19

 The command ALTER TABLE is used to change an existing table and have the below general structure: 20

 The below figure shows two examples of adding new fields/columns to an existing table: 21

 The command DROP TABLE is used to delete the structure and the content of an existing table: 22

 Instead of typing in SQL commands you can do it in a graphical way  Try this by following the instructions page 165bot – 170bot 23