Advanced Database Management System

Slides:



Advertisements
Similar presentations
MySQL. To start go to Login details: login: labuser password:macimd15 – There.
Advertisements

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.
MySQL-Database Teppo Räisänen Oulu University of Applied Sciences School of Business and Information Management.
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 Relational Databases and SQL
Using Relational Databases and SQL Steven Emory Department of Computer Science California State University, Los Angeles Lecture 9: Data Definition Language.
SQL DDL constraints Restrictions on the columns and tables 1SQL DDL Constraints.
Using Relational Databases and SQL Steven Emory Department of Computer Science California State University, Los Angeles Lecture 10: Data Definition Language.
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, Copyright © 2010 All Rights Reserved. 1.
DAT702.  Standard Query Language  Ability to access and manipulate databases ◦ Retrieve data ◦ Insert, delete, update records ◦ Create and set permissions.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
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.
Copyright © Curt Hill Index Creation SQL.
Constraints  Constraints are used to enforce rules at table level.  Constraints prevent the deletion of a table if there is dependencies.  The following.
MySQL. Dept. of Computing Science, University of Aberdeen2 In this lecture you will learn The main subsystems in MySQL architecture The different storage.
Introduction to MySQL Lab no. 10 Advance Database Management System.
SQL SQL Server : Overview SQL : Overview Types of SQL Database : Creation Tables : Creation & Manipulation Data : Creation & Manipulation Data : Retrieving.
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, Copyright © 2015, Fred McClurg, All Rights.
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.
SQL: DDL. SQL Statements DDL - data definition language –Defining and modifying data structures (metadata): database, tables, views, etc. DML - data manipulation.
SQL Basics. What is SQL? SQL stands for Structured Query Language. SQL lets you access and manipulate databases.
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,
Oracle 11g: SQL Chapter 4 Constraints.
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.
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.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 (Part II) INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor.
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.
>> Introduction to MySQL. Introduction Structured Query Language (SQL) – Standard Database Language – Manage Data in a DBMS (Database Management System)
Altering Tables and Constraints Database Systems Objectives Add and modify columns. Add, enable, disable, or remove constraints. Drop a table. Remove.
1 CS 430 Database Theory Winter 2005 Lecture 11: SQL DDL.
There are two types of MySQL instructions (Data Definition Language) DDL: Create database, create table, alter table,,,. (Data Manipulation Language) DML.
Database: SQL, MySQL, LINQ and Java DB © by Pearson Education, Inc. All Rights Reserved.
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.
Distribution of Marks For Second Semester Internal Sessional Evaluation External Evaluation Assignment /Project QuizzesClass Attendance Mid-Term Test Total.
At the end of this lesson, you will be able to: Describe constraints Create and maintain constraints.
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)
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
Introduction to MySQL  Working with MySQL and MySQL Workbench.
Physical Model Lecture 11. Physical Data Model The last step is the physical design phase, In this phase data is – Store – Organized and – Access.
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.
Web Systems & Technologies
Fundamental of Database Systems
Data Definition and Data Types
MySQL-Database Jouni Juntunen Oulu University of Applied Sciences
SQL: Schema Definition and Constraints Chapter 6 week 6
Insert, Update and the rest…
CS311 Database Management system
Structured Query Language (Data definition Language)
Lecturer: Mukhtar Mohamed Ali “Hakaale”
DATABASE SQL= Structure Query Language مبادئ قواعد بيانات
HAVING,INDEX,COMMIT & ROLLBACK
CS122 Using Relational Databases and SQL
Database Management System
CS1222 Using Relational Databases and SQL
Data Definition Language
Data Definition Language
Instructor: Samia arshad
CS122 Using Relational Databases and SQL
កម្មវិធីបង្រៀន SQL Programming ជាភាសាខ្មែរ Online SQL Training Course
Trainer: Bach Ngoc Toan– TEDU Website:
Presentation transcript:

Advanced Database Management System Lab no. 12

Outline SQL Commands (for MySQL) Alter Command phpMyAdmin (DB backup)

Alter table statement Changing a table name Adding Columns alter table table_name rename new_table_name; Adding Columns alter table table_name add column column_name column_attributes; Dropping Columns alter table table_name drop column column_name;

Alter table statement You can add indexes using the index, unique, and primary key commands in the same way you would use them in the create statement: Adding index alter table my_table add index index_name (column_name1); Dropping Index alter table my_table drop index index_name; Adding unique index constraint alter table my_table add unique index_name(column_name); Note that unique index cannot be created on a column with duplicate values Adding Unique constraint on a column alter table my_table add unique(column_name);

Alter table statement Dropping primary key Adding primary key alter table my_table add primary key(my_column); Dropping primary key alter table my_table drop primary key;

Alter table statement Dropping foreign key Adding foreign key alter table my_table add foreign key (my_column) references other_table(col); Dropping foreign key alter table my_table drop foriegn key; Note: Other option to add foreign key from PHPMyAdmin is shown in next slide You will have to create an index on the foreign key column then select the option shown in next slide.

Alter cont’d Changing column definitions It is possible to change a column’s name or attributes with either the change or modify command. To change a column’s name you must also redefine the column’s attributes. The following will work: alter table my_table change old_col new_col int not null; To change a column’s characteristics/attributes, do the following: alter table my_table modify col_name varchar(50);

For further reference on ALTER http://dev.mysql.com/doc/refman/5.0/en/alter-table.html

Show statement cont’d show columns show index show table status Syntax: show columns from table_name; show index Syntax: show index from table_name; show table status Syntax: Show table status like ‘table_name’;

The Show statement Show Database: On mySql console write… mysql> show databases; Show Tables: On MySql console write… mysql> Use guestbook; mysql> show tables; Example: mysql> use guestbook; Database changed +---------------------+ | Tables_in_guestbook | | guestbook | | guestbook1 | | my_table | 3 rows in set (0.11 sec) mysql>

Example mysql> show table status like 'guestbook' *************************** 1. row *************************** Name: guestbook Engine: InnoDB Version: 10 Row_format: Compact Rows: 0 Avg_row_length: 0 Data_length: 16384 Max_data_length: 0 Index_length: 0 Data_free: 0 Auto_increment: NULL Create_time: 2008-04-05 01:38:12 Update_time: NULL Check_time: NULL Collation: latin1_swedish_ci Checksum: NULL Create_options: Comment: InnoDB free: 4096 kB 1 row in set (0.02 sec) mysql>_

Show cont’d Show create table: Syntax: show create table guestbook mysql> show create table guestbook *************************** 1. row *************************** Table: guestbook Create Table: CREATE TABLE `guestbook` ( `name` varchar(40) default NULL, `location` varchar(40) default NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 1 row in set (0.00 sec) mysql>

Taking Database Backup