SQL: DDL. SQL Statements DDL - data definition language –Defining and modifying data structures (metadata): database, tables, views, etc. DML - data manipulation.

Slides:



Advertisements
Similar presentations
SQL’s Data Definition Language (DDL) n DDL statements define, modify and remove objects from data dictionary tables maintained by the DBMS n Whenever you.
Advertisements

SQL components In Oracle. SQL in Oracle SQL is made up of 4 components: –DDL Data Definition Language CREATE, ALTER, DROP, TRUNCATE. Creates / Alters.
Using SQL to create tables Ways of using Databases.
ASP.NET Database Connectivity I. 2 © UW Business School, University of Washington 2004 Outline Database Concepts SQL ASP.NET Database Connectivity.
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.
SQL DDL constraints Restrictions on the columns and tables 1SQL DDL Constraints.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 4-1 David M. Kroenke Database Processing Chapter 7 Structured Query Language.
Database Management System LICT 3011 Eyad H. Elshami.
Using Relational Databases and SQL Steven Emory Department of Computer Science California State University, Los Angeles Lecture 10: Data Definition Language.
Oracle Data Definition Language (DDL)
1 IT420: Database Management and Organization SQL: Structured Query Language 25 January 2006 Adina Crăiniceanu
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.
 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 (CB Chapter 6) CPSC 356 Database Ellen Walker Hiram College (Includes figures from Database Systems by Connolly & Begg, © Addison Wesley.
SQL data definition using Oracle1 SQL Data Definition using Oracle.
Chapter 10 – Database Creation1 IT238: Data Modeling and Database Design Unit 6: Database Creation Instructor: Qing Yan, M.D., Ph.D.
Chapter 7 SQL HUANG XUEHUA. SQL SQL server2005 introduction Install components  management studio.
SQL data definition using Oracle1 SQL Data Definition using Oracle.
Oracle Data Definition Language (DDL) Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2008.
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.
SQL: DDL John Ortiz Cs.utsa.edu.
SQL Basics. 5/27/2016Chapter 32 of 19 Naming SQL commands are NOT case sensitive SQL commands are NOT case sensitive But user identifier names ARE case.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 7 (Part a): Introduction to SQL Modern Database Management 9 th Edition Jeffrey A.
SQL Basics. What is SQL? SQL stands for Structured Query Language. SQL lets you access and manipulate databases.
SQL Structured Query Language 1. Data Definition Language (DDL) is used to manage table and define data structure i.e. CREATE, ALTER, DROP Data Control.
Tables and Constraints Oracle PL/SQL. Datatypes The SQL Data Definition Language Commands (or DDL) enable us to create, modify and remove database data.
1 SQL - II Data Constraints –Applying data constraints Types of data constraints –I/O constraints The PRIMARY KEY constraints The FOREIGN KEY constraints.
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.
CREATE TABLE CREATE TABLE statement is used for creating relations Each column is described with three parts: column name, data type, and optional constraints.
Prince Sultan University Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.
Chapter 4 Constraints Oracle 10g: SQL. Oracle 10g: SQL 2 Objectives Explain the purpose of constraints in a table Distinguish among PRIMARY KEY, FOREIGN.
SQL: Part 1 Original materials supplied by the Oracle Academic Initiative (OAI). Edited for classroom use by Professor Laku Chidambaram. Not for commercial.
DBSQL 5-1 Copyright © Genetic Computer School 2009 Chapter 5 Structured Query Language.
Visual Programing SQL Overview Section 1.
© 2002 by Prentice Hall 1 David M. Kroenke Database Processing Eighth Edition Chapter 9 Structured Query Language.
1 SQL-2 Tarek El-Shishtawy Professor Ass. Of Computer Engineering.
1 DBS201: More on SQL Lecture 3. 2 Agenda How to use SQL to update table definitions How to update data in a table How to join tables together.
Week 8-9 SQL-1. SQL Components: DDL, DCL, & DML SQL is a very large and powerful language, but every type of SQL statement falls within one of three main.
©Silberschatz, Korth and Sudarshan1 Structured Query Language (SQL) Data Definition Language Domains Integrity Constraints.
Altering Tables and Constraints Database Systems Objectives Add and modify columns. Add, enable, disable, or remove constraints. Drop a table. Remove.
Populating and Querying tables Insert, Update, Delete and View (DML)
There are two types of MySQL instructions (Data Definition Language) DDL: Create database, create table, alter table,,,. (Data Manipulation Language) DML.
Relational Database Management System(RDBMS) Structured Query Language(SQL)
IS6146 Databases for Management Information Systems Lecture 3: SQL III – The DDL Rob Gleasure robgleasure.com.
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.
UNIVERSITAS BINA DARMA 2013 DATA DEFINITION LANGUAGE (DDL)
Databases Introduction - concepts. Concepts of Relational Databases.
Constraints and Views Chap. 3-5 continued (7 th ed. 5-7)
Physical Model Lecture 11. Physical Data Model The last step is the physical design phase, In this phase data is – Store – Organized and – Access.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 Basic SQL تنبيه : شرائح العرض (Slides) هي وسيلة لتوضيح الدرس واداة.
Rob Gleasure robgleasure.com
Structured Query Language
Fundamental of Database Systems
Rob Gleasure robgleasure.com
SQL: Schema Definition and Constraints Chapter 6 week 6
The Basics of Data Manipulation
DATABASE SQL= Structure Query Language مبادئ قواعد بيانات
لغة قواعد البيانات STRUCTURED QUERY LANGUAGE SQL))
The Basics of Data Manipulation
SQL data definition using Oracle
DATABASE SQL= Structure Query Language مبادئ قواعد بيانات
Oracle Data Definition Language (DDL)
SQL-1 Week 8-9.
Database Management System
Session - 6 Sequence - 1 SQL: The Structured Query Language:
Data Definition Language
Session - 6 Sequence - 1 SQL: The Structured Query Language:
Presentation transcript:

SQL: DDL

SQL Statements DDL - data definition language –Defining and modifying data structures (metadata): database, tables, views, etc. DML - data manipulation language –Manipulating user data: insert, update, select, etc. DCL - data control language –Control data access: permissions, etc.

3 SQL DDL DDL statements include –CREATE Table –ALTER Table –DROP Table

Create Table CREATE TABLE TableName ( ColumnDefinitions, Table Constraints )

5 Column Definition What to define? –Column name (required) –Data type and length (required) –Column constraints (optional): primary key, null, not null, default, unique, check Example FirstName VARCHAR(30) NOT NULL,

6 Data Types Data types are slightly different in many database products Data types reference –Access 2007: –SQL Server 2005:

Example

Example: Using Table Constraints

Example: Foreign Key

ALTER Table Alter Table TableName [Modification] Modification include –Add, modify, drop columns –Add, modify, drop table constraints

11 Altering Columns Adding a new column ALTER TABLE tablename ADD (column datatype); Modify a column ALTER TABLE tablename MODIFY (column newdatatype); ALTER TABLE Customer ADD (FNAME VARCHAR(30)); ALTER TABLE Customer MODIFY (FName VARCHAR(40)); Drop a column ALTER TABLE tablename DROP COLUMN colummname; ALTER TABLE Customer DROP COLUMN FName;

Altering Table Constraints Add a foreign key Alter table GroupAssignment add constraint GroupAssignment_FK2 foreign key(GroupNumber) references Groups(GroupId) on update cascade;

13 DROP Table DROP TABLE tablename; DROP TABLE Customer; Warning… The DROP statement will permanently remove table structure and all data

Summary Key concepts –DDL –Create –Alter –Drop –SQL Data types –Referential integrity, cascade