Module 4: Creating Data Types and Tables. Overview Creating Data Types Creating Tables Generating Column Values Generating Scripts.

Slides:



Advertisements
Similar presentations
Database Chapters.
Advertisements

Project Management Database and SQL Server Katmai New Features Qingsong Yao
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.
Creating Tables, Defining Constraints Rose-Hulman Institute of Technology Curt Clifton.
1 Nassau Community CollegeProf. Vincent Costa Acknowledgements: Introduction to Database Management, All Rights ReservedIntroduction to Database Management.
Copyright ©2014 Pearson Education, Inc. Chapter 6 Physical Design Chapter6.1.
Database Constraints. Database constraints are restrictions on the contents of the database or on database operations Database constraints provide a way.
DATABASES AND SQL. Introduction Relation: Relation means table(data is arranged in rows and columns) Domain : A domain is a pool of values appearing in.
Introduction to SQL  SQL or sequel  It is a standardised language with thousands of pages in the standard  It can be in database system through GUI,
Module 3: Changes to Transact-SQL. Overview Accessing Object Information New Transact-SQL Syntax Changes to Objects Distributed Queries.
Using XML in SQL Server 2005 NameTitleCompany. XML Overview Business Opportunity The majority of all data transmitted electronically between organizations.
Module 4: Data Objects. Overview Tables are the main objects that store data Indexes, views, stored programs and other objects are the support structures.
Irwin/McGraw-Hill Copyright © 2000 The McGraw-Hill Companies. All Rights reserved Whitten Bentley DittmanSYSTEMS ANALYSIS AND DESIGN METHODS5th Edition.
CS 3630 Database Design and Implementation. Your Oracle Account UserName is the same as your UWP username Followed Not case sensitive Initial.
CHAPTER:14 Simple Queries in SQL Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
Chapter 7 SQL HUANG XUEHUA. SQL SQL server2005 introduction Install components  management studio.
Module 1: Introduction to Transact-SQL
© 2007 by Prentice Hall3-1 Introduction to Oracle 10g Chapter 3 Creating, Modifying, Renaming, and Deleting Database Tables James Perry and Gerald Post.
Chapter 4 Introduction to MySQL. MySQL “the world’s most popular open-source database application” “commonly used with PHP”
Oracle Data Definition Language (DDL) Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2008.
Module 5 Planning for SQL Server® 2008 R2 Indexing.
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.
Module 3: Creating Data Types and Tables. Overview Working with Data Types Working with Tables Generating Column Values Generating Scripts.
SQL Fundamentals  SQL: Structured Query Language is a simple and powerful language used to create, access, and manipulate data and structure in the database.
Indexes / Session 2/ 1 of 36 Session 2 Module 3: Types of Indexes Module 4: Maintaining Indexes.
Data Types Lesson 4. Skills Matrix Table A table stores your data. Tables are relational in that they are organized as rows and columns (a matrix). Each.
Advanced Web 2012 Lecture 3 Sean Costain What is a Database? Sean Costain 2012 A database is a structured way of dealing with structured information.
SQL Server 2005 Implementation and Maintenance Chapter 3: Tables and Views.
CREATE TABLE CREATE TABLE statement is used for creating relations Each column is described with three parts: column name, data type, and optional constraints.
Session 11 Creating Tables and Using Data Types. RDBMS and Data Management/Session 11/2 of 40 Session Objectives Define the data types and list the categories.
06 | Modifying Data in SQL Server Brian Alderman | MCT, CEO / Founder of MicroTechPoint Tobias Ternstrom | Microsoft SQL Server Program Manager.
# 1# 1 Creating Tables, Setting Constraints, and Datatypes What is a constraint and why do we use it? What is a datatype? What does CHAR mean? CS 105.
Visual Programing SQL Overview Section 1.
GLOBEX INFOTEK Copyright © 2013 Dr. Emelda Ntinglet-DavisSYSTEMS ANALYSIS AND DESIGN METHODSINTRODUCTORY SESSION EFFECTIVE DATABASE DESIGN for BEGINNERS.
Sql DDL queries CS 260 Database Systems.
IMS 4212: Data Modeling—Attributes and Domains 1 Dr. Lawrence West, Management Dept., University of Central Florida Attributes and Domains.
Data Modeling Creating E/R Diagrams SoftUni Team Technical Trainers Software University
Session 1 Module 1: Introduction to Data Integrity
©Silberschatz, Korth and Sudarshan1 Structured Query Language (SQL) Data Definition Language Domains Integrity Constraints.
Chapter 4 Indexes. Indexes Logically represents subsets of data from one or more tables View Generates numeric valuesSequence Basic unit of storage; composed.
1 CS 430 Database Theory Winter 2005 Lecture 11: SQL DDL.
Basic SQL*Plus edit and execute commands SQL*Plus buffer and built-in editor holds the last SQL statement Statements are created in free-flow style and.
Lecture # 24 Introduction to SQL Muhammad Emran Database Systems.
Creating E/R Diagrams with SQL Server Management Studio, Writing SQL Queries D0ncho Minkov Telerik School Academy schoolacademy.telerik.com Technical Trainer.
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.
Lec-7. The IN Operator The IN operator allows you to specify multiple values in a WHERE clause. SQL IN Syntax SELECT column_name(s) FROM table_name WHERE.
Advanced SQL - DDL Advanced Database Dr. AlaaEddin Almabhouh.
Standards and Conventions
Creating Database Objects
Managing Tables, Data Integrity, Constraints by Adrienne Watt
Data Definition and Data Types
Module 2: Creating Data Types and Tables
Data Definition and Data Types
Lesson 7 Managing Data Creating a database with Web Matrix.
Attributes and Domains
SQL Implementation & Administration
Database systems Lecture 2 – Data Types
Chapter 4 Indexes.
CH 4 Indexes.
PT2520 Unit 5: Physical Design
CH 4 Indexes.
Attributes and Domains
Data Definition Language
Chapter 4 Introduction to MySQL.
Creating Database Objects
SQL (Structured Query Language)
Presentation transcript:

Module 4: Creating Data Types and Tables

Overview Creating Data Types Creating Tables Generating Column Values Generating Scripts

 Creating Data Types System-supplied Data Types Creating and Dropping User-defined Data Types Guidelines for Specifying Data Types

System-supplied Data Types Numeric Integer Exact numeric Approximate numeric Monetary Date and Time Character and Unicode Character Binary Other

Creating and Dropping User-defined Data Types Dropping Creating EXEC sp_addtype city, 'nvarchar(15)', NULL EXEC sp_addtype region, 'nvarchar(15)', NULL EXEC sp_addtype country, 'nvarchar(15)', NULL EXEC sp_addtype city, 'nvarchar(15)', NULL EXEC sp_addtype region, 'nvarchar(15)', NULL EXEC sp_addtype country, 'nvarchar(15)', NULL EXEC sp_droptype city

Guidelines for Specifying Data Types If Column Length Varies, Use a Variable Data Type Use tinyint Appropriately For Numeric Data Types, Commonly Use decimal If Storage Is Greater Than 8000 Bytes, Use text or image Use money for Currency Do Not Use float or real as Primary Keys

 Creating Tables How SQL Server Organizes Data in Rows How SQL Server Organizes text, ntext, and image Data Creating and Dropping a Table Adding and Dropping a Column

How SQL Server Organizes Data in Rows Header Fixed Data NB VB Variable Data Null Block Variable Block 4 bytes Data

How SQL Server Organizes text, ntext, and image Data Data row TextPointer Root Structure Intermediate Node block 1 block 2 block 1 block 2

Creating a Table Column Collation Specifying NULL or NOT NULL Computed Columns Dropping a Table Creating and Dropping a Table Column name Data type NULL or NOT NULL CREATE TABLE dbo.Categories (CategoryID CategoryName Description Picture CREATE TABLE dbo.Categories (CategoryID CategoryName Description Picture int IDENTITY (1,1) nvarchar(15) ntext image int IDENTITY (1,1) nvarchar(15) ntext imageNOT NULL, NULL, NULL)NOT NULL, NULL, NULL)

Adding and Dropping a Column ALTER TABLE CategoriesNew ADD Commission money null ADD ALTER TABLE CategoriesNew DROP COLUMN Sales_date DROP Customer_name Sales_amount Sales_date Customer ID Commission

 Generating Column Values Using the Identity Property Using the NEWID Function and the uniqueidentifier Data Type

Using the Identity Property Requirements for Using the Identity Property Only one identity column is allowed per table Use with integer, numeric, and decimal data types Retrieving Information About the Identity Property Use IDENT_SEED and IDENT_INCR for definition information Use to determine most recent value Managing the Identity Property

Using the NEWID Function and the uniqueidentifier Data Type These Features Are Used Together Ensure Globally Unique Values Use with the DEFAULT Constraint CREATE TABLE Customer (CustID uniqueidentifier NOT NULL DEFAULT NEWID(), CustName char(30) NOT NULL) CREATE TABLE Customer (CustID uniqueidentifier NOT NULL DEFAULT NEWID(), CustName char(30) NOT NULL)

Generating Scripts Generate Schema as a Transact-SQL Script Maintain backup script Create or update a database development script Create a test or development environment Train new employees What to Generate Entire database into single script file Table-only schema Table and index schema

Recommended Practices Always Specify Column Characteristics in CREATE TABLE Generate Scripts to Recreate Database and Database Objects Specify Appropriate Data Types and Data Type Sizes

Review Creating Data Types Creating Tables Generating Column Values Generating Scripts