Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, Copyright © 2010 All Rights Reserved. 1.

Slides:



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

Let’s try Oracle. Accessing Oracle The Oracle system, like the SQL Server system, is client / server. For SQL Server, –the client is the Query Analyser.
SQL components In Oracle. SQL in Oracle SQL is made up of 4 components: –DDL Data Definition Language CREATE, ALTER, DROP, TRUNCATE. Creates / Alters.
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, Copyright © 2010 All Rights Reserved. 1.
CS320 Web and Internet Programming SQL and MySQL Chengyu Sun California State University, Los Angeles.
A Guide to MySQL 3. 2 Objectives Start MySQL and learn how to use the MySQL Reference Manual Create a database Change (activate) a database Create tables.
CSC 2720 Building Web Applications Database and SQL.
DAT702.  Standard Query Language  Ability to access and manipulate databases ◦ Retrieve data ◦ Insert, delete, update records ◦ Create and set permissions.
Introduction To Databases IDIA 618 Fall 2014 Bridget M. Blodgett.
1 CSE 480: Database Systems Lecture 9: SQL-DDL Reference: Read Chapter of the textbook.
MySQL Dr. Hsiang-Fu Yu National Taipei University of Education
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
INTERNET APPLICATION DEVELOPMENT For More visit:
ASP.NET Programming with C# and SQL Server First Edition
Copyright © 2003 Pearson Education, Inc. Slide 8-1 The Web Wizard’s Guide to PHP by David Lash.
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
 SQL stands for Structured Query Language.  SQL lets you access and manipulate databases.  SQL is an ANSI (American National Standards Institute) standard.
Lecture 9 – MYSQL and PHP (Part1) SFDV3011 – Advanced Web Development 1.
Chapter 7 Working with Databases and MySQL PHP Programming with MySQL 2 nd Edition.
Chapter 7 Working with Databases and MySQL PHP Programming with MySQL 2 nd Edition.
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.
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.
NMED 3850 A Advanced Online Design January 12, 2010 V. Mahadevan.
Database Fred Durao What is a database? A database is any organized collection of data. Some examples of databases you may encounter in.
CPS120: Introduction to Computer Science Lecture 19 Introduction to SQL.
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, Copyright © 2015, Fred McClurg, All Rights.
1 Structured Query Language (SQL). 2 Contents SQL – I SQL – II SQL – III SQL – IV.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Advanced Database Management System
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.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Information Building and Retrieval Using MySQL Track 3 : Basic Course in Database.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
Visual Programing SQL Overview Section 1.
>> 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.
CP476 Internet Computing Perl CGI and MySql 1 Relational Databases –A database is a collection of data organized to allow relatively easy access for retrievals,
There are two types of MySQL instructions (Data Definition Language) DDL: Create database, create table, alter table,,,. (Data Manipulation Language) DML.
ECMM6018 Enterprise Networking For Electronic Commerce Tutorial 6 CGI/Perl and databases.
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.
Kirkwood Center for Continuing Education By Fred McClurg, Introduction to PHP and MySQL Copyright © 2015, Fred McClurg, All Rights.
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 Table Creation and Management Oracle 10g: SQL.
Unit-8 Introduction Of MySql. Types of table in PHP MySQL supports various of table types or storage engines to allow you to optimize your database. The.
Databases and SQL CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
CS320 Web and Internet Programming SQL and MySQL Chengyu Sun California State University, Los Angeles.
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.
Introduction to Databases & SQL Ahmet Sacan. What you’ll need Firefox, SQLite plugin Mirdb and Targetscan databases.
Introduction to Database Programming with Python Gary Stewart
Web Systems & Technologies
Chapter 5 Introduction to SQL.
CS320 Web and Internet Programming SQL and MySQL
MySQL-Database Jouni Juntunen Oulu University of Applied Sciences
Prepared by : Moshira M. Ali CS490 Coordinator Arab Open University
Chapter 7 Working with Databases and MySQL
Chapter 8 Working with Databases and MySQL
Introduction To Structured Query Language (SQL)
Database systems Lecture 3 – SQL + CRUD
Contents Preface I Introduction Lesson Objectives I-2
CS3220 Web and Internet Programming SQL and MySQL
Data Definition Language
Data Definition Language
MySQL Database System Installation Overview SQL summary
CS3220 Web and Internet Programming SQL and MySQL
Presentation transcript:

Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, Copyright © 2010 All Rights Reserved. 1

Chapter Eight MySQL Fundamentals ses/php/slides/chapter08a.fundamentals.ppt 2

 Released internally May 23, 1995  Version 3.23 (January 2001) supported multiple DB engines:  MyISAM: For large amounts of data  InnoDB: For transaction safe processing  InnoDB: For foreign key support  Version 4.0 (March 2003):  Unions: Merging results of two queries into one result  Version 4.1 (October 2004):  Subqueries: Query within a query  Prepared Statements: Precompiled statement MySQL History 3

 Version 5.0 (October 2005):  Cursors: Retrieving multi-row data  Stored Procedures: SQL functions stored in the database  Triggers: Events executed upon tables and columns and defined in the database  Views: Predefined select statement  Transactions: Guarantee the order and success of operations MySQL History (continued) 4

 Sun Microsystems acquires MySQL February 26, 2008  Current Generally Available Release:  Event scheduler: Execute event at a specified time  Row-base replication: Copy data from one table to another at the row level  Partitioning: Divide the data into independent parts MySQL History (continued) 5

 Sun Microsystems acquires MySQL on February 26, 2008  Oracle buys Sun on April 20, 2009  Generally Available Release:  Development Release:  Version 6.0+ (Alpha testing now):  Foreign key support for all database engines MySQL History Summary 6

MySQL Home Page: MySQL MySQL 5.1 Reference Manual: MySQL Documentation Search (plugin for firefox): SQL Tutorial: MySQL Workbench: MySQL References 7

MySQL uses Structured Query Language (SQL) SQL is language for retrieving, updating, deleting, information from a database Relational databases use a model that define data according to relationships Other databases: Oracle, Informix, DB2 (IBM) Access (Microsoft), SQL Server, PostgreSQL What is MySQL? 8

Table: A named set of data that is organized into data types (or columns) and data values (or rows). A table has a specific number of columns, but can have any number of rows. Column: A named collection of data elements of the same data type. A database column is analogous to an array variable in a programming language. Row: A set of related data fields that share the same data type structure. A row consists of a field that corresponds to each column in a table. Rows are also known as database records. A database row can be thought of as a multi-dimensional array of values. Database Definition of Terms 9

Database: A database is a named collection of tables that have a similar purpose. Field: A single database element that contains a data value. It is the intersection of a column and a row. Schema: Refers to the database structure of how data is organized. Database Definition of Terms (cont.) 10

Chapter Eight MySQL Commands 11

MySQL can be a accessed via command line (and the API from within PHP). To login to MySQL: mysql -h hostname -u user -p Note: On new MySQL installations the user is “root” and the password is blank (e.g. ""). Exit the command line shell: quit | exit Login/Logout Syntax 12

Example command line login: Login/Logout Example 13

Display the database version and misc information. Example: status; MySQL Status 14

Note: The databases “information_schema”, “mysql”, “phpmyadmin”, contain meta data (e.g. data about data) concerning tables. They are used for administrative purposes. DO NOT DELETE THEM! The databases “test” and “cdcol” are for user testing. Display all databases available. Example: show databases; Show Databases 15

show tables; Display all the tables in a database. Show Tables 16

Sets a connection to a specific database. Syntax: use dbName; Database Connection 17

Display the column names and types in a table. Syntax: describe tableName; Describe Table 18

source fileName; Execute SQL commands contained in a file as a script: MySQL Source File 19

MySQL permits syntax for three different comments. Example: /* * Multi-line comment * and /* nested comments * are legal */ */ # Shell-like comment -- Standard SQL comment MySQL Comments 20

Chapter Eight Administrator Commands 21

Syntax: CREATE DATABASE dbName; Example: CREATE DATABASE carddb; USE carddb; Creating a Database 22

Syntax: CREATE TABLE tblName ( colName1 dataType1 [colAttr1...] [, colName2 dataType2] [, colAttr2...] [, tblAttr1,...] ); Table Creation Syntax 23

CREATE TABLE notecard ( # id INT NOT NULL AUTO_INCREMENT, id /* column name */ INT /* column data type */ NOT NULL /* data can’t be null */ AUTO_INCREMENT, /* next integer */ name VARCHAR(50), /* 50 chr max */ content TEXT, /* unlimited char */ creation TIMESTAMP DEFAULT NOW(), category_id INT, /* foreign key */ PRIMARY KEY(id) ); /* index */ Table Creation Anatomy 24

Description: The describe command displays the column name, column type, and other attributes regarding a table. Syntax: DESCRIBE tableName; Tables Described 25

Syntax: ALTER TABLE oldTable RENAME newTable; Example: ALTER TABLE notecard RENAME recipe; Renaming a Table 26

Syntax: ALTER TABLE tableName CHANGE oldColNam newColNam newColType; Example: ALTER TABLE author CHANGE penname pseudonym varchar(25); Changing (Renaming) Column Name 27

Syntax: ALTER TABLE tableName MODIFY colName colType; Example: ALTER TABLE book MODIFY author varchar(25); Warning: Changing the data type of a column in a table that contains values could cause a loss of data! Modifying a Column Data Type 28

Modifying a Column Data Type (cont.) 29

Syntax: ALTER TABLE tblName ADD colName1 colType1 FIRST|AFTER colName2; Example: ALTER TABLE book ADD pseudonym varchar(25) AFTER id; Adding a Column 30

Syntax: ALTER TABLE tblName MODIFY colNam1 colType FIRST|AFTER colNam2; Example: ALTER TABLE book MODIFY pseudonym varchar(25) AFTER author; Changing the Column Order 31

Syntax: ALTER TABLE tableName DROP columnName; Example: ALTER TABLE book DROP pseudonym; Pitfall: Dropping a column also removes the data stored in the column! Note: There is no “undo” on dropped columns. Removing a Column 32

Syntax: DROP TABLE tableName; Example: DROP TABLE book; Pitfall: Dropping a table also removes the data stored in the table! Note: There is no “undo” on dropped tables. Removing a Table 33

to be continued... /courses/php/slides/chapter08b.crud.ppt