ALTER Command Building Database Relationships. page 21/4/2014 Presentation ALTER Command The ALTER command allows you to change almost everything in your.

Slides:



Advertisements
Similar presentations
Normalization Building Database Relationships. page 21/4/2014 Presentation Normalization Youve been creating tables without giving much thought to them.
Advertisements

Database Relationship Modeling Building Database Relationships.
Query Methods (SQL). What is SQL A programming language for databases. SQL (structured Query Language) It allows you add, edit, delete and run queries.
Virtual training week 4 structured query language (SQL)
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.
Quick-and-dirty.  Commands end in a semi-colon ◦ If you forget, another prompt line shows up  Either continue the command or…  End it with a semi-colon.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 7-1 COS 346 Day 11.
SQL Data Definition II Stanislava Armstrong 1SQL Data Definition II.
Database Modifications A modification command does not return a result as a query does, but it changes the database in some way. There are three kinds.
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.
5 Chapter 5 Structured Query Language (SQL1) Revision.
30-Jun-15 SQL A Brief Introduction. SQL SQL is Structured Query Language Some people pronounce SQL as “sequel” Other people insist that only “ess-cue-ell”
DAT702.  Standard Query Language  Ability to access and manipulate databases ◦ Retrieve data ◦ Insert, delete, update records ◦ Create and set permissions.
Database Constraints. Database constraints are restrictions on the contents of the database or on database operations Database constraints provide a way.
MY SQL Eng: SAHAR. Introduction to SQL What is SQL? When a user wants to get some information from a database file, he can issue a query A query is a.
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
 SQL stands for Structured Query Language.  SQL lets you access and manipulate databases.  SQL is an ANSI (American National Standards Institute) standard.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
Constraints  Constraints are used to enforce rules at table level.  Constraints prevent the deletion of a table if there is dependencies.  The following.
Programming using C# Joins SQL Injection Stored Procedures
15/10/20151 PHP & MySQL 'Slide materials are based on W3Schools PHP tutorial, 'PHP website 'MySQL website.
Introduction to MySQL Lab no. 10 Advance Database Management System.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
Other database objects (Sequence). What Is a Sequence? A sequence: Automatically generates sequential numbers Is a sharable object Is typically used to.
DATA MANIPULATION andCONTROL
1 Structured Query Language (SQL). 2 Contents SQL – I SQL – II SQL – III SQL – IV.
Advanced Database Management System
Effective Indexes For Beginners. Performance is slow Let’s add another index!
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.
Chapter 5 MYSQL Database. Introduction to MYSQL MySQL is the world's most popular open-source database. Open source means that the source code, the programming.
Oracle 11g DATABASE DEVELOPMENT LAB1. Introduction  Oracle 11g Database:-  Oracle 11g database is designed for some features, which helps to the organizations.
SQL: DDL. SQL Statements DDL - data definition language –Defining and modifying data structures (metadata): database, tables, views, etc. DML - data manipulation.
M1G Introduction to Database Development 5. Doing more with queries.
Intro to SQL| MIS 2502  Spacing not relevant › BUT… no spaces in an attribute name or table name  Oracle commands keywords, table names, and attribute.
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.
1 SQL - II Data Constraints –Applying data constraints Types of data constraints –I/O constraints The PRIMARY KEY constraints The FOREIGN KEY constraints.
SQL for Database Construction and Application Processing
Prince Sultan University Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.
Visual Programing SQL Overview Section 1.
SQL John Nowobilski. What is SQL? Structured Query Language Manages Data in Database Management Systems based on the Relational Model Developed in 1970s.
Altering Tables and Constraints Database Systems Objectives Add and modify columns. Add, enable, disable, or remove constraints. Drop a table. Remove.
Relational Database Management System(RDBMS) Structured Query Language(SQL)
Distribution of Marks For Second Semester Internal Sessional Evaluation External Evaluation Assignment /Project QuizzesClass Attendance Mid-Term Test Total.
Chapter 3 Table Creation and Management Oracle 10g: SQL.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 Basic SQL تنبيه : شرائح العرض (Slides) هي وسيلة لتوضيح الدرس واداة.
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.
LEC-8 SQL. Indexes The CREATE INDEX statement is used to create indexes in tables. Indexes allow the database application to find data fast; without reading.
Fundamentals of DBMS Notes-1.
Database Access with SQL
CS SQL.
Tables and Triggers.
CHAPTER 7 DATABASE ACCESS THROUGH WEB
CS311 Database Management system
Database application MySQL Database and PhpMyAdmin
DATABASE SQL= Structure Query Language مبادئ قواعد بيانات
Workbench Data Definition Language (DDL)
Teaching slides Chapter 8.
CS122 Using Relational Databases and SQL
Database Processing: David M. Kroenke’s Chapter Seven:
CS1222 Using Relational Databases and SQL
Data Definition Language
Data Definition Language
Instructor: Samia arshad
CS122 Using Relational Databases and SQL
SQL NOT NULL Constraint
SQL (Structured Query Language)
SQL AUTO INCREMENT Field
Presentation transcript:

ALTER Command Building Database Relationships

page 21/4/2014 Presentation ALTER Command The ALTER command allows you to change almost everything in your table without having to reinsert your data. But be careful, if you change a column of one data type to a different one, you risk losing your data.

page 31/4/2014 Presentation ALTER Command Dataville Alterations: OUR SERVICES FOR EXISTING TABLES: CHANGE both the name and data type of an existing column * MODIFY the data type or position of an existing column * ADD a column to your tableyou pick the data type DROP a column from your table * * Possible loss of data may occur, no guarantees offered.

page 41/4/2014 Presentation All about relationships Import projekts table Lets use DESCRIBE to see how this table is constructed: DESCRIBE projekts; This shows us if a columns is the primary key and what type of data is being stored in each column.

page 51/4/2014 Presentation ALTER TABLE Our first step will be to use ALTER TABLE and give our table a meaningful name. ALTER TABLE projekts RENAME TO project_list;

page 61/4/2014 Presentation Retooling our columns We can RENAME our existing columns. By renaming these columns that contain valid data, we wont need to insert the data into new columns. We need to add three columns called est_cost, con_phone, and start_date.

page 71/4/2014 Presentation ALTER and CHANGE Change the column number to have a new name, proj_id, and set it to AUTO_INCREMENT. Then well make it a primary key.

page 81/4/2014 Presentation Change two columns with one SQL statement Well alter the names of the columns called descriptionofproj and contractoronjob, and at the same time were also going to change their data types. All we have to do is include both CHANGE COLUMN lines in one ALTER TABLE statement and put a comma between them. If you change the data type to something new, you may lose data.

page 91/4/2014 Presentation MODIFY keyword The MODIFY keyword. It changes only the data type of a column and leaves the name alone. For example, suppose you needed a longer column to hold the proj_desc. You want it to be VARCHAR(120). Heres what you need to do.

page 101/4/2014 Presentation DROP that column Its good programming practice to have only the columns you need in your table. If you arent using a column, drop it. With ALTER, you can easily add it back again, if you need it in the future. Once youve dropped a column, everything that was stored in it is removed too!

page 111/4/2014 Presentation Moving the columns ALTER TABLE mytable MODIFY COLUMN mycolumn INT AFTER someothercolumn; ALTER TABLE mytable MODIFY COLUMN mycolumn INT FIRST;

page 121/4/2014 Presentation Questions???