SlideShare a Scribd company logo
hasen@microcis.net July 16, 2013Hassen poreya
Trainer, Cresco Solution
Afghanistan Workforce
Development Program
Database
MySQL, Modification Commands
Modification Commands
 There are three SQL commands to modify the
database:
 INSERT
 DELETE
 UPDATE
INSERT Command
 In its simplest form, it is used to add one or more
tuples to a relation.
 Tuples are the rows
 Relations are the tables.
 Attribute values should be listed in the same order
as the attributes were specified in the CREATE
TABLE command.
INSERT Command
INSERT INTO table name VALUES
(value1, value2, ...);
 Values are separated by comma ,
 Strings, Dates are enclosed by single quotation
marks ‘’
 Values have to be sorted according to the table
structure (the columns)
INSERT Command
INSERT INTO employee VALUES
(1,'John',‘ Smith', 'Berlin', '1979-
09-04', 1000.40);
INSERT INTO project VALUES (1,
'Database Design', 'Kabul');
INSERT INTO works in VALUES(1,1,40);
INSERT Command
INSERT INTO employee VALUES
(NULL, 'Anna', 'Conner', 'London',
'1960-11-10‘,1.40);
What will happen if we put null value in the id field?
INSERT Command
 If we used AUTO INCREMENT for the definition of
a column, the database system will automatically
compute a unique value for Id.
 The value is computed by incrementing the
maximum value for Id already in the database.
DELETE Command
 Removes tuples from a relation.
 Includes a WHERE clause to select the tuples to be
deleted.
 A missing WHERE clause species that all tuples in the
relation are to be deleted; the table then becomes an
empty table.
 The number of tuples deleted depends on the number
of tuples in the relation that satisfy the WHERE clause.
DELETE Command
DELETE FROM table name WHERE condition;
DELETE FROM employee WHERE id=1;
DELETE FROM project WHERE
location=‘kabul’;
INSERT Command: Integrity Constraints
 Integrity Constraints:
 One of the tasks of a database system is to make
(automatically) sure that the stored data is in a
consistent state.
 When we model the Mini-World we also model what
a consistent state means for us by defining integrity
constraints.
 In our company each employee is assigned a unique id
as the PRIMARY KEY
Integrity Constraints: PRIMARY KEY
 Primary Key
 Database system automatically rejects all new records
with a key that is already stored in the database as
below:
Integrity Constraints: UNIQUE
 UNIQUE
 Similar to primary key: has to be unique
 We do not want to use name as a primary key to
identify records, but still we want to express that it has
to be unique.
Integrity Constraints: NOT NULL
 NOT NULL
 Sometimes we want to make sure that a value is
always assigned to a column, so we use NOT NULL
 Primary keys are automatically defined as NOT NULL
(we couldn't identify an employee if there is no Id
stored)
Modification Command: UPDATE
 It is used to modify attribute values of one or more
selected tuples.
 A WHERE clause selects the tuples to be modified.
 An additional SET clause species the attributes to
be modified and their new values.
Modification Command: SELECT
 Extract data stored in some columns of some table.
 General syntax is:
SELECT column name1, column name2, ... FROM
table name;
SELECT * FROM table name;
 The asterisk (*) retrieves all attributes form the
specified table.
Modification Command: SELECT
SELECT last name, location, salary
FROM employee
Modification Command: SELECT
SELECT * FROM employee
SELECT Command: WHERE
 Basic form of the SQL SELECT statement is called a
mapping or a SELECT-FROM-WHERE- block.
SELECT < attributelist > FROM < tablelist > WHERE
< condition >
 < condition > is a conditional (Boolean) expression
that identifies the tuples to be retrieved by the
query.
SELECT Command: WHERE
SELECT location, salary FROM
employee WHERE last_name=Smith;
SELECT Command: ORDER BY
 Sort the result according to some column,
descending or ascending.
SELECT Command: ORDER BY
 Compare the result with the same query using
ORDER BY.
Let’s do something
hasen@microcis.net July 16, 2013Hassen poreya
Trainer, Cresco Solution
Any Questions!
Ad

Recommended

Lab1 select statement
Lab1 select statement
Balqees Al.Mubarak
 
Database Systems - SQL - DDL Statements (Chapter 3/3)
Database Systems - SQL - DDL Statements (Chapter 3/3)
Vidyasagar Mundroy
 
Database Systems - SQL - DDL Statements (Chapter 3/2)
Database Systems - SQL - DDL Statements (Chapter 3/2)
Vidyasagar Mundroy
 
Lab5 sub query
Lab5 sub query
Balqees Al.Mubarak
 
Mysql cheatsheet
Mysql cheatsheet
Adolfo Nasol
 
SQL Views
SQL Views
baabtra.com - No. 1 supplier of quality freshers
 
Oracle: Basic SQL
Oracle: Basic SQL
DataminingTools Inc
 
Sql operator
Sql operator
Pooja Dixit
 
SQL Tutorial - Basic Commands
SQL Tutorial - Basic Commands
1keydata
 
Creating database using sql commands
Creating database using sql commands
Belle Wx
 
View & index in SQL
View & index in SQL
Swapnali Pawar
 
Sql basics
Sql basics
Genesis Omo
 
DDL,DML,SQL Functions and Joins
DDL,DML,SQL Functions and Joins
Ashwin Dinoriya
 
Les13
Les13
arnold 7490
 
MULTIPLE TABLES
MULTIPLE TABLES
ASHABOOPATHY
 
SQL Functions and Operators
SQL Functions and Operators
Mohan Kumar.R
 
SQL
SQL
Surendra Shukla
 
Advanced SQL Webinar
Advanced SQL Webinar
Ram Kedem
 
Module 3
Module 3
cs19club
 
Sql select
Sql select
Mudasir Syed
 
Ch04
Ch04
cs19club
 
Database Management System 1
Database Management System 1
Swapnali Pawar
 
Sql12
Sql12
tacex1
 
SQL Introduction to displaying data from multiple tables
SQL Introduction to displaying data from multiple tables
Vibrant Technologies & Computers
 
Ch05
Ch05
cs19club
 
Introduction to triggers
Introduction to triggers
Command Prompt., Inc
 
Web app development_php_05
Web app development_php_05
Hassen Poreya
 
CodeIgniter Practice
CodeIgniter Practice
Jamshid Hashimi
 
Web app development_crud_13
Web app development_crud_13
Hassen Poreya
 
Web app development_database_design_10
Web app development_database_design_10
Hassen Poreya
 

More Related Content

What's hot (18)

SQL Tutorial - Basic Commands
SQL Tutorial - Basic Commands
1keydata
 
Creating database using sql commands
Creating database using sql commands
Belle Wx
 
View & index in SQL
View & index in SQL
Swapnali Pawar
 
Sql basics
Sql basics
Genesis Omo
 
DDL,DML,SQL Functions and Joins
DDL,DML,SQL Functions and Joins
Ashwin Dinoriya
 
Les13
Les13
arnold 7490
 
MULTIPLE TABLES
MULTIPLE TABLES
ASHABOOPATHY
 
SQL Functions and Operators
SQL Functions and Operators
Mohan Kumar.R
 
SQL
SQL
Surendra Shukla
 
Advanced SQL Webinar
Advanced SQL Webinar
Ram Kedem
 
Module 3
Module 3
cs19club
 
Sql select
Sql select
Mudasir Syed
 
Ch04
Ch04
cs19club
 
Database Management System 1
Database Management System 1
Swapnali Pawar
 
Sql12
Sql12
tacex1
 
SQL Introduction to displaying data from multiple tables
SQL Introduction to displaying data from multiple tables
Vibrant Technologies & Computers
 
Ch05
Ch05
cs19club
 
Introduction to triggers
Introduction to triggers
Command Prompt., Inc
 

Viewers also liked (15)

Web app development_php_05
Web app development_php_05
Hassen Poreya
 
CodeIgniter Practice
CodeIgniter Practice
Jamshid Hashimi
 
Web app development_crud_13
Web app development_crud_13
Hassen Poreya
 
Web app development_database_design_10
Web app development_database_design_10
Hassen Poreya
 
Web app development_html_css_03
Web app development_html_css_03
Hassen Poreya
 
Web app development_php_07
Web app development_php_07
Hassen Poreya
 
Web app development_my_sql_08
Web app development_my_sql_08
Hassen Poreya
 
Web app development_php_04
Web app development_php_04
Hassen Poreya
 
Learn to Code with JavaScript - Choose Your Own Adventures
Learn to Code with JavaScript - Choose Your Own Adventures
Tessa Mero
 
Web app development_database_design_11
Web app development_database_design_11
Hassen Poreya
 
Web app development_database_design_er-mapping_12
Web app development_database_design_er-mapping_12
Hassen Poreya
 
Web app development_php_06
Web app development_php_06
Hassen Poreya
 
Web app development_html_02
Web app development_html_02
Hassen Poreya
 
Web app development_html_01
Web app development_html_01
Hassen Poreya
 
Web app development_cookies_sessions_14
Web app development_cookies_sessions_14
Hassen Poreya
 
Web app development_php_05
Web app development_php_05
Hassen Poreya
 
Web app development_crud_13
Web app development_crud_13
Hassen Poreya
 
Web app development_database_design_10
Web app development_database_design_10
Hassen Poreya
 
Web app development_html_css_03
Web app development_html_css_03
Hassen Poreya
 
Web app development_php_07
Web app development_php_07
Hassen Poreya
 
Web app development_my_sql_08
Web app development_my_sql_08
Hassen Poreya
 
Web app development_php_04
Web app development_php_04
Hassen Poreya
 
Learn to Code with JavaScript - Choose Your Own Adventures
Learn to Code with JavaScript - Choose Your Own Adventures
Tessa Mero
 
Web app development_database_design_11
Web app development_database_design_11
Hassen Poreya
 
Web app development_database_design_er-mapping_12
Web app development_database_design_er-mapping_12
Hassen Poreya
 
Web app development_php_06
Web app development_php_06
Hassen Poreya
 
Web app development_html_02
Web app development_html_02
Hassen Poreya
 
Web app development_html_01
Web app development_html_01
Hassen Poreya
 
Web app development_cookies_sessions_14
Web app development_cookies_sessions_14
Hassen Poreya
 
Ad

Similar to Web app development_my_sql_09 (20)

SQL
SQL
Mohamed Essam
 
DATABASE MANAGMENT SYSTEM (DBMS) AND SQL
DATABASE MANAGMENT SYSTEM (DBMS) AND SQL
Dev Chauhan
 
Ppt INFORMATIVE PRACTICES for class 11th chapter 14
Ppt INFORMATIVE PRACTICES for class 11th chapter 14
prashant0000
 
Sql commands
Sql commands
Pooja Dixit
 
Db1 lecture4
Db1 lecture4
Sherif Gad
 
SQL Assessment Command Statements
SQL Assessment Command Statements
Shaun Wilson
 
DBMS-SQL-Commands-BBA-4-Sem-1-PanjabUniversity.ppt
DBMS-SQL-Commands-BBA-4-Sem-1-PanjabUniversity.ppt
NishaGupta92113
 
SQL Presentation-1 (structured query language)
SQL Presentation-1 (structured query language)
renodet116
 
DML Commands
DML Commands
Randy Riness @ South Puget Sound Community College
 
PPT
PPT
webhostingguy
 
SQL Presentation-1 yehjebjj yeuu helo the worls.ppt
SQL Presentation-1 yehjebjj yeuu helo the worls.ppt
nanisaketh
 
unit-5 sql notes.docx
unit-5 sql notes.docx
RaviRajput416403
 
full detailled SQL notesquestion bank (1).pdf
full detailled SQL notesquestion bank (1).pdf
yvpachorib23
 
Null values, insert, delete and update in database
Null values, insert, delete and update in database
Hemant Suthar
 
UNIT2.ppt
UNIT2.ppt
SaurabhLokare1
 
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
SakkaravarthiS1
 
MY SQL
MY SQL
sundar
 
Crime record management system project.pptx
Crime record management system project.pptx
shindegls59
 
WEEK-2 DML and operators power point presentation
WEEK-2 DML and operators power point presentation
AshokRachapalli1
 
Database Akjljljlkjlkjkljlkjldiministration.pptx
Database Akjljljlkjlkjkljlkjldiministration.pptx
EliasPetros
 
DATABASE MANAGMENT SYSTEM (DBMS) AND SQL
DATABASE MANAGMENT SYSTEM (DBMS) AND SQL
Dev Chauhan
 
Ppt INFORMATIVE PRACTICES for class 11th chapter 14
Ppt INFORMATIVE PRACTICES for class 11th chapter 14
prashant0000
 
SQL Assessment Command Statements
SQL Assessment Command Statements
Shaun Wilson
 
DBMS-SQL-Commands-BBA-4-Sem-1-PanjabUniversity.ppt
DBMS-SQL-Commands-BBA-4-Sem-1-PanjabUniversity.ppt
NishaGupta92113
 
SQL Presentation-1 (structured query language)
SQL Presentation-1 (structured query language)
renodet116
 
SQL Presentation-1 yehjebjj yeuu helo the worls.ppt
SQL Presentation-1 yehjebjj yeuu helo the worls.ppt
nanisaketh
 
full detailled SQL notesquestion bank (1).pdf
full detailled SQL notesquestion bank (1).pdf
yvpachorib23
 
Null values, insert, delete and update in database
Null values, insert, delete and update in database
Hemant Suthar
 
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
SakkaravarthiS1
 
Crime record management system project.pptx
Crime record management system project.pptx
shindegls59
 
WEEK-2 DML and operators power point presentation
WEEK-2 DML and operators power point presentation
AshokRachapalli1
 
Database Akjljljlkjlkjkljlkjldiministration.pptx
Database Akjljljlkjlkjkljlkjldiministration.pptx
EliasPetros
 
Ad

Recently uploaded (20)

Quantum AI: Where Impossible Becomes Probable
Quantum AI: Where Impossible Becomes Probable
Saikat Basu
 
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Safe Software
 
You are not excused! How to avoid security blind spots on the way to production
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
 
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
pcprocore
 
Securing AI - There Is No Try, Only Do!.pdf
Securing AI - There Is No Try, Only Do!.pdf
Priyanka Aash
 
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
Priyanka Aash
 
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
 
Techniques for Automatic Device Identification and Network Assignment.pdf
Techniques for Automatic Device Identification and Network Assignment.pdf
Priyanka Aash
 
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
digitaljignect
 
Lessons Learned from Developing Secure AI Workflows.pdf
Lessons Learned from Developing Secure AI Workflows.pdf
Priyanka Aash
 
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
 
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Priyanka Aash
 
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
Fwdays
 
"Scaling in space and time with Temporal", Andriy Lupa.pdf
"Scaling in space and time with Temporal", Andriy Lupa.pdf
Fwdays
 
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
Earley Information Science
 
AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
 
UserCon Belgium: Honey, VMware increased my bill
UserCon Belgium: Honey, VMware increased my bill
stijn40
 
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
Priyanka Aash
 
Quantum AI: Where Impossible Becomes Probable
Quantum AI: Where Impossible Becomes Probable
Saikat Basu
 
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Safe Software
 
You are not excused! How to avoid security blind spots on the way to production
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
 
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
pcprocore
 
Securing AI - There Is No Try, Only Do!.pdf
Securing AI - There Is No Try, Only Do!.pdf
Priyanka Aash
 
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
Priyanka Aash
 
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
 
Techniques for Automatic Device Identification and Network Assignment.pdf
Techniques for Automatic Device Identification and Network Assignment.pdf
Priyanka Aash
 
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
digitaljignect
 
Lessons Learned from Developing Secure AI Workflows.pdf
Lessons Learned from Developing Secure AI Workflows.pdf
Priyanka Aash
 
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
 
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Priyanka Aash
 
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
Fwdays
 
"Scaling in space and time with Temporal", Andriy Lupa.pdf
"Scaling in space and time with Temporal", Andriy Lupa.pdf
Fwdays
 
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
Earley Information Science
 
AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
 
UserCon Belgium: Honey, VMware increased my bill
UserCon Belgium: Honey, VMware increased my bill
stijn40
 
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
Priyanka Aash
 

Web app development_my_sql_09

  • 1. [email protected] July 16, 2013Hassen poreya Trainer, Cresco Solution Afghanistan Workforce Development Program Database MySQL, Modification Commands
  • 2. Modification Commands  There are three SQL commands to modify the database:  INSERT  DELETE  UPDATE
  • 3. INSERT Command  In its simplest form, it is used to add one or more tuples to a relation.  Tuples are the rows  Relations are the tables.  Attribute values should be listed in the same order as the attributes were specified in the CREATE TABLE command.
  • 4. INSERT Command INSERT INTO table name VALUES (value1, value2, ...);  Values are separated by comma ,  Strings, Dates are enclosed by single quotation marks ‘’  Values have to be sorted according to the table structure (the columns)
  • 5. INSERT Command INSERT INTO employee VALUES (1,'John',‘ Smith', 'Berlin', '1979- 09-04', 1000.40); INSERT INTO project VALUES (1, 'Database Design', 'Kabul'); INSERT INTO works in VALUES(1,1,40);
  • 6. INSERT Command INSERT INTO employee VALUES (NULL, 'Anna', 'Conner', 'London', '1960-11-10‘,1.40); What will happen if we put null value in the id field?
  • 7. INSERT Command  If we used AUTO INCREMENT for the definition of a column, the database system will automatically compute a unique value for Id.  The value is computed by incrementing the maximum value for Id already in the database.
  • 8. DELETE Command  Removes tuples from a relation.  Includes a WHERE clause to select the tuples to be deleted.  A missing WHERE clause species that all tuples in the relation are to be deleted; the table then becomes an empty table.  The number of tuples deleted depends on the number of tuples in the relation that satisfy the WHERE clause.
  • 9. DELETE Command DELETE FROM table name WHERE condition; DELETE FROM employee WHERE id=1; DELETE FROM project WHERE location=‘kabul’;
  • 10. INSERT Command: Integrity Constraints  Integrity Constraints:  One of the tasks of a database system is to make (automatically) sure that the stored data is in a consistent state.  When we model the Mini-World we also model what a consistent state means for us by defining integrity constraints.  In our company each employee is assigned a unique id as the PRIMARY KEY
  • 11. Integrity Constraints: PRIMARY KEY  Primary Key  Database system automatically rejects all new records with a key that is already stored in the database as below:
  • 12. Integrity Constraints: UNIQUE  UNIQUE  Similar to primary key: has to be unique  We do not want to use name as a primary key to identify records, but still we want to express that it has to be unique.
  • 13. Integrity Constraints: NOT NULL  NOT NULL  Sometimes we want to make sure that a value is always assigned to a column, so we use NOT NULL  Primary keys are automatically defined as NOT NULL (we couldn't identify an employee if there is no Id stored)
  • 14. Modification Command: UPDATE  It is used to modify attribute values of one or more selected tuples.  A WHERE clause selects the tuples to be modified.  An additional SET clause species the attributes to be modified and their new values.
  • 15. Modification Command: SELECT  Extract data stored in some columns of some table.  General syntax is: SELECT column name1, column name2, ... FROM table name; SELECT * FROM table name;  The asterisk (*) retrieves all attributes form the specified table.
  • 16. Modification Command: SELECT SELECT last name, location, salary FROM employee
  • 18. SELECT Command: WHERE  Basic form of the SQL SELECT statement is called a mapping or a SELECT-FROM-WHERE- block. SELECT < attributelist > FROM < tablelist > WHERE < condition >  < condition > is a conditional (Boolean) expression that identifies the tuples to be retrieved by the query.
  • 19. SELECT Command: WHERE SELECT location, salary FROM employee WHERE last_name=Smith;
  • 20. SELECT Command: ORDER BY  Sort the result according to some column, descending or ascending.
  • 21. SELECT Command: ORDER BY  Compare the result with the same query using ORDER BY.
  • 23. [email protected] July 16, 2013Hassen poreya Trainer, Cresco Solution Any Questions!