SlideShare a Scribd company logo
SQL/200

                     SQL Programming

            Workshop 3 – Modifying Data, Managing the
                           Database

Bookstore                   SQL200 Module 3             1
SQL200 Contact Information



            P.O. Box 6142
            Laguna Niguel, CA 92607
            949-489-1472
            http://www.d2associates.com
            slides.1@dhdursoassociates.com
            Copyright 2001-2009. All rights reserved.


Bookstore                             SQL200 Module 3   2
SQL200 Module 3
•   Part 1 – Modifying Data
    Part 2 – Managing Database Structures
•
•   Part 3 – Creating Views and Indexes
•   Part 4 -- Security




Bookstore          SQL200 Module 3          3
SQL/200

            SQL Programming

            Part 1 – Modifying Data


Bookstore          SQL200 Module 3    4
Relational Database with constraints (from text)




Bookstore                 SQL200 Module 3                  5
Data Modification Statements

            • Insert

            • Update

            • Delete



Bookstore          SQL200 Module 3   6
Data Modification Statements

            • End-user rarely sees these
              statements

            • Application developer prepares
              these statements “behind the
              scenes” based on forms filled out
              by user



Bookstore                  SQL200 Module 3        7
Insert
• Adds new rows to an existing table
• Two forms:
      – Single Row
      – Multi-Row




Bookstore            SQL200 Module 3   8
Single Row Insert


            Basic Syntax:
            Insert [into] <table-name>
            Values (<value-list>)




Bookstore                SQL200 Module 3   9
Single Row Insert

         Basic Example:
         insert into sources(source_numb,
         source_name, source_street)
         values(22,'Specialty Books',
         'Canal Street')




Bookstore             SQL200 Module 3       10
Insert Statement




Bookstore        SQL200 Module 3   11
Sources table after Insert




Bookstore            SQL200 Module 3     12
Multi-row Insert
            Basic Syntax:


            Insert [into] <table-name>
            Select <select-statement>


            We will do this after creating a new
            table later in this module
Bookstore                 SQL200 Module 3          13
Update
• Updates fields in an existing row

   Basic Syntax:
   Update <table-name>
   Set <field1> = new value, <field2> = new value,
   …
   Where <selection-criteria>
Bookstore             SQL200 Module 3                14
Update
• Increase Ingram prices by 10%

   Example:
   Update books
   Set retail_price = retail_price
   *1.10
   Where source_numb = 1
Bookstore         SQL200 Module 3    15
Ingram Book Prices before Update




Bookstore       SQL200 Module 3       16
Ingram Book Prices after Update




Bookstore   SQL200 Module 3   17
After update in MS Access




Bookstore                SQL200 Module 3   18
Delete
• Deletes one or more rows

            Basic Syntax:


            Delete from <table-name>
            Where <selection-criteria>


Bookstore                   SQL200 Module 3   19
Delete

         Example:


         Delete from sources
         Where source_numb = 22


Bookstore             SQL200 Module 3   20
Delete




Bookstore   SQL200 Module 3   21
Sources table after Delete




Bookstore             SQL200 Module 3    22
Delete and Referential Integrity
• Can affect referential integrity when deleting a
  “parent” row
• Can do following with child…
      –     Cascade: delete the child row
      –     Set null: set the child’s foreign key null
      –     Set default: as above but to default value
      –     No action: don’t allow delete of parent row
• Referential integrity can be established when
  creating or modifying table structures which we
  will look at later in the class

Bookstore                      SQL200 Module 3            23
SQL/200

                  SQL Programming

            Part 2– Managing Database Structures


Bookstore                 SQL200 Module 3          24
Schemas
• Logical view of a database; sort of a “sub-
  database” – we will not cover these in this module
  or…
      – Catalogs
      – Clusters
      – Domains (somewhat like a user defined datatype)
• These topics are highly dependent upon the vendor
  DBMS and installation practices


Bookstore                 SQL200 Module 3                 25
Tables

            • Base tables
            • Temporary tables
              – Local (or module scope)
              – Global (session scope)




Bookstore               SQL200 Module 3   26
Creating Tables
• Use create statement
• Specify:
      – Columns with data types and column
        constraints
      – Table constraints
            • Foreign key references
            • Primary key designation



Bookstore                    SQL200 Module 3   27
Temporary Tables

   Basic syntax:
   Create [global] temporary table <table-name>
   <rest of statement as for normal create>


   Note: SQL Server uses a different syntax. Put a
   #in front of the table name as in #mytable.
   Access doesn’t have true temporary tables.
Bookstore              SQL200 Module 3               28
Data Types
• Int – integers or whole numbers
      – Ex: how_many int
• Char – fixed length fields
      – Ex: state char(2)
• Varchar/Varchar2 – variable length fields
      – Ex: address varchar(35)
• Money – money field; same as MS Access
  currency
• Date/Datetime – date and time
• And many others – see documentation or Help
Bookstore                   SQL200 Module 3     29
Create Table
     Basic syntax:
     Create table <table-name>
     <column1> <datatype> <constraints>
     ,.. <column1> <datatype> <constraints>
     …
     <table constraints>
     Note: often preceded by a drop
Bookstore                  SQL200 Module 3    30
Column Constraints
•   Primary key
    Not NULL
•
•   CHECK clause
•   Default
    Unique
•



Bookstore          SQL200 Module 3   31
Table Constraints
• Primary Key
• Foreign Key
• Compare fields against each other. I.e.
  ship_date >= order_date




Bookstore          SQL200 Module 3          32
But first – the Drop Statement
• Deletes a database “object”
      –     Drop table <table-name>
      –     Drop view <view-name>
      –     Drop index <index-name>
      –     Drop domain <domain-name>




Bookstore                SQL200 Module 3   33
Create Table
       Example 1: Create a summary table
       Create table summary(
       isbn varchar(20) primary key,
       How_many int check (how_many >= 0),
       Constraint isbn_fk
       Foreign key (isbn) references
       books(isbn)
       )
Bookstore             SQL200 Module 3        34
Create Summary Table




Bookstore          SQL200 Module 3   35
Constraints on Summary Table




Bookstore     SQL200 Module 3     36
Multi-row Insert


            Basic Syntax:


            Insert [into] <table-name>
            Select <select-statement>



Bookstore                SQL200 Module 3   37
Multi-row Insert
            Basic Example: (store # times each
            book ordered)


            Insert into
            summary(isbn, how_many)
            Select isbn, count(*)
            From orderlines
            Group by isbn;
Bookstore                   SQL200 Module 3      38
Multi-row Insert




Bookstore        SQL200 Module 3   39
After multi-row insert in MS Access




Bookstore               SQL200 Module 3   40
SQL/200

                  SQL Programming

       Part 3 – Creating Views and Indexes, Modifying
                          Structures

Bookstore                 SQL200 Module 3               41
Views
• Think of a view as a named query wherein
  the definition is stored in the database
• Can be read like a table
• Some are updateable




Bookstore        SQL200 Module 3             42
Views

   Basic syntax:
   Create view <view-name> (<column-list>)
   As
   <select statement>



Bookstore               SQL200 Module 3      43
Creating a View




Bookstore       SQL200 Module 3   44
Using Views
• Can be used like a table subject to various
  limitations
      – Cannot insert into grouped queries, etc.
      – Etc.
• Sample syntax:
            select column-list
            from employee_view


Bookstore                 SQL200 Module 3          45
Using a View




Bookstore      SQL200 Module 3   46
Indexes
• Used to speed searches, joins, etc.
• Placed on:
      – primary and foreign keys
      – Secondary keys
• In commercial practice often managed by
  DBA’s for large databases



Bookstore              SQL200 Module 3      47
Indexes
    Basic syntax:


    Create [unique] index <index-name>
    On <table-name> (field-name> [desc])


    Note: can place index on a composite key; ex: state and
    city
Bookstore                 SQL200 Module 3                     48
Indexes

      Basic example:


      create index state_inx
      on customers(customer_state)



Bookstore              SQL200 Module 3   49
After indexing on customer_state




Bookstore              SQL200 Module 3   50
Customers table with index




Bookstore         SQL200 Module 3    51
State_inx in Oracle




Bookstore         SQL200 Module 3   52
Modifying a Table Design
• Applies to tables
• Use ALTER statement
      –     Add columns
      –     Delete columns
      –     Rename columns
      –     Add column constraints
      –     Add table constraints


Bookstore                  SQL200 Module 3   53
Modifying a Table Design
      Basic syntax:
      Alter <table-name>
      Add <field-name>,
      Add <table-constraint>,
      Modify <field-name>
      Etc.

Bookstore               SQL200 Module 3   54
Modify a Table Design

        Example: add a phone number field


        alter table publishers
        add phone char(12);




Bookstore               SQL200 Module 3     55
After alter publishers table




Bookstore               SQL200 Module 3   56
SQL/200

            SQL Programming

              Part 4 – Security


Bookstore         SQL200 Module 3   57
Security
•   Specifics can vary by product
    Access: workgroup administrator
•
•   SQL Server: users, groups
•   Oracle: users, roles




Bookstore          SQL200 Module 3    58
Security
• Important DBA function
      – Beyond scope of this course
      – Typically controlled through the Enterprise
        Managers
• In commercial practice application security
  frequently controlled via own login and a
  “users” table or similar


Bookstore               SQL200 Module 3               59
SQL Security Statements


              • Grant
              • Revoke
              • Deny




Bookstore            SQL200 Module 3   60
Grant

   Syntax:


   Grant <access-right> [with grant option]
   On <object> to <user>


Bookstore           SQL200 Module 3           61
Access Rights
•   Select
    Update
•
•   Insert
•   Delete
    References
•
•   All privileges


Bookstore            SQL200 Module 3   62
Grant

     Example:


     Grant update
     On employees to ddurso



Bookstore           SQL200 Module 3   63
Revoke
• Revokes the rights
• Syntax similar to grant




                                    [end module]
Bookstore         SQL200 Module 3                  64

More Related Content

What's hot

The Ring programming language version 1.10 book - Part 36 of 212
The Ring programming language version 1.10 book - Part 36 of 212The Ring programming language version 1.10 book - Part 36 of 212
The Ring programming language version 1.10 book - Part 36 of 212
Mahmoud Samir Fayed
 
Lab
LabLab
Sql server T-sql basics ppt-3
Sql server T-sql basics  ppt-3Sql server T-sql basics  ppt-3
Sql server T-sql basics ppt-3
Vibrant Technologies & Computers
 
Dbms practical list
Dbms practical listDbms practical list
Dbms practical list
RajSingh734307
 
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowDBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
Alex Zaballa
 
Schema webinar
Schema webinarSchema webinar
Schema webinar
Gary Sherman
 
SQL Tutorial for BCA-2
SQL Tutorial for BCA-2SQL Tutorial for BCA-2
SQL Tutorial for BCA-2
Raj vardhan
 
The Ring programming language version 1.5.1 book - Part 26 of 180
The Ring programming language version 1.5.1 book - Part 26 of 180The Ring programming language version 1.5.1 book - Part 26 of 180
The Ring programming language version 1.5.1 book - Part 26 of 180
Mahmoud Samir Fayed
 
Blocks In Drupal
Blocks In DrupalBlocks In Drupal
Blocks In Drupal
guest6fb0ef
 
Sql presentation 1 by chandan
Sql presentation 1 by chandanSql presentation 1 by chandan
Sql presentation 1 by chandan
Linux international training Center
 
Best sql plsql material
Best sql plsql materialBest sql plsql material
Best sql plsql material
pitchaiah yechuri
 
The Ring programming language version 1.2 book - Part 17 of 84
The Ring programming language version 1.2 book - Part 17 of 84The Ring programming language version 1.2 book - Part 17 of 84
The Ring programming language version 1.2 book - Part 17 of 84
Mahmoud Samir Fayed
 
Sql views
Sql viewsSql views
Sql views
arshid045
 
MySQL and its basic commands
MySQL and its basic commandsMySQL and its basic commands
MySQL and its basic commands
Bwsrang Basumatary
 

What's hot (19)

The Ring programming language version 1.10 book - Part 36 of 212
The Ring programming language version 1.10 book - Part 36 of 212The Ring programming language version 1.10 book - Part 36 of 212
The Ring programming language version 1.10 book - Part 36 of 212
 
Lab
LabLab
Lab
 
Sql server T-sql basics ppt-3
Sql server T-sql basics  ppt-3Sql server T-sql basics  ppt-3
Sql server T-sql basics ppt-3
 
Dbms practical list
Dbms practical listDbms practical list
Dbms practical list
 
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowDBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
 
Les11 Including Constraints
Les11 Including ConstraintsLes11 Including Constraints
Les11 Including Constraints
 
Schema webinar
Schema webinarSchema webinar
Schema webinar
 
SQL Tutorial for BCA-2
SQL Tutorial for BCA-2SQL Tutorial for BCA-2
SQL Tutorial for BCA-2
 
The Ring programming language version 1.5.1 book - Part 26 of 180
The Ring programming language version 1.5.1 book - Part 26 of 180The Ring programming language version 1.5.1 book - Part 26 of 180
The Ring programming language version 1.5.1 book - Part 26 of 180
 
Schema201 webinar
Schema201 webinarSchema201 webinar
Schema201 webinar
 
Blocks In Drupal
Blocks In DrupalBlocks In Drupal
Blocks In Drupal
 
Sql presentation 1 by chandan
Sql presentation 1 by chandanSql presentation 1 by chandan
Sql presentation 1 by chandan
 
Best sql plsql material
Best sql plsql materialBest sql plsql material
Best sql plsql material
 
Dbms record
Dbms recordDbms record
Dbms record
 
The Ring programming language version 1.2 book - Part 17 of 84
The Ring programming language version 1.2 book - Part 17 of 84The Ring programming language version 1.2 book - Part 17 of 84
The Ring programming language version 1.2 book - Part 17 of 84
 
Navicat en
Navicat enNavicat en
Navicat en
 
Sql views
Sql viewsSql views
Sql views
 
MySQL and its basic commands
MySQL and its basic commandsMySQL and its basic commands
MySQL and its basic commands
 
SQL
SQLSQL
SQL
 

Viewers also liked

AMP110 Microsoft Access Macros
AMP110 Microsoft Access MacrosAMP110 Microsoft Access Macros
AMP110 Microsoft Access Macros
Dan D'Urso
 
Muziekdigitaal Taggerfm Pitch 091027
Muziekdigitaal Taggerfm Pitch 091027Muziekdigitaal Taggerfm Pitch 091027
Muziekdigitaal Taggerfm Pitch 091027Tim Rootsaert
 
Muziekdigitaal Mike Belgium Pitch 091028
Muziekdigitaal Mike Belgium Pitch 091028Muziekdigitaal Mike Belgium Pitch 091028
Muziekdigitaal Mike Belgium Pitch 091028Tim Rootsaert
 
Tagger.fm Muziek Digitaal 091028
Tagger.fm Muziek Digitaal 091028Tagger.fm Muziek Digitaal 091028
Tagger.fm Muziek Digitaal 091028Tim Rootsaert
 
Profit Hunters
Profit HuntersProfit Hunters
Profit Hunters
Cory Rhodes
 
Il Mostro Di Cogne
Il Mostro Di CogneIl Mostro Di Cogne
Il Mostro Di Cogne
F R
 
Roma 2014
Roma 2014Roma 2014
Creating a Photo Story With Soundslides
Creating a Photo Story With SoundslidesCreating a Photo Story With Soundslides
Creating a Photo Story With Soundslides
Ryan Thornburg
 
AVB201.1 Microsoft Access VBA Module 1
AVB201.1 Microsoft Access VBA Module 1AVB201.1 Microsoft Access VBA Module 1
AVB201.1 Microsoft Access VBA Module 1
Dan D'Urso
 
AIN100
AIN100AIN100
AIN100
Dan D'Urso
 
Farrah bostic 5for5
Farrah bostic 5for5Farrah bostic 5for5
Farrah bostic 5for5
The Difference Engine
 
Microsoft access self joins
Microsoft access self joinsMicrosoft access self joins
Microsoft access self joins
Dan D'Urso
 
電動車及儲能系統產業發展-創業懶人包-青年創業及圓夢網
電動車及儲能系統產業發展-創業懶人包-青年創業及圓夢網電動車及儲能系統產業發展-創業懶人包-青年創業及圓夢網
電動車及儲能系統產業發展-創業懶人包-青年創業及圓夢網
RICK Lin
 
Thom Point of View on Segmentation
Thom Point of View on SegmentationThom Point of View on Segmentation
Thom Point of View on Segmentation
PieterDuron
 
My Print Portfolio
My Print PortfolioMy Print Portfolio
My Print Portfolio
beth7865
 
SQL200.1 Module 1
SQL200.1 Module 1SQL200.1 Module 1
SQL200.1 Module 1
Dan D'Urso
 
¿Somos animales?
¿Somos animales?¿Somos animales?
¿Somos animales?
JAVIER ALSINA GONZALEZ
 

Viewers also liked (20)

AMP110 Microsoft Access Macros
AMP110 Microsoft Access MacrosAMP110 Microsoft Access Macros
AMP110 Microsoft Access Macros
 
PREMIS FOTOGRAFIA FILOSOFICA
PREMIS FOTOGRAFIA FILOSOFICAPREMIS FOTOGRAFIA FILOSOFICA
PREMIS FOTOGRAFIA FILOSOFICA
 
Muziekdigitaal Taggerfm Pitch 091027
Muziekdigitaal Taggerfm Pitch 091027Muziekdigitaal Taggerfm Pitch 091027
Muziekdigitaal Taggerfm Pitch 091027
 
Muziekdigitaal Mike Belgium Pitch 091028
Muziekdigitaal Mike Belgium Pitch 091028Muziekdigitaal Mike Belgium Pitch 091028
Muziekdigitaal Mike Belgium Pitch 091028
 
Tagger.fm Muziek Digitaal 091028
Tagger.fm Muziek Digitaal 091028Tagger.fm Muziek Digitaal 091028
Tagger.fm Muziek Digitaal 091028
 
Profit Hunters
Profit HuntersProfit Hunters
Profit Hunters
 
Il Mostro Di Cogne
Il Mostro Di CogneIl Mostro Di Cogne
Il Mostro Di Cogne
 
Roma 2014
Roma 2014Roma 2014
Roma 2014
 
Creating a Photo Story With Soundslides
Creating a Photo Story With SoundslidesCreating a Photo Story With Soundslides
Creating a Photo Story With Soundslides
 
AVB201.1 Microsoft Access VBA Module 1
AVB201.1 Microsoft Access VBA Module 1AVB201.1 Microsoft Access VBA Module 1
AVB201.1 Microsoft Access VBA Module 1
 
AIN100
AIN100AIN100
AIN100
 
13 concurs d'aforismes
13 concurs d'aforismes13 concurs d'aforismes
13 concurs d'aforismes
 
Farrah bostic 5for5
Farrah bostic 5for5Farrah bostic 5for5
Farrah bostic 5for5
 
Microsoft access self joins
Microsoft access self joinsMicrosoft access self joins
Microsoft access self joins
 
電動車及儲能系統產業發展-創業懶人包-青年創業及圓夢網
電動車及儲能系統產業發展-創業懶人包-青年創業及圓夢網電動車及儲能系統產業發展-創業懶人包-青年創業及圓夢網
電動車及儲能系統產業發展-創業懶人包-青年創業及圓夢網
 
Thom Point of View on Segmentation
Thom Point of View on SegmentationThom Point of View on Segmentation
Thom Point of View on Segmentation
 
My Print Portfolio
My Print PortfolioMy Print Portfolio
My Print Portfolio
 
SQL200.1 Module 1
SQL200.1 Module 1SQL200.1 Module 1
SQL200.1 Module 1
 
¿Somos animales?
¿Somos animales?¿Somos animales?
¿Somos animales?
 
Filoarnaucadell
Filoarnaucadell Filoarnaucadell
Filoarnaucadell
 

Similar to SQL200.3 Module 3

SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3
SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3
SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3
Dan D'Urso
 
SQL212.3 Introduction to SQL using Oracle Module 3
SQL212.3 Introduction to SQL using Oracle Module 3SQL212.3 Introduction to SQL using Oracle Module 3
SQL212.3 Introduction to SQL using Oracle Module 3
Dan D'Urso
 
SQL202.2 Accelerated Introduction to SQL Using SQL Server Module 2
SQL202.2 Accelerated Introduction to SQL Using SQL Server Module 2SQL202.2 Accelerated Introduction to SQL Using SQL Server Module 2
SQL202.2 Accelerated Introduction to SQL Using SQL Server Module 2
Dan D'Urso
 
SQL202.1 Accelerated Introduction to SQL Using SQL Server Module 1
SQL202.1 Accelerated Introduction to SQL Using SQL Server Module 1SQL202.1 Accelerated Introduction to SQL Using SQL Server Module 1
SQL202.1 Accelerated Introduction to SQL Using SQL Server Module 1
Dan D'Urso
 
Bn1037 demo oracle sql
Bn1037 demo  oracle sqlBn1037 demo  oracle sql
Bn1037 demo oracle sql
conline training
 
SQL Server 2008 New Features
SQL Server 2008 New FeaturesSQL Server 2008 New Features
SQL Server 2008 New Features
Dan English
 
SQL302 Intermediate SQL Workshop 3
SQL302 Intermediate SQL Workshop 3SQL302 Intermediate SQL Workshop 3
SQL302 Intermediate SQL Workshop 3
Dan D'Urso
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAsOracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAs
Alex Zaballa
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c  - New Features for Developers and DBAsOracle Database 12c  - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAs
Alex Zaballa
 
SQL212.1 Introduction to SQL using Oracle Module 1
SQL212.1 Introduction to SQL using Oracle Module 1SQL212.1 Introduction to SQL using Oracle Module 1
SQL212.1 Introduction to SQL using Oracle Module 1
Dan D'Urso
 
Die Neuheiten in MariaDB 10.2 und MaxScale 2.1
Die Neuheiten in MariaDB 10.2 und MaxScale 2.1Die Neuheiten in MariaDB 10.2 und MaxScale 2.1
Die Neuheiten in MariaDB 10.2 und MaxScale 2.1
MariaDB plc
 
SQL_SERVER_BASIC_1_Training.pptx
SQL_SERVER_BASIC_1_Training.pptxSQL_SERVER_BASIC_1_Training.pptx
SQL_SERVER_BASIC_1_Training.pptx
KashifManzoorMeo
 
Getting Started with MySQL II
Getting Started with MySQL IIGetting Started with MySQL II
Getting Started with MySQL II
Sankhya_Analytics
 
SQL200A Microsoft Access SQL Design
SQL200A Microsoft Access SQL DesignSQL200A Microsoft Access SQL Design
SQL200A Microsoft Access SQL Design
Dan D'Urso
 
SQL_SERVER_BASIC_1_Training.pptx
SQL_SERVER_BASIC_1_Training.pptxSQL_SERVER_BASIC_1_Training.pptx
SQL_SERVER_BASIC_1_Training.pptx
QuyVo27
 
SQL Inteoduction to SQL manipulating of data
SQL Inteoduction to SQL manipulating of data   SQL Inteoduction to SQL manipulating of data
SQL Inteoduction to SQL manipulating of data
Vibrant Technologies & Computers
 
Dms 22319 micro project
Dms 22319 micro projectDms 22319 micro project
Dms 22319 micro project
ARVIND SARDAR
 
SQL212.2 Introduction to SQL using Oracle Module 2
SQL212.2 Introduction to SQL using Oracle Module 2SQL212.2 Introduction to SQL using Oracle Module 2
SQL212.2 Introduction to SQL using Oracle Module 2
Dan D'Urso
 
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
Frederic Descamps
 

Similar to SQL200.3 Module 3 (20)

SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3
SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3
SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3
 
SQL212.3 Introduction to SQL using Oracle Module 3
SQL212.3 Introduction to SQL using Oracle Module 3SQL212.3 Introduction to SQL using Oracle Module 3
SQL212.3 Introduction to SQL using Oracle Module 3
 
SQL202.2 Accelerated Introduction to SQL Using SQL Server Module 2
SQL202.2 Accelerated Introduction to SQL Using SQL Server Module 2SQL202.2 Accelerated Introduction to SQL Using SQL Server Module 2
SQL202.2 Accelerated Introduction to SQL Using SQL Server Module 2
 
SQL202.1 Accelerated Introduction to SQL Using SQL Server Module 1
SQL202.1 Accelerated Introduction to SQL Using SQL Server Module 1SQL202.1 Accelerated Introduction to SQL Using SQL Server Module 1
SQL202.1 Accelerated Introduction to SQL Using SQL Server Module 1
 
MySql slides (ppt)
MySql slides (ppt)MySql slides (ppt)
MySql slides (ppt)
 
Bn1037 demo oracle sql
Bn1037 demo  oracle sqlBn1037 demo  oracle sql
Bn1037 demo oracle sql
 
SQL Server 2008 New Features
SQL Server 2008 New FeaturesSQL Server 2008 New Features
SQL Server 2008 New Features
 
SQL302 Intermediate SQL Workshop 3
SQL302 Intermediate SQL Workshop 3SQL302 Intermediate SQL Workshop 3
SQL302 Intermediate SQL Workshop 3
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAsOracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAs
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c  - New Features for Developers and DBAsOracle Database 12c  - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAs
 
SQL212.1 Introduction to SQL using Oracle Module 1
SQL212.1 Introduction to SQL using Oracle Module 1SQL212.1 Introduction to SQL using Oracle Module 1
SQL212.1 Introduction to SQL using Oracle Module 1
 
Die Neuheiten in MariaDB 10.2 und MaxScale 2.1
Die Neuheiten in MariaDB 10.2 und MaxScale 2.1Die Neuheiten in MariaDB 10.2 und MaxScale 2.1
Die Neuheiten in MariaDB 10.2 und MaxScale 2.1
 
SQL_SERVER_BASIC_1_Training.pptx
SQL_SERVER_BASIC_1_Training.pptxSQL_SERVER_BASIC_1_Training.pptx
SQL_SERVER_BASIC_1_Training.pptx
 
Getting Started with MySQL II
Getting Started with MySQL IIGetting Started with MySQL II
Getting Started with MySQL II
 
SQL200A Microsoft Access SQL Design
SQL200A Microsoft Access SQL DesignSQL200A Microsoft Access SQL Design
SQL200A Microsoft Access SQL Design
 
SQL_SERVER_BASIC_1_Training.pptx
SQL_SERVER_BASIC_1_Training.pptxSQL_SERVER_BASIC_1_Training.pptx
SQL_SERVER_BASIC_1_Training.pptx
 
SQL Inteoduction to SQL manipulating of data
SQL Inteoduction to SQL manipulating of data   SQL Inteoduction to SQL manipulating of data
SQL Inteoduction to SQL manipulating of data
 
Dms 22319 micro project
Dms 22319 micro projectDms 22319 micro project
Dms 22319 micro project
 
SQL212.2 Introduction to SQL using Oracle Module 2
SQL212.2 Introduction to SQL using Oracle Module 2SQL212.2 Introduction to SQL using Oracle Module 2
SQL212.2 Introduction to SQL using Oracle Module 2
 
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
 

More from Dan D'Urso

SQL201S Accelerated Introduction to MySQL Queries
SQL201S Accelerated Introduction to MySQL QueriesSQL201S Accelerated Introduction to MySQL Queries
SQL201S Accelerated Introduction to MySQL Queries
Dan D'Urso
 
LCD201d Database Diagramming with Lucidchart
LCD201d Database Diagramming with LucidchartLCD201d Database Diagramming with Lucidchart
LCD201d Database Diagramming with Lucidchart
Dan D'Urso
 
Database Normalization
Database NormalizationDatabase Normalization
Database Normalization
Dan D'Urso
 
VIS201d Visio Database Diagramming
VIS201d Visio Database DiagrammingVIS201d Visio Database Diagramming
VIS201d Visio Database Diagramming
Dan D'Urso
 
PRJ101a Project 2013 Accelerated
PRJ101a Project 2013 AcceleratedPRJ101a Project 2013 Accelerated
PRJ101a Project 2013 Accelerated
Dan D'Urso
 
PRJ101xl Project Libre Basic Training
PRJ101xl Project Libre Basic TrainingPRJ101xl Project Libre Basic Training
PRJ101xl Project Libre Basic Training
Dan D'Urso
 
Introduction to coding using Python
Introduction to coding using PythonIntroduction to coding using Python
Introduction to coding using Python
Dan D'Urso
 
Stem conference
Stem conferenceStem conference
Stem conference
Dan D'Urso
 
SQL302 Intermediate SQL
SQL302 Intermediate SQLSQL302 Intermediate SQL
SQL302 Intermediate SQL
Dan D'Urso
 
AIN106 Access Reporting and Analysis
AIN106 Access Reporting and AnalysisAIN106 Access Reporting and Analysis
AIN106 Access Reporting and Analysis
Dan D'Urso
 
SQL302 Intermediate SQL Workshop 2
SQL302 Intermediate SQL Workshop 2SQL302 Intermediate SQL Workshop 2
SQL302 Intermediate SQL Workshop 2
Dan D'Urso
 
Course Catalog
Course CatalogCourse Catalog
Course CatalogDan D'Urso
 
SQL302 Intermediate SQL Workshop 1
SQL302 Intermediate SQL Workshop 1SQL302 Intermediate SQL Workshop 1
SQL302 Intermediate SQL Workshop 1
Dan D'Urso
 
SQL212 Oracle SQL Manual
SQL212 Oracle SQL ManualSQL212 Oracle SQL Manual
SQL212 Oracle SQL Manual
Dan D'Urso
 
SQL201W MySQL SQL Manual
SQL201W MySQL SQL ManualSQL201W MySQL SQL Manual
SQL201W MySQL SQL Manual
Dan D'Urso
 
SQL206 SQL Median
SQL206 SQL MedianSQL206 SQL Median
SQL206 SQL Median
Dan D'Urso
 
SQL202 SQL Server SQL Manual
SQL202 SQL Server SQL ManualSQL202 SQL Server SQL Manual
SQL202 SQL Server SQL Manual
Dan D'Urso
 
AIN102 Microsoft Access Queries
AIN102 Microsoft Access QueriesAIN102 Microsoft Access Queries
AIN102 Microsoft Access Queries
Dan D'Urso
 
AIN102S Access string function sample queries
AIN102S Access string function sample queriesAIN102S Access string function sample queries
AIN102S Access string function sample queries
Dan D'Urso
 
AIN102.2 Microsoft Access Queries
AIN102.2 Microsoft Access QueriesAIN102.2 Microsoft Access Queries
AIN102.2 Microsoft Access Queries
Dan D'Urso
 

More from Dan D'Urso (20)

SQL201S Accelerated Introduction to MySQL Queries
SQL201S Accelerated Introduction to MySQL QueriesSQL201S Accelerated Introduction to MySQL Queries
SQL201S Accelerated Introduction to MySQL Queries
 
LCD201d Database Diagramming with Lucidchart
LCD201d Database Diagramming with LucidchartLCD201d Database Diagramming with Lucidchart
LCD201d Database Diagramming with Lucidchart
 
Database Normalization
Database NormalizationDatabase Normalization
Database Normalization
 
VIS201d Visio Database Diagramming
VIS201d Visio Database DiagrammingVIS201d Visio Database Diagramming
VIS201d Visio Database Diagramming
 
PRJ101a Project 2013 Accelerated
PRJ101a Project 2013 AcceleratedPRJ101a Project 2013 Accelerated
PRJ101a Project 2013 Accelerated
 
PRJ101xl Project Libre Basic Training
PRJ101xl Project Libre Basic TrainingPRJ101xl Project Libre Basic Training
PRJ101xl Project Libre Basic Training
 
Introduction to coding using Python
Introduction to coding using PythonIntroduction to coding using Python
Introduction to coding using Python
 
Stem conference
Stem conferenceStem conference
Stem conference
 
SQL302 Intermediate SQL
SQL302 Intermediate SQLSQL302 Intermediate SQL
SQL302 Intermediate SQL
 
AIN106 Access Reporting and Analysis
AIN106 Access Reporting and AnalysisAIN106 Access Reporting and Analysis
AIN106 Access Reporting and Analysis
 
SQL302 Intermediate SQL Workshop 2
SQL302 Intermediate SQL Workshop 2SQL302 Intermediate SQL Workshop 2
SQL302 Intermediate SQL Workshop 2
 
Course Catalog
Course CatalogCourse Catalog
Course Catalog
 
SQL302 Intermediate SQL Workshop 1
SQL302 Intermediate SQL Workshop 1SQL302 Intermediate SQL Workshop 1
SQL302 Intermediate SQL Workshop 1
 
SQL212 Oracle SQL Manual
SQL212 Oracle SQL ManualSQL212 Oracle SQL Manual
SQL212 Oracle SQL Manual
 
SQL201W MySQL SQL Manual
SQL201W MySQL SQL ManualSQL201W MySQL SQL Manual
SQL201W MySQL SQL Manual
 
SQL206 SQL Median
SQL206 SQL MedianSQL206 SQL Median
SQL206 SQL Median
 
SQL202 SQL Server SQL Manual
SQL202 SQL Server SQL ManualSQL202 SQL Server SQL Manual
SQL202 SQL Server SQL Manual
 
AIN102 Microsoft Access Queries
AIN102 Microsoft Access QueriesAIN102 Microsoft Access Queries
AIN102 Microsoft Access Queries
 
AIN102S Access string function sample queries
AIN102S Access string function sample queriesAIN102S Access string function sample queries
AIN102S Access string function sample queries
 
AIN102.2 Microsoft Access Queries
AIN102.2 Microsoft Access QueriesAIN102.2 Microsoft Access Queries
AIN102.2 Microsoft Access Queries
 

Recently uploaded

Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 

Recently uploaded (20)

Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 

SQL200.3 Module 3

  • 1. SQL/200 SQL Programming Workshop 3 – Modifying Data, Managing the Database Bookstore SQL200 Module 3 1
  • 2. SQL200 Contact Information P.O. Box 6142 Laguna Niguel, CA 92607 949-489-1472 http://www.d2associates.com slides.1@dhdursoassociates.com Copyright 2001-2009. All rights reserved. Bookstore SQL200 Module 3 2
  • 3. SQL200 Module 3 • Part 1 – Modifying Data Part 2 – Managing Database Structures • • Part 3 – Creating Views and Indexes • Part 4 -- Security Bookstore SQL200 Module 3 3
  • 4. SQL/200 SQL Programming Part 1 – Modifying Data Bookstore SQL200 Module 3 4
  • 5. Relational Database with constraints (from text) Bookstore SQL200 Module 3 5
  • 6. Data Modification Statements • Insert • Update • Delete Bookstore SQL200 Module 3 6
  • 7. Data Modification Statements • End-user rarely sees these statements • Application developer prepares these statements “behind the scenes” based on forms filled out by user Bookstore SQL200 Module 3 7
  • 8. Insert • Adds new rows to an existing table • Two forms: – Single Row – Multi-Row Bookstore SQL200 Module 3 8
  • 9. Single Row Insert Basic Syntax: Insert [into] <table-name> Values (<value-list>) Bookstore SQL200 Module 3 9
  • 10. Single Row Insert Basic Example: insert into sources(source_numb, source_name, source_street) values(22,'Specialty Books', 'Canal Street') Bookstore SQL200 Module 3 10
  • 11. Insert Statement Bookstore SQL200 Module 3 11
  • 12. Sources table after Insert Bookstore SQL200 Module 3 12
  • 13. Multi-row Insert Basic Syntax: Insert [into] <table-name> Select <select-statement> We will do this after creating a new table later in this module Bookstore SQL200 Module 3 13
  • 14. Update • Updates fields in an existing row Basic Syntax: Update <table-name> Set <field1> = new value, <field2> = new value, … Where <selection-criteria> Bookstore SQL200 Module 3 14
  • 15. Update • Increase Ingram prices by 10% Example: Update books Set retail_price = retail_price *1.10 Where source_numb = 1 Bookstore SQL200 Module 3 15
  • 16. Ingram Book Prices before Update Bookstore SQL200 Module 3 16
  • 17. Ingram Book Prices after Update Bookstore SQL200 Module 3 17
  • 18. After update in MS Access Bookstore SQL200 Module 3 18
  • 19. Delete • Deletes one or more rows Basic Syntax: Delete from <table-name> Where <selection-criteria> Bookstore SQL200 Module 3 19
  • 20. Delete Example: Delete from sources Where source_numb = 22 Bookstore SQL200 Module 3 20
  • 21. Delete Bookstore SQL200 Module 3 21
  • 22. Sources table after Delete Bookstore SQL200 Module 3 22
  • 23. Delete and Referential Integrity • Can affect referential integrity when deleting a “parent” row • Can do following with child… – Cascade: delete the child row – Set null: set the child’s foreign key null – Set default: as above but to default value – No action: don’t allow delete of parent row • Referential integrity can be established when creating or modifying table structures which we will look at later in the class Bookstore SQL200 Module 3 23
  • 24. SQL/200 SQL Programming Part 2– Managing Database Structures Bookstore SQL200 Module 3 24
  • 25. Schemas • Logical view of a database; sort of a “sub- database” – we will not cover these in this module or… – Catalogs – Clusters – Domains (somewhat like a user defined datatype) • These topics are highly dependent upon the vendor DBMS and installation practices Bookstore SQL200 Module 3 25
  • 26. Tables • Base tables • Temporary tables – Local (or module scope) – Global (session scope) Bookstore SQL200 Module 3 26
  • 27. Creating Tables • Use create statement • Specify: – Columns with data types and column constraints – Table constraints • Foreign key references • Primary key designation Bookstore SQL200 Module 3 27
  • 28. Temporary Tables Basic syntax: Create [global] temporary table <table-name> <rest of statement as for normal create> Note: SQL Server uses a different syntax. Put a #in front of the table name as in #mytable. Access doesn’t have true temporary tables. Bookstore SQL200 Module 3 28
  • 29. Data Types • Int – integers or whole numbers – Ex: how_many int • Char – fixed length fields – Ex: state char(2) • Varchar/Varchar2 – variable length fields – Ex: address varchar(35) • Money – money field; same as MS Access currency • Date/Datetime – date and time • And many others – see documentation or Help Bookstore SQL200 Module 3 29
  • 30. Create Table Basic syntax: Create table <table-name> <column1> <datatype> <constraints> ,.. <column1> <datatype> <constraints> … <table constraints> Note: often preceded by a drop Bookstore SQL200 Module 3 30
  • 31. Column Constraints • Primary key Not NULL • • CHECK clause • Default Unique • Bookstore SQL200 Module 3 31
  • 32. Table Constraints • Primary Key • Foreign Key • Compare fields against each other. I.e. ship_date >= order_date Bookstore SQL200 Module 3 32
  • 33. But first – the Drop Statement • Deletes a database “object” – Drop table <table-name> – Drop view <view-name> – Drop index <index-name> – Drop domain <domain-name> Bookstore SQL200 Module 3 33
  • 34. Create Table Example 1: Create a summary table Create table summary( isbn varchar(20) primary key, How_many int check (how_many >= 0), Constraint isbn_fk Foreign key (isbn) references books(isbn) ) Bookstore SQL200 Module 3 34
  • 35. Create Summary Table Bookstore SQL200 Module 3 35
  • 36. Constraints on Summary Table Bookstore SQL200 Module 3 36
  • 37. Multi-row Insert Basic Syntax: Insert [into] <table-name> Select <select-statement> Bookstore SQL200 Module 3 37
  • 38. Multi-row Insert Basic Example: (store # times each book ordered) Insert into summary(isbn, how_many) Select isbn, count(*) From orderlines Group by isbn; Bookstore SQL200 Module 3 38
  • 39. Multi-row Insert Bookstore SQL200 Module 3 39
  • 40. After multi-row insert in MS Access Bookstore SQL200 Module 3 40
  • 41. SQL/200 SQL Programming Part 3 – Creating Views and Indexes, Modifying Structures Bookstore SQL200 Module 3 41
  • 42. Views • Think of a view as a named query wherein the definition is stored in the database • Can be read like a table • Some are updateable Bookstore SQL200 Module 3 42
  • 43. Views Basic syntax: Create view <view-name> (<column-list>) As <select statement> Bookstore SQL200 Module 3 43
  • 44. Creating a View Bookstore SQL200 Module 3 44
  • 45. Using Views • Can be used like a table subject to various limitations – Cannot insert into grouped queries, etc. – Etc. • Sample syntax: select column-list from employee_view Bookstore SQL200 Module 3 45
  • 46. Using a View Bookstore SQL200 Module 3 46
  • 47. Indexes • Used to speed searches, joins, etc. • Placed on: – primary and foreign keys – Secondary keys • In commercial practice often managed by DBA’s for large databases Bookstore SQL200 Module 3 47
  • 48. Indexes Basic syntax: Create [unique] index <index-name> On <table-name> (field-name> [desc]) Note: can place index on a composite key; ex: state and city Bookstore SQL200 Module 3 48
  • 49. Indexes Basic example: create index state_inx on customers(customer_state) Bookstore SQL200 Module 3 49
  • 50. After indexing on customer_state Bookstore SQL200 Module 3 50
  • 51. Customers table with index Bookstore SQL200 Module 3 51
  • 52. State_inx in Oracle Bookstore SQL200 Module 3 52
  • 53. Modifying a Table Design • Applies to tables • Use ALTER statement – Add columns – Delete columns – Rename columns – Add column constraints – Add table constraints Bookstore SQL200 Module 3 53
  • 54. Modifying a Table Design Basic syntax: Alter <table-name> Add <field-name>, Add <table-constraint>, Modify <field-name> Etc. Bookstore SQL200 Module 3 54
  • 55. Modify a Table Design Example: add a phone number field alter table publishers add phone char(12); Bookstore SQL200 Module 3 55
  • 56. After alter publishers table Bookstore SQL200 Module 3 56
  • 57. SQL/200 SQL Programming Part 4 – Security Bookstore SQL200 Module 3 57
  • 58. Security • Specifics can vary by product Access: workgroup administrator • • SQL Server: users, groups • Oracle: users, roles Bookstore SQL200 Module 3 58
  • 59. Security • Important DBA function – Beyond scope of this course – Typically controlled through the Enterprise Managers • In commercial practice application security frequently controlled via own login and a “users” table or similar Bookstore SQL200 Module 3 59
  • 60. SQL Security Statements • Grant • Revoke • Deny Bookstore SQL200 Module 3 60
  • 61. Grant Syntax: Grant <access-right> [with grant option] On <object> to <user> Bookstore SQL200 Module 3 61
  • 62. Access Rights • Select Update • • Insert • Delete References • • All privileges Bookstore SQL200 Module 3 62
  • 63. Grant Example: Grant update On employees to ddurso Bookstore SQL200 Module 3 63
  • 64. Revoke • Revokes the rights • Syntax similar to grant [end module] Bookstore SQL200 Module 3 64