SlideShare a Scribd company logo
1 of 37
Download to read offline
MySQL 102

    MySQL 102 is the second part of a
presentation to be preceded by MySQL 101
 and covers material that will build on the
           previous presentation.


                                                 1
Http://slideshare.net/davestokes/presentations
Agenda
โž”   Workbench
โž”   User Accounts & Privileges
โž”   Tables and Databases
โž”   Views
โž”   Stored Routines/Procedures
โž”   Questions and Answers
โž”   Replication (after a break)
David.Stokes@Oracle.com   @stoker   2
Workbench
๎€Œ   FREE
๎€Œ   http://dev.mysql.com/downloads/
๎€Œ   Three tools in one
    ๎€Œ Query Tool
    ๎€Œ Admin Tool
    ๎€Œ Entity Relationship Mapper
๎€Œ    Scripts available for setting up replication,
        fail over and more


http://dev.mysql.com/doc/refman/5.5/en/getting-mysql.html   3
Did I mention free?




http://dev.mysql.com/downloads/workbench/   4
Admin




        5
User Accounts




           6
Users and Hosts




             7
Know whom
can do what
      ๎€Œ   We have four
          accounts
          ๎€Œ   Anonymous (%)
          ๎€Œ   ODBC
          ๎€Œ   joe
          ๎€Œ   root
      ๎€Œ   ODBC and joe can
            login from any host
            while root and
            anonymous are local
            host only

                              8
Joe's Info


'joe' can connect to the mysqld server from any host.
Note he does not have a password which can be a
serious security concern.



                                               9
htallation.html
Joe's Priviledges




               10
Joe's Limits


Account Limits can be used to throttle user access.

                                               11
Schema Privileges




               12
Easier than ...
GRANT INSERT, UPDATE,
SELECT
ON world.*
To 'joe'@'%';
FLUSH PRIVILEGES;

                   13
Tables & Databases
Databases contain tables, which
are used for storing data.
Databases also contain objects
such as stored routines or
triggers. โ€“ MySQl 5.0 Certification
Guide

httphtml                       14
1. CREATE DATABASE foo
               2. (magic)
              3. mkdir foo

๎€Œ   CREATE DATBASE
    will create a directory
    to house .frm files
๎€Œ   InnoDB tables will
    have table spaces for
    data & indexes
๎€Œ   MyISQM can also
    have .MYD and .MYI
    files for data and
    indexes

                                15
Databases
๎€Œ   db.opt will hold info on
    character sets,
    collations.
๎€Œ   Databases can hold
    zero or more tables
    plus objects like view,
    triggers
๎€Œ   Databases can not be
    nested



                               16
CREATE a DATABASE, aka SCHEMA



๎€Œ   Use Workbench to
    create a schema




                                       17
Create 'demo'


Here we create a schema named 'demo' with UTF8 character set
and the 'general' 'case insensitive' collation.


                                                      18
Review โ€“
๎€Œ   Workbench will show
    the statement used to
    create the schema.
๎€Œ   Or you could type in
    the SQL by hand.




                            19
We have 'demo'
๎€Œ   Double click on demo
    to expand the list of
    contents




                            20
CREATE a table



๎€Œ   Now we can create a
    table in the 'demo'
    schema




                                 21
Creating a Table



Create a table named stuff with a column named
member_id that is NOT NULL, AUTOINCREMENT,
UNSIGNED and a PRIMARY KEY

                                          22
Review the SQL
We can see the
SQL that is about
to be executed to
create the table.




                    23
Double Check
๎€Œ   Any problems will be
    show here as well as
    success




                           24
SHOW CREATE TABLE




๎€Œ   Note that INT(10) means 10 characters will be
    shown for output. INT(2) will show two places of
    data by default but still holds upto 2147483647
    signed or 4294967295 unsigned.
                                               25
After adding
   two more columns
For the sake of brevity,
two more columns have
been added for name and
email, both are stup to
hold CHAR data




                           26
Add some data

๎€Œ   Note we do not have member_id mentioned.




                                           27
Select data from stuff
 Here we select data
 from the table. Note
 that member_id was
 automatically filled in
 for this record.




                           28
Add a few more
         records
Here a few more records
have been added and the
member_id has again has
been incremented and
inserted.




                          29
Triggers
๎€Œ   Triggers are 'fired' in response to a an SQL
    statement.
๎€Œ   They can happen before OR after an INSERT,
    UPDATE, or DELETE event.
๎€Œ
๎€Œ   They can be used to check values, sum data, etc.
๎€Œ   You may not want 'logic' in your database and
    prefer to have it in the application level.




                                              30
Boss: We need to track
previous email addresses




๎€Œ   Lets track previous email address by placing them
    in a new column creatively called oldemail.




                                               31
Trigger in Action




               32
Did you catch the mistake?

 The previous trigger had a serious logical
 flaw. Take a look at it and see if you can
                  spot it.



 Hint: Is the email the only thing that will
              ever get updated?
                                        33
VIEWS
๎€Œ   Views are stored queries that when invoked
    produce a result set. A view acts as a virtual table.
๎€Œ   Can be used to hide table and column names from
    programmers.
๎€Œ   Can be used to gather information from many
    tables into one view for simpler access (PHB
    protector)
๎€Œ   Not materialized




                                                  34
Create a VIEW,
        use as a table



๎€Œ   SELECT * from get_stuffg
๎€Œ   SELECT Customer from get_stuffg




                                       35
Stored Routines
  Stored Procedures
   Stored procedures and Stored Routines take zero or more
 arguments. A Stored Procedure can pass back values through
output variables or result sets. A function must output exactly
                      ONE scalar variable.

MySQL Follows the ISO:2003 SQL standard syntax for stored
                       routines.

        And theses two subjects are not for newbies.


                                                        36
Questions/Answers




David.Stokes@Oracle.com   @stoker   37

More Related Content

What's hot

MySql slides (ppt)
MySql slides (ppt)MySql slides (ppt)
MySql slides (ppt)webhostingguy
ย 
spring-tutorial
spring-tutorialspring-tutorial
spring-tutorialArjun Shanka
ย 
Database administration
Database administrationDatabase administration
Database administrationabhi_love
ย 
Beginner guide to mysql command line
Beginner guide to mysql command lineBeginner guide to mysql command line
Beginner guide to mysql command linePriti Solanki
ย 
Mysql database
Mysql databaseMysql database
Mysql databasemayank78634
ย 
Database administration commands
Database administration commands Database administration commands
Database administration commands Varsha Ajith
ย 
Managing users & tables using Oracle Enterprise Manage
Managing users & tables using Oracle Enterprise ManageManaging users & tables using Oracle Enterprise Manage
Managing users & tables using Oracle Enterprise ManageNR Computer Learning Center
ย 
MySQL and its basic commands
MySQL and its basic commandsMySQL and its basic commands
MySQL and its basic commandsBwsrang Basumatary
ย 
Manage users & tables in Oracle Database
Manage users & tables in Oracle DatabaseManage users & tables in Oracle Database
Manage users & tables in Oracle DatabaseNR Computer Learning Center
ย 
Oracle ORA Errors
Oracle ORA ErrorsOracle ORA Errors
Oracle ORA ErrorsManish Mudhliyar
ย 
Mysql
MysqlMysql
Mysqlksujitha
ย 
MySQL lecture
MySQL lectureMySQL lecture
MySQL lecturewebhostingguy
ย 
Using object dependencies in sql server 2008 tech republic
Using object dependencies in sql server 2008   tech republicUsing object dependencies in sql server 2008   tech republic
Using object dependencies in sql server 2008 tech republicKaing Menglieng
ย 
Blocks In Drupal
Blocks In DrupalBlocks In Drupal
Blocks In Drupalguest6fb0ef
ย 
้ฆ™ๆธฏๅ…ญๅˆๅฝฉ
้ฆ™ๆธฏๅ…ญๅˆๅฝฉ้ฆ™ๆธฏๅ…ญๅˆๅฝฉ
้ฆ™ๆธฏๅ…ญๅˆๅฝฉiewsxc
ย 

What's hot (19)

MySql slides (ppt)
MySql slides (ppt)MySql slides (ppt)
MySql slides (ppt)
ย 
spring-tutorial
spring-tutorialspring-tutorial
spring-tutorial
ย 
Database administration
Database administrationDatabase administration
Database administration
ย 
Les14
Les14Les14
Les14
ย 
Beginner guide to mysql command line
Beginner guide to mysql command lineBeginner guide to mysql command line
Beginner guide to mysql command line
ย 
Mysql database
Mysql databaseMysql database
Mysql database
ย 
MySql:Introduction
MySql:IntroductionMySql:Introduction
MySql:Introduction
ย 
Database administration commands
Database administration commands Database administration commands
Database administration commands
ย 
Managing users & tables using Oracle Enterprise Manage
Managing users & tables using Oracle Enterprise ManageManaging users & tables using Oracle Enterprise Manage
Managing users & tables using Oracle Enterprise Manage
ย 
MySQL and its basic commands
MySQL and its basic commandsMySQL and its basic commands
MySQL and its basic commands
ย 
Manage users & tables in Oracle Database
Manage users & tables in Oracle DatabaseManage users & tables in Oracle Database
Manage users & tables in Oracle Database
ย 
Oracle ORA Errors
Oracle ORA ErrorsOracle ORA Errors
Oracle ORA Errors
ย 
Mysql
MysqlMysql
Mysql
ย 
MySQL lecture
MySQL lectureMySQL lecture
MySQL lecture
ย 
Using object dependencies in sql server 2008 tech republic
Using object dependencies in sql server 2008   tech republicUsing object dependencies in sql server 2008   tech republic
Using object dependencies in sql server 2008 tech republic
ย 
ANDROID USING SQLITE DATABASE ADMINISTRATORS ~HMFTJ
ANDROID USING SQLITE DATABASE ADMINISTRATORS ~HMFTJANDROID USING SQLITE DATABASE ADMINISTRATORS ~HMFTJ
ANDROID USING SQLITE DATABASE ADMINISTRATORS ~HMFTJ
ย 
Blocks In Drupal
Blocks In DrupalBlocks In Drupal
Blocks In Drupal
ย 
้ฆ™ๆธฏๅ…ญๅˆๅฝฉ
้ฆ™ๆธฏๅ…ญๅˆๅฝฉ้ฆ™ๆธฏๅ…ญๅˆๅฝฉ
้ฆ™ๆธฏๅ…ญๅˆๅฝฉ
ย 
MySql:Basics
MySql:BasicsMySql:Basics
MySql:Basics
ย 

Viewers also liked

mysqlnd query cache plugin: user-defined storage handler
mysqlnd query cache plugin: user-defined storage handlermysqlnd query cache plugin: user-defined storage handler
mysqlnd query cache plugin: user-defined storage handlerUlf Wendel
ย 
10 things you might not know about MySQL
10 things you might not know about MySQL10 things you might not know about MySQL
10 things you might not know about MySQLJorge Bernal
ย 
Mysql basics1
Mysql basics1Mysql basics1
Mysql basics1Steffy Robert
ย 
Easy MySQL Replication Setup and Troubleshooting
Easy MySQL Replication Setup and TroubleshootingEasy MySQL Replication Setup and Troubleshooting
Easy MySQL Replication Setup and TroubleshootingBob Burgess
ย 
MySQL Tuning using digested slow-logs
MySQL Tuning using digested slow-logsMySQL Tuning using digested slow-logs
MySQL Tuning using digested slow-logsBob Burgess
ย 
Performance Schema in MySQL (Danil Zburivsky)
Performance Schema in MySQL (Danil Zburivsky)Performance Schema in MySQL (Danil Zburivsky)
Performance Schema in MySQL (Danil Zburivsky)Ontico
ย 
The care and feeding of a MySQL database
The care and feeding of a MySQL databaseThe care and feeding of a MySQL database
The care and feeding of a MySQL databaseDave Stokes
ย 
PoC: Using a Group Communication System to improve MySQL Replication HA
PoC: Using a Group Communication System to improve MySQL Replication HAPoC: Using a Group Communication System to improve MySQL Replication HA
PoC: Using a Group Communication System to improve MySQL Replication HAUlf Wendel
ย 
Mysql query optimization
Mysql query optimizationMysql query optimization
Mysql query optimizationBaohua Cai
ย 
MySQL Group Replication
MySQL Group ReplicationMySQL Group Replication
MySQL Group ReplicationUlf Wendel
ย 
Modern MySQL Monitoring and Dashboards.
Modern MySQL Monitoring and Dashboards.Modern MySQL Monitoring and Dashboards.
Modern MySQL Monitoring and Dashboards.Mydbops
ย 
Best Practices in Migrating to MySQL - Part 1
Best Practices in Migrating to MySQL - Part 1Best Practices in Migrating to MySQL - Part 1
Best Practices in Migrating to MySQL - Part 1Ronald Bradford
ย 
Vighnesh_Naik_Resume_DevOps
Vighnesh_Naik_Resume_DevOpsVighnesh_Naik_Resume_DevOps
Vighnesh_Naik_Resume_DevOpsVIGHNESH NAIK
ย 
MySQL For Oracle Developers
MySQL For Oracle DevelopersMySQL For Oracle Developers
MySQL For Oracle DevelopersRonald Bradford
ย 
MySQL Atchitecture and Concepts
MySQL Atchitecture and ConceptsMySQL Atchitecture and Concepts
MySQL Atchitecture and ConceptsTuyen Vuong
ย 

Viewers also liked (19)

mysqlnd query cache plugin: user-defined storage handler
mysqlnd query cache plugin: user-defined storage handlermysqlnd query cache plugin: user-defined storage handler
mysqlnd query cache plugin: user-defined storage handler
ย 
10 things you might not know about MySQL
10 things you might not know about MySQL10 things you might not know about MySQL
10 things you might not know about MySQL
ย 
Mysql basics1
Mysql basics1Mysql basics1
Mysql basics1
ย 
Cb08 sanchez citlali.ppsx
Cb08 sanchez citlali.ppsxCb08 sanchez citlali.ppsx
Cb08 sanchez citlali.ppsx
ย 
Easy MySQL Replication Setup and Troubleshooting
Easy MySQL Replication Setup and TroubleshootingEasy MySQL Replication Setup and Troubleshooting
Easy MySQL Replication Setup and Troubleshooting
ย 
MySQL Tuning using digested slow-logs
MySQL Tuning using digested slow-logsMySQL Tuning using digested slow-logs
MySQL Tuning using digested slow-logs
ย 
Performance Schema in MySQL (Danil Zburivsky)
Performance Schema in MySQL (Danil Zburivsky)Performance Schema in MySQL (Danil Zburivsky)
Performance Schema in MySQL (Danil Zburivsky)
ย 
MySQL database
MySQL databaseMySQL database
MySQL database
ย 
The care and feeding of a MySQL database
The care and feeding of a MySQL databaseThe care and feeding of a MySQL database
The care and feeding of a MySQL database
ย 
PoC: Using a Group Communication System to improve MySQL Replication HA
PoC: Using a Group Communication System to improve MySQL Replication HAPoC: Using a Group Communication System to improve MySQL Replication HA
PoC: Using a Group Communication System to improve MySQL Replication HA
ย 
Mysql query optimization
Mysql query optimizationMysql query optimization
Mysql query optimization
ย 
MySQL Group Replication
MySQL Group ReplicationMySQL Group Replication
MySQL Group Replication
ย 
MySQL DBA
MySQL DBAMySQL DBA
MySQL DBA
ย 
Modern MySQL Monitoring and Dashboards.
Modern MySQL Monitoring and Dashboards.Modern MySQL Monitoring and Dashboards.
Modern MySQL Monitoring and Dashboards.
ย 
Best Practices in Migrating to MySQL - Part 1
Best Practices in Migrating to MySQL - Part 1Best Practices in Migrating to MySQL - Part 1
Best Practices in Migrating to MySQL - Part 1
ย 
Vighnesh_Naik_Resume_DevOps
Vighnesh_Naik_Resume_DevOpsVighnesh_Naik_Resume_DevOps
Vighnesh_Naik_Resume_DevOps
ย 
MySQL For Oracle Developers
MySQL For Oracle DevelopersMySQL For Oracle Developers
MySQL For Oracle Developers
ย 
MYSQL.ppt
MYSQL.pptMYSQL.ppt
MYSQL.ppt
ย 
MySQL Atchitecture and Concepts
MySQL Atchitecture and ConceptsMySQL Atchitecture and Concepts
MySQL Atchitecture and Concepts
ย 

Similar to My sql102

android sqlite
android sqliteandroid sqlite
android sqliteDeepa Rani
ย 
Sq lite module5
Sq lite module5Sq lite module5
Sq lite module5Highervista
ย 
Getting Started with MySQL I
Getting Started with MySQL IGetting Started with MySQL I
Getting Started with MySQL ISankhya_Analytics
ย 
Sql basics
Sql  basicsSql  basics
Sql basicsGenesis Omo
ย 
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)Dave Stokes
ย 
DB2UDB_the_Basics Day2
DB2UDB_the_Basics Day2DB2UDB_the_Basics Day2
DB2UDB_the_Basics Day2Pranav Prakash
ย 
Sq lite
Sq liteSq lite
Sq litevinoth raj
ย 
20201106 hk-py con-mysql-shell
20201106 hk-py con-mysql-shell20201106 hk-py con-mysql-shell
20201106 hk-py con-mysql-shellIvan Ma
ย 
Sq lite module6
Sq lite module6Sq lite module6
Sq lite module6Highervista
ย 
Introduction to Threading in .Net
Introduction to Threading in .NetIntroduction to Threading in .Net
Introduction to Threading in .Netwebhostingguy
ย 
MySQL Without the SQL -- Oh My! Longhorn PHP Conference
MySQL Without the SQL -- Oh My!  Longhorn PHP ConferenceMySQL Without the SQL -- Oh My!  Longhorn PHP Conference
MySQL Without the SQL -- Oh My! Longhorn PHP ConferenceDave Stokes
ย 
RivieraJUG - MySQL 8.0 - What's new for developers.pdf
RivieraJUG - MySQL 8.0 - What's new for developers.pdfRivieraJUG - MySQL 8.0 - What's new for developers.pdf
RivieraJUG - MySQL 8.0 - What's new for developers.pdfFrederic Descamps
ย 
MySQL Baics - Texas Linxufest beginners tutorial May 31st, 2019
MySQL Baics - Texas Linxufest beginners tutorial May 31st, 2019MySQL Baics - Texas Linxufest beginners tutorial May 31st, 2019
MySQL Baics - Texas Linxufest beginners tutorial May 31st, 2019Dave Stokes
ย 
PNWPHP -- What are Databases so &#%-ing Difficult
PNWPHP -- What are Databases so &#%-ing DifficultPNWPHP -- What are Databases so &#%-ing Difficult
PNWPHP -- What are Databases so &#%-ing DifficultDave Stokes
ย 
MySQL 8 Tips and Tricks from Symfony USA 2018, San Francisco
MySQL 8 Tips and Tricks from Symfony USA 2018, San FranciscoMySQL 8 Tips and Tricks from Symfony USA 2018, San Francisco
MySQL 8 Tips and Tricks from Symfony USA 2018, San FranciscoDave Stokes
ย 
MySQL 8 Server Optimization Swanseacon 2018
MySQL 8 Server Optimization Swanseacon 2018MySQL 8 Server Optimization Swanseacon 2018
MySQL 8 Server Optimization Swanseacon 2018Dave Stokes
ย 
Les nouveautรฉs de MySQL 8.0
Les nouveautรฉs de MySQL 8.0Les nouveautรฉs de MySQL 8.0
Les nouveautรฉs de MySQL 8.0Frederic Descamps
ย 
mysqlanditsbasiccommands-150226033905-conversion-gate02.pdf
mysqlanditsbasiccommands-150226033905-conversion-gate02.pdfmysqlanditsbasiccommands-150226033905-conversion-gate02.pdf
mysqlanditsbasiccommands-150226033905-conversion-gate02.pdfpradnyamulay
ย 
Getting Started with MySQL II
Getting Started with MySQL IIGetting Started with MySQL II
Getting Started with MySQL IISankhya_Analytics
ย 

Similar to My sql102 (20)

android sqlite
android sqliteandroid sqlite
android sqlite
ย 
Sq lite module5
Sq lite module5Sq lite module5
Sq lite module5
ย 
Getting Started with MySQL I
Getting Started with MySQL IGetting Started with MySQL I
Getting Started with MySQL I
ย 
Sql basics
Sql  basicsSql  basics
Sql basics
ย 
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
ย 
DB2UDB_the_Basics Day2
DB2UDB_the_Basics Day2DB2UDB_the_Basics Day2
DB2UDB_the_Basics Day2
ย 
7. SQL.pptx
7. SQL.pptx7. SQL.pptx
7. SQL.pptx
ย 
Sq lite
Sq liteSq lite
Sq lite
ย 
20201106 hk-py con-mysql-shell
20201106 hk-py con-mysql-shell20201106 hk-py con-mysql-shell
20201106 hk-py con-mysql-shell
ย 
Sq lite module6
Sq lite module6Sq lite module6
Sq lite module6
ย 
Introduction to Threading in .Net
Introduction to Threading in .NetIntroduction to Threading in .Net
Introduction to Threading in .Net
ย 
MySQL Without the SQL -- Oh My! Longhorn PHP Conference
MySQL Without the SQL -- Oh My!  Longhorn PHP ConferenceMySQL Without the SQL -- Oh My!  Longhorn PHP Conference
MySQL Without the SQL -- Oh My! Longhorn PHP Conference
ย 
RivieraJUG - MySQL 8.0 - What's new for developers.pdf
RivieraJUG - MySQL 8.0 - What's new for developers.pdfRivieraJUG - MySQL 8.0 - What's new for developers.pdf
RivieraJUG - MySQL 8.0 - What's new for developers.pdf
ย 
MySQL Baics - Texas Linxufest beginners tutorial May 31st, 2019
MySQL Baics - Texas Linxufest beginners tutorial May 31st, 2019MySQL Baics - Texas Linxufest beginners tutorial May 31st, 2019
MySQL Baics - Texas Linxufest beginners tutorial May 31st, 2019
ย 
PNWPHP -- What are Databases so &#%-ing Difficult
PNWPHP -- What are Databases so &#%-ing DifficultPNWPHP -- What are Databases so &#%-ing Difficult
PNWPHP -- What are Databases so &#%-ing Difficult
ย 
MySQL 8 Tips and Tricks from Symfony USA 2018, San Francisco
MySQL 8 Tips and Tricks from Symfony USA 2018, San FranciscoMySQL 8 Tips and Tricks from Symfony USA 2018, San Francisco
MySQL 8 Tips and Tricks from Symfony USA 2018, San Francisco
ย 
MySQL 8 Server Optimization Swanseacon 2018
MySQL 8 Server Optimization Swanseacon 2018MySQL 8 Server Optimization Swanseacon 2018
MySQL 8 Server Optimization Swanseacon 2018
ย 
Les nouveautรฉs de MySQL 8.0
Les nouveautรฉs de MySQL 8.0Les nouveautรฉs de MySQL 8.0
Les nouveautรฉs de MySQL 8.0
ย 
mysqlanditsbasiccommands-150226033905-conversion-gate02.pdf
mysqlanditsbasiccommands-150226033905-conversion-gate02.pdfmysqlanditsbasiccommands-150226033905-conversion-gate02.pdf
mysqlanditsbasiccommands-150226033905-conversion-gate02.pdf
ย 
Getting Started with MySQL II
Getting Started with MySQL IIGetting Started with MySQL II
Getting Started with MySQL II
ย 

More from Dave Stokes

Json within a relational database
Json within a relational databaseJson within a relational database
Json within a relational databaseDave Stokes
ย 
Database basics for new-ish developers -- All Things Open October 18th 2021
Database basics for new-ish developers  -- All Things Open October 18th 2021Database basics for new-ish developers  -- All Things Open October 18th 2021
Database basics for new-ish developers -- All Things Open October 18th 2021Dave Stokes
ย 
Php & my sql - how do pdo, mysq-li, and x devapi do what they do
Php & my sql  - how do pdo, mysq-li, and x devapi do what they doPhp & my sql  - how do pdo, mysq-li, and x devapi do what they do
Php & my sql - how do pdo, mysq-li, and x devapi do what they doDave Stokes
ย 
Longhorn PHP - MySQL Indexes, Histograms, Locking Options, and Other Ways to ...
Longhorn PHP - MySQL Indexes, Histograms, Locking Options, and Other Ways to ...Longhorn PHP - MySQL Indexes, Histograms, Locking Options, and Other Ways to ...
Longhorn PHP - MySQL Indexes, Histograms, Locking Options, and Other Ways to ...Dave Stokes
ย 
MySQL 8.0 New Features -- September 27th presentation for Open Source Summit
MySQL 8.0 New Features -- September 27th presentation for Open Source SummitMySQL 8.0 New Features -- September 27th presentation for Open Source Summit
MySQL 8.0 New Features -- September 27th presentation for Open Source SummitDave Stokes
ย 
JavaScript and Friends August 20th, 20201 -- MySQL Shell and JavaScript
JavaScript and Friends August 20th, 20201 -- MySQL Shell and JavaScriptJavaScript and Friends August 20th, 20201 -- MySQL Shell and JavaScript
JavaScript and Friends August 20th, 20201 -- MySQL Shell and JavaScriptDave Stokes
ย 
Open Source World June '21 -- JSON Within a Relational Database
Open Source World June '21 -- JSON Within a Relational DatabaseOpen Source World June '21 -- JSON Within a Relational Database
Open Source World June '21 -- JSON Within a Relational DatabaseDave Stokes
ย 
Dutch PHP Conference 2021 - MySQL Indexes and Histograms
Dutch PHP Conference 2021 - MySQL Indexes and HistogramsDutch PHP Conference 2021 - MySQL Indexes and Histograms
Dutch PHP Conference 2021 - MySQL Indexes and HistogramsDave Stokes
ย 
Validating JSON -- Percona Live 2021 presentation
Validating JSON -- Percona Live 2021 presentationValidating JSON -- Percona Live 2021 presentation
Validating JSON -- Percona Live 2021 presentationDave Stokes
ย 
Midwest PHP Presentation - New MSQL Features
Midwest PHP Presentation - New MSQL FeaturesMidwest PHP Presentation - New MSQL Features
Midwest PHP Presentation - New MSQL FeaturesDave Stokes
ย 
Data Love Conference - Window Functions for Database Analytics
Data Love Conference - Window Functions for Database AnalyticsData Love Conference - Window Functions for Database Analytics
Data Love Conference - Window Functions for Database AnalyticsDave Stokes
ย 
Open Source 1010 and Quest InSync presentations March 30th, 2021 on MySQL Ind...
Open Source 1010 and Quest InSync presentations March 30th, 2021 on MySQL Ind...Open Source 1010 and Quest InSync presentations March 30th, 2021 on MySQL Ind...
Open Source 1010 and Quest InSync presentations March 30th, 2021 on MySQL Ind...Dave Stokes
ย 
Confoo 2021 -- MySQL New Features
Confoo 2021 -- MySQL New FeaturesConfoo 2021 -- MySQL New Features
Confoo 2021 -- MySQL New FeaturesDave Stokes
ย 
Confoo 2021 - MySQL Indexes & Histograms
Confoo 2021 - MySQL Indexes & HistogramsConfoo 2021 - MySQL Indexes & Histograms
Confoo 2021 - MySQL Indexes & HistogramsDave Stokes
ย 
Datacon LA - MySQL without the SQL - Oh my!
Datacon LA - MySQL without the SQL - Oh my! Datacon LA - MySQL without the SQL - Oh my!
Datacon LA - MySQL without the SQL - Oh my! Dave Stokes
ย 
MySQL Replication Update - DEbconf 2020 presentation
MySQL Replication Update - DEbconf 2020 presentationMySQL Replication Update - DEbconf 2020 presentation
MySQL Replication Update - DEbconf 2020 presentationDave Stokes
ย 
MySQL 8.0 Operational Changes
MySQL 8.0 Operational ChangesMySQL 8.0 Operational Changes
MySQL 8.0 Operational ChangesDave Stokes
ย 
cPanel now supports MySQL 8.0 - My Top Seven Features
cPanel now supports MySQL 8.0 - My Top Seven FeaturescPanel now supports MySQL 8.0 - My Top Seven Features
cPanel now supports MySQL 8.0 - My Top Seven FeaturesDave Stokes
ย 
A Step by Step Introduction to the MySQL Document Store
A Step by Step Introduction to the MySQL Document StoreA Step by Step Introduction to the MySQL Document Store
A Step by Step Introduction to the MySQL Document StoreDave Stokes
ย 
Discover The Power of NoSQL + MySQL with MySQL
Discover The Power of NoSQL + MySQL with MySQLDiscover The Power of NoSQL + MySQL with MySQL
Discover The Power of NoSQL + MySQL with MySQLDave Stokes
ย 

More from Dave Stokes (20)

Json within a relational database
Json within a relational databaseJson within a relational database
Json within a relational database
ย 
Database basics for new-ish developers -- All Things Open October 18th 2021
Database basics for new-ish developers  -- All Things Open October 18th 2021Database basics for new-ish developers  -- All Things Open October 18th 2021
Database basics for new-ish developers -- All Things Open October 18th 2021
ย 
Php & my sql - how do pdo, mysq-li, and x devapi do what they do
Php & my sql  - how do pdo, mysq-li, and x devapi do what they doPhp & my sql  - how do pdo, mysq-li, and x devapi do what they do
Php & my sql - how do pdo, mysq-li, and x devapi do what they do
ย 
Longhorn PHP - MySQL Indexes, Histograms, Locking Options, and Other Ways to ...
Longhorn PHP - MySQL Indexes, Histograms, Locking Options, and Other Ways to ...Longhorn PHP - MySQL Indexes, Histograms, Locking Options, and Other Ways to ...
Longhorn PHP - MySQL Indexes, Histograms, Locking Options, and Other Ways to ...
ย 
MySQL 8.0 New Features -- September 27th presentation for Open Source Summit
MySQL 8.0 New Features -- September 27th presentation for Open Source SummitMySQL 8.0 New Features -- September 27th presentation for Open Source Summit
MySQL 8.0 New Features -- September 27th presentation for Open Source Summit
ย 
JavaScript and Friends August 20th, 20201 -- MySQL Shell and JavaScript
JavaScript and Friends August 20th, 20201 -- MySQL Shell and JavaScriptJavaScript and Friends August 20th, 20201 -- MySQL Shell and JavaScript
JavaScript and Friends August 20th, 20201 -- MySQL Shell and JavaScript
ย 
Open Source World June '21 -- JSON Within a Relational Database
Open Source World June '21 -- JSON Within a Relational DatabaseOpen Source World June '21 -- JSON Within a Relational Database
Open Source World June '21 -- JSON Within a Relational Database
ย 
Dutch PHP Conference 2021 - MySQL Indexes and Histograms
Dutch PHP Conference 2021 - MySQL Indexes and HistogramsDutch PHP Conference 2021 - MySQL Indexes and Histograms
Dutch PHP Conference 2021 - MySQL Indexes and Histograms
ย 
Validating JSON -- Percona Live 2021 presentation
Validating JSON -- Percona Live 2021 presentationValidating JSON -- Percona Live 2021 presentation
Validating JSON -- Percona Live 2021 presentation
ย 
Midwest PHP Presentation - New MSQL Features
Midwest PHP Presentation - New MSQL FeaturesMidwest PHP Presentation - New MSQL Features
Midwest PHP Presentation - New MSQL Features
ย 
Data Love Conference - Window Functions for Database Analytics
Data Love Conference - Window Functions for Database AnalyticsData Love Conference - Window Functions for Database Analytics
Data Love Conference - Window Functions for Database Analytics
ย 
Open Source 1010 and Quest InSync presentations March 30th, 2021 on MySQL Ind...
Open Source 1010 and Quest InSync presentations March 30th, 2021 on MySQL Ind...Open Source 1010 and Quest InSync presentations March 30th, 2021 on MySQL Ind...
Open Source 1010 and Quest InSync presentations March 30th, 2021 on MySQL Ind...
ย 
Confoo 2021 -- MySQL New Features
Confoo 2021 -- MySQL New FeaturesConfoo 2021 -- MySQL New Features
Confoo 2021 -- MySQL New Features
ย 
Confoo 2021 - MySQL Indexes & Histograms
Confoo 2021 - MySQL Indexes & HistogramsConfoo 2021 - MySQL Indexes & Histograms
Confoo 2021 - MySQL Indexes & Histograms
ย 
Datacon LA - MySQL without the SQL - Oh my!
Datacon LA - MySQL without the SQL - Oh my! Datacon LA - MySQL without the SQL - Oh my!
Datacon LA - MySQL without the SQL - Oh my!
ย 
MySQL Replication Update - DEbconf 2020 presentation
MySQL Replication Update - DEbconf 2020 presentationMySQL Replication Update - DEbconf 2020 presentation
MySQL Replication Update - DEbconf 2020 presentation
ย 
MySQL 8.0 Operational Changes
MySQL 8.0 Operational ChangesMySQL 8.0 Operational Changes
MySQL 8.0 Operational Changes
ย 
cPanel now supports MySQL 8.0 - My Top Seven Features
cPanel now supports MySQL 8.0 - My Top Seven FeaturescPanel now supports MySQL 8.0 - My Top Seven Features
cPanel now supports MySQL 8.0 - My Top Seven Features
ย 
A Step by Step Introduction to the MySQL Document Store
A Step by Step Introduction to the MySQL Document StoreA Step by Step Introduction to the MySQL Document Store
A Step by Step Introduction to the MySQL Document Store
ย 
Discover The Power of NoSQL + MySQL with MySQL
Discover The Power of NoSQL + MySQL with MySQLDiscover The Power of NoSQL + MySQL with MySQL
Discover The Power of NoSQL + MySQL with MySQL
ย 

Recently uploaded

Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
ย 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
ย 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
ย 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
ย 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
ย 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
ย 
๐Ÿฌ The future of MySQL is Postgres ๐Ÿ˜
๐Ÿฌ  The future of MySQL is Postgres   ๐Ÿ˜๐Ÿฌ  The future of MySQL is Postgres   ๐Ÿ˜
๐Ÿฌ The future of MySQL is Postgres ๐Ÿ˜RTylerCroy
ย 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
ย 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
ย 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
ย 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
ย 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
ย 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service ๐Ÿธ 8923113531 ๐ŸŽฐ Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service ๐Ÿธ 8923113531 ๐ŸŽฐ Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service ๐Ÿธ 8923113531 ๐ŸŽฐ Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service ๐Ÿธ 8923113531 ๐ŸŽฐ Avail...gurkirankumar98700
ย 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
ย 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
ย 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
ย 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
ย 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
ย 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
ย 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
ย 

Recently uploaded (20)

Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
ย 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
ย 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
ย 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
ย 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
ย 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
ย 
๐Ÿฌ The future of MySQL is Postgres ๐Ÿ˜
๐Ÿฌ  The future of MySQL is Postgres   ๐Ÿ˜๐Ÿฌ  The future of MySQL is Postgres   ๐Ÿ˜
๐Ÿฌ The future of MySQL is Postgres ๐Ÿ˜
ย 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
ย 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
ย 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
ย 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
ย 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
ย 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service ๐Ÿธ 8923113531 ๐ŸŽฐ Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service ๐Ÿธ 8923113531 ๐ŸŽฐ Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service ๐Ÿธ 8923113531 ๐ŸŽฐ Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service ๐Ÿธ 8923113531 ๐ŸŽฐ Avail...
ย 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
ย 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
ย 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
ย 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
ย 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
ย 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
ย 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
ย 

My sql102

  • 1. MySQL 102 MySQL 102 is the second part of a presentation to be preceded by MySQL 101 and covers material that will build on the previous presentation. 1 Http://slideshare.net/davestokes/presentations
  • 2. Agenda โž” Workbench โž” User Accounts & Privileges โž” Tables and Databases โž” Views โž” Stored Routines/Procedures โž” Questions and Answers โž” Replication (after a break) David.Stokes@Oracle.com @stoker 2
  • 3. Workbench ๎€Œ FREE ๎€Œ http://dev.mysql.com/downloads/ ๎€Œ Three tools in one ๎€Œ Query Tool ๎€Œ Admin Tool ๎€Œ Entity Relationship Mapper ๎€Œ Scripts available for setting up replication, fail over and more http://dev.mysql.com/doc/refman/5.5/en/getting-mysql.html 3
  • 4. Did I mention free? http://dev.mysql.com/downloads/workbench/ 4
  • 5. Admin 5
  • 8. Know whom can do what ๎€Œ We have four accounts ๎€Œ Anonymous (%) ๎€Œ ODBC ๎€Œ joe ๎€Œ root ๎€Œ ODBC and joe can login from any host while root and anonymous are local host only 8
  • 9. Joe's Info 'joe' can connect to the mysqld server from any host. Note he does not have a password which can be a serious security concern. 9 htallation.html
  • 11. Joe's Limits Account Limits can be used to throttle user access. 11
  • 13. Easier than ... GRANT INSERT, UPDATE, SELECT ON world.* To 'joe'@'%'; FLUSH PRIVILEGES; 13
  • 14. Tables & Databases Databases contain tables, which are used for storing data. Databases also contain objects such as stored routines or triggers. โ€“ MySQl 5.0 Certification Guide httphtml 14
  • 15. 1. CREATE DATABASE foo 2. (magic) 3. mkdir foo ๎€Œ CREATE DATBASE will create a directory to house .frm files ๎€Œ InnoDB tables will have table spaces for data & indexes ๎€Œ MyISQM can also have .MYD and .MYI files for data and indexes 15
  • 16. Databases ๎€Œ db.opt will hold info on character sets, collations. ๎€Œ Databases can hold zero or more tables plus objects like view, triggers ๎€Œ Databases can not be nested 16
  • 17. CREATE a DATABASE, aka SCHEMA ๎€Œ Use Workbench to create a schema 17
  • 18. Create 'demo' Here we create a schema named 'demo' with UTF8 character set and the 'general' 'case insensitive' collation. 18
  • 19. Review โ€“ ๎€Œ Workbench will show the statement used to create the schema. ๎€Œ Or you could type in the SQL by hand. 19
  • 20. We have 'demo' ๎€Œ Double click on demo to expand the list of contents 20
  • 21. CREATE a table ๎€Œ Now we can create a table in the 'demo' schema 21
  • 22. Creating a Table Create a table named stuff with a column named member_id that is NOT NULL, AUTOINCREMENT, UNSIGNED and a PRIMARY KEY 22
  • 23. Review the SQL We can see the SQL that is about to be executed to create the table. 23
  • 24. Double Check ๎€Œ Any problems will be show here as well as success 24
  • 25. SHOW CREATE TABLE ๎€Œ Note that INT(10) means 10 characters will be shown for output. INT(2) will show two places of data by default but still holds upto 2147483647 signed or 4294967295 unsigned. 25
  • 26. After adding two more columns For the sake of brevity, two more columns have been added for name and email, both are stup to hold CHAR data 26
  • 27. Add some data ๎€Œ Note we do not have member_id mentioned. 27
  • 28. Select data from stuff Here we select data from the table. Note that member_id was automatically filled in for this record. 28
  • 29. Add a few more records Here a few more records have been added and the member_id has again has been incremented and inserted. 29
  • 30. Triggers ๎€Œ Triggers are 'fired' in response to a an SQL statement. ๎€Œ They can happen before OR after an INSERT, UPDATE, or DELETE event. ๎€Œ ๎€Œ They can be used to check values, sum data, etc. ๎€Œ You may not want 'logic' in your database and prefer to have it in the application level. 30
  • 31. Boss: We need to track previous email addresses ๎€Œ Lets track previous email address by placing them in a new column creatively called oldemail. 31
  • 33. Did you catch the mistake? The previous trigger had a serious logical flaw. Take a look at it and see if you can spot it. Hint: Is the email the only thing that will ever get updated? 33
  • 34. VIEWS ๎€Œ Views are stored queries that when invoked produce a result set. A view acts as a virtual table. ๎€Œ Can be used to hide table and column names from programmers. ๎€Œ Can be used to gather information from many tables into one view for simpler access (PHB protector) ๎€Œ Not materialized 34
  • 35. Create a VIEW, use as a table ๎€Œ SELECT * from get_stuffg ๎€Œ SELECT Customer from get_stuffg 35
  • 36. Stored Routines Stored Procedures Stored procedures and Stored Routines take zero or more arguments. A Stored Procedure can pass back values through output variables or result sets. A function must output exactly ONE scalar variable. MySQL Follows the ISO:2003 SQL standard syntax for stored routines. And theses two subjects are not for newbies. 36