SlideShare a Scribd company logo
Introduction to SQL_02
‫کننده‬ ‫تهیه‬:‫عادل‬ ‫هللا‬ ‫عصمت‬
‫با‬ ‫معرفی‬SQL
Topics:
• SQL SELECT TOP Clause
• SQL LIKE Operator
• SQL IN Operator
• SQL INSERT INTO Statement
• SQL UPDATE Statement
• SQL DELETE Statement
•‫واره‬ ‫جمله‬Select top،SQL
•‫عملیه‬like،SQL
•‫عملیه‬In،SQL
•‫دستور‬Insert into،SQL
•‫دستور‬update،SQL
•‫دستور‬delete،SQL
2:04 AM
Gharjistan University Computer Science
Faculty Farah Branch
2
SQL SELECT TOP Clause:
• The SELECT TOP clause is
used to specify the number
of records to return.
• The SELECT TOP clause can
be very useful on large
tables with thousands of
records. Returning a large
number of records can
impact on performance.
• Note: Not all database
systems support the SELECT
TOP clause.
•‫واره‬ ‫جمله‬select top‫برای‬
‫ریکاردهایکه‬ ‫تعداد‬ ‫کردن‬ ‫مشخص‬
‫میرود‬ ‫بکار‬ ‫میشود‬ ‫داده‬ ‫برگشت‬.
•‫واره‬ ‫جمله‬select top‫جدول‬ ‫در‬
‫هزاران‬ ‫تعداد‬ ‫به‬ ‫که‬ ‫بزرگ‬ ‫های‬
‫واقع‬ ‫مفید‬ ‫بسیار‬ ‫داشته‬ ‫ریکارد‬‫شده‬
‫میتواند‬.‫ب‬ ‫ریکاردها‬ ‫دادن‬ ‫برگشت‬‫ه‬
‫اجراعات‬ ‫کیفیت‬ ‫روی‬ ‫زیاد‬ ‫تعداد‬
‫میتواند‬ ‫مانده‬ ‫تأثیر‬.
•‫یادداشت‬:‫دیتاب‬ ‫های‬ ‫سیستم‬ ‫تمام‬‫یس‬
‫واره‬ ‫جمله‬select top‫پشتیبانی‬ ‫را‬
‫نمیکند‬.
2:04 AM
Gharjistan University Computer Science
Faculty Farah Branch
3
Continue…
• SQL Server / MS Access Syntax:
• SELECT TOP number|percent column_name(s) FROM
table_name;
• MySQL Syntax:
• SELECT column_name(s) FROM table_name LIMIT number;
• Examples:
1. SELECT TOP 2 * FROM Customers;
2. SELECT TOP 50 PERCENT * FROM Customers;
3. SELECT * FROM Persons LIMIT 5;
2:04 AM
Gharjistan University Computer Science
Faculty Farah Branch
4
SQL LIKE Operator:
• The LIKE operator is used in
a WHERE clause to search
for a specified pattern in a
column.
• Syntax:
• SELECT column_name(s)
FROM table_name
WHERE column_name LIKE
pattern;
•‫عملیه‬like‫واره‬ ‫جمله‬ ‫در‬where
‫در‬ ‫خاص‬ ‫شیوه‬ ‫یک‬ ‫دریافتن‬ ‫برای‬
‫میرود‬ ‫بکار‬ ‫ستون‬ ‫یک‬.
•‫ساختار‬:
• SELECT column_name(s)
FROM table_name
WHERE column_name LIKE
pattern;
2:04 AM
Gharjistan University Computer Science
Faculty Farah Branch
5
Continue…
• Examples:
• SELECT * FROM Customers WHERE City LIKE 's%';
• SELECT * FROM Customers WHERE City LIKE '%s';
• SELECT * FROM Customers WHERE Country LIKE '%land%';
2:04 AM
Gharjistan University Computer Science
Faculty Farah Branch
6
SQL IN Operator:
• The IN operator allows you
to specify multiple values in
a WHERE clause.
• Syntax:
• SELECT column_name(s)
FROM table_name
WHERE column_name IN
(value1,value2,...);
•‫عملیه‬IN‫کردن‬ ‫مشخص‬ ‫بخاطر‬
‫واره‬ ‫جمله‬ ‫در‬ ‫قیمت‬ ‫چندین‬where
‫میرود‬ ‫بکار‬.
•‫ساختار‬:
• SELECT column_name(s)
FROM table_name
WHERE column_name IN
(value1,value2,...);
2:04 AM
Gharjistan University Computer Science
Faculty Farah Branch
7
Continue…
• Example:
• SELECT * FROM Customers WHERE City IN ('Paris','London');
2:04 AM
Gharjistan University Computer Science
Faculty Farah Branch
8
SQL INSERT INTO Statement:
• The INSERT INTO statement
is used to insert new
records in a table.
• Syntax:
• It is possible to write the
INSERT INTO statement in
two forms.
• The first form does not
specify the column names
where the data will be
inserted, only their values
as follow:
•‫دستور‬insert into‫درج‬ ‫برای‬
‫دیتابیس‬ ‫به‬ ‫جدید‬ ‫ریکارد‬ ‫کردن‬‫بکار‬
‫میرود‬.
•‫ساختار‬:
•‫دستور‬insert into‫شکل‬ ‫بدو‬
‫شود‬ ‫نوشته‬ ‫ممکن‬.
•‫نمی‬ ‫مشخص‬ ‫ها‬ ‫ستون‬ ‫که‬ ‫اول‬ ‫روش‬
‫جدول‬ ‫یک‬ ‫درج‬ ‫ها‬ ‫قیمت‬ ‫فقط‬ ‫و‬ ‫شود‬
‫ذیل‬ ‫قرار‬ ‫میگردد‬:
Nangarhar University Database1 9
Continue…
• INSERT INTO table_name
VALUES
(value1,value2,value3,...);
• The second form specifies
both the column names and
the values to be inserted:
• INSERT INTO table_name
(column1,column2,column3,
...)
VALUES
(value1,value2,value3,...);
• INSERT INTO table_name
VALUES
(value1,value2,value3,...);
•‫هم‬ ‫و‬ ‫ها‬ ‫ستون‬ ‫هم‬ ‫دوم‬ ‫روش‬ ‫در‬
‫مشخص‬ ‫میگردد‬ ‫درج‬ ‫که‬ ‫های‬ ‫قیمت‬
‫ذیل‬ ‫قرار‬ ‫میشود‬:
• INSERT INTO table_name
(column1,column2,column3,
...)
VALUES
(value1,value2,value3,...);
Nangarhar University Database1 10
Continue…
• Examples:
1. INSERT INTO Customers (CustomerName, City, Country)
VALUES ('Cardinal', 'Stavanger', 'Norway');
2. INSERT INTO Customers
VALUES ('Cardinal', 'Stavanger', 'Norway');
2:04 AM
Gharjistan University Computer Science
Faculty Farah Branch
11
SQL UPDATE Statement:
• The UPDATE statement is
used to update existing
records in a table.
• Syntax:
UPDATE table_name
SET column1=value1,
column2=value2,...
WHERE
some_column=some_value;
•‫دستور‬Update‫روز‬ ‫به‬ ‫برای‬
‫یک‬ ‫در‬ ‫موجود‬ ‫ریکاردهای‬ ‫کردن‬
‫میرود‬ ‫بکار‬ ‫جدول‬.
•‫ساختار‬:
• UPDATE table_name
SET column1=value1,
column2=value2,...
WHERE
some_column=some_value;
2:04 AM
Gharjistan University Computer Science
Faculty Farah Branch
12
Continue…
• Examples:
• UPDATE Customers SET ContactName='Alfred Schmidt',
City='Hamburg‘ WHERE CustomerName='Alfreds Futterkiste';
2:04 AM
Gharjistan University Computer Science
Faculty Farah Branch
13
Continue…
• Update Warning!
• Be careful when updating
records. If we had omitted
the WHERE clause, in the
example above, like this:
• UPDATE Customers
SET ContactName='Alfred
Schmidt', City='Hamburg';
• All the records in the
customer table will be
updated.
•‫درآوردن‬ ‫روز‬ ‫به‬ ‫هشدار‬:
•‫آوردن‬ ‫روز‬ ‫به‬ ‫در‬ ‫که‬ ‫باشید‬ ‫متوجه‬
‫واره‬ ‫جمله‬ ‫هرگاه‬ ‫ریکاردها‬where
‫رو‬ ‫به‬ ‫ها‬ ‫ریکارد‬ ‫تمام‬ ‫ننویسیم‬ ‫را‬‫ز‬
‫ذیل‬ ‫قرار‬ ‫شد‬ ‫خواهد‬ ‫درآورده‬:
• UPDATE Customers
SET ContactName='Alfred
Schmidt', City='Hamburg';
2:04 AM
Gharjistan University Computer Science
Faculty Farah Branch
14
SQL DELETE Statement:
• The DELETE statement is
used to delete records in a
table.
• Syntax:
• DELETE FROM table_name
WHERE
some_column=some_value;
•‫دستور‬delete‫کردن‬ ‫حذف‬ ‫برای‬
‫بکار‬ ‫جدول‬ ‫یک‬ ‫در‬ ‫ریکاردها‬
‫میرود‬.
•‫ساختار‬:
• DELETE FROM table_name
WHERE
some_column=some_value;
2:04 AM
Gharjistan University Computer Science
Faculty Farah Branch
15
Continue…
• Examples:
• DELETE FROM Customers WHERE CustomerName='Alfreds
Futterkiste' AND ContactName='Maria Anders';
Nangarhar University Database1 16
Delete All Data:
• It is possible to delete all
rows in a table without
deleting the table. This
means that the table
structure, attributes, and
indexes will be intact:
• Syntax:
• DELETE FROM table_name;
or
DELETE * FROM
table_name;
•‫یک‬ ‫در‬ ‫سطرها‬ ‫تمام‬ ‫که‬ ‫است‬ ‫ممکن‬
‫حذف‬ ‫جدول‬ ‫خود‬ ‫اینکه‬ ‫بدون‬ ‫جدول‬
‫کرد‬ ‫حذف‬ ‫شود‬.‫که‬ ‫معنا‬ ‫این‬ ‫به‬
‫و‬ ‫خاصه‬ ‫صفات‬ ،‫جدول‬ ‫ساختار‬
index‫باقی‬ ‫درست‬ ‫و‬ ‫ثابت‬ ‫آن‬ ‫های‬
‫ماند‬ ‫خواهد‬.
•‫ساختار‬:
• DELETE FROM table_name;
or
DELETE * FROM
table_name;
Nangarhar University Database1 17
Continue…
• Note: Be very careful when
deleting records. You
cannot undo this
statement!
•‫نوت‬:
•‫هاه‬ ‫ریکارد‬ ‫کردن‬ ‫حذف‬ ‫وقت‬ ‫در‬
‫دوبا‬ ‫چونکه‬ ‫باشید‬ ‫مواظب‬ ‫بسیار‬‫ره‬
‫را‬ ‫دستور‬ ‫این‬ ‫که‬ ‫نمیتوانید‬undo
‫کنید‬.
Nangarhar University Database1 18
2:04 AM
Gharjistan University Computer Science
Faculty Farah Branch
19

More Related Content

PDF
Mysql Explain Explained
PPT
Oracle SQL, PL/SQL best practices
DOC
Pl sql using_xml
PPTX
Database Testing
PPS
Procedures/functions of rdbms
PPT
Oracle Baisc Tutorial
Mysql Explain Explained
Oracle SQL, PL/SQL best practices
Pl sql using_xml
Database Testing
Procedures/functions of rdbms
Oracle Baisc Tutorial

What's hot (17)

PPT
Oracle PL/SQL Bulk binds
PPTX
Oracle: Procedures
DOC
PPTX
Sql Functions And Procedures
PDF
MySQL Query And Index Tuning
PPTX
Lab1 select statement
PPTX
Sql server ___________session_18(stored procedures)
PPTX
How mysql choose the execution plan
PPTX
SignalR & SQL Dependency
PPT
plsql Lec11
PPT
Myth busters - performance tuning 101 2007
PPTX
Sql parametrized queries
PPT
Oracle SQL, PL/SQL Performance tuning
PPT
Oracle Forms : Query Triggers
PPTX
PPSX
Sql triggers
Oracle PL/SQL Bulk binds
Oracle: Procedures
Sql Functions And Procedures
MySQL Query And Index Tuning
Lab1 select statement
Sql server ___________session_18(stored procedures)
How mysql choose the execution plan
SignalR & SQL Dependency
plsql Lec11
Myth busters - performance tuning 101 2007
Sql parametrized queries
Oracle SQL, PL/SQL Performance tuning
Oracle Forms : Query Triggers
Sql triggers
Ad

Viewers also liked (20)

PPTX
How to speak in public
PPTX
Lecture 1. java database connectivity
PPTX
E learning ict4-d_presentation
PPTX
Web design - Working with forms in HTML
PDF
Tarjumaye jadwali-quran-karim-pdf
 
PPTX
How to take control of your l ife
PPTX
Introduction to graph databases in term of neo4j
PDF
Bitcharities Cause Presentation
PDF
PPTX
Simple past
PPTX
Computational Advertising
PDF
Web app development_cookies_sessions_14
PDF
Web Application Security and Awareness
PDF
Fondo gallerie storiche romane - Destinazione Donna - catalogo della mostra
PDF
Google Search Console
PPT
Enterprise Resource Planning using Odoo/OpenERP in Afghanistan
PDF
Architecting for failure - Why are distributed systems hard?
PPT
Mite Nroc Beebe Aeqa
PDF
Bootstrap day3
PPTX
Monitoring Virtualized Environments
How to speak in public
Lecture 1. java database connectivity
E learning ict4-d_presentation
Web design - Working with forms in HTML
Tarjumaye jadwali-quran-karim-pdf
 
How to take control of your l ife
Introduction to graph databases in term of neo4j
Bitcharities Cause Presentation
Simple past
Computational Advertising
Web app development_cookies_sessions_14
Web Application Security and Awareness
Fondo gallerie storiche romane - Destinazione Donna - catalogo della mostra
Google Search Console
Enterprise Resource Planning using Odoo/OpenERP in Afghanistan
Architecting for failure - Why are distributed systems hard?
Mite Nroc Beebe Aeqa
Bootstrap day3
Monitoring Virtualized Environments
Ad

Similar to Introduction to sql_02 (17)

PPTX
Introduction to sql_01
PPTX
SQL Operator - for advance database concept
PPTX
WEEK-2 DML and operators power point presentation
PPT
SQL : introduction
PPTX
SQL Tutorial for Beginners
PPTX
Lecture - MY-SQL/ SQL Commands - DDL.pptx
DOCX
Farheen abdul hameed ip project (MY SQL);
PDF
Complete SQL Tutorial In Hindi By Rishabh Mishra.pdf
PDF
Complete SQL Tutorial In Hindi By Rishabh Mishra (Basic to Advance).pdf
PPTX
Null values, insert, delete and update in database
PDF
Sql tutorial
PPTX
06.01 sql select distinct
PPTX
Lecture 21 Insert Update Delete.pptx
PDF
Chapter Five - Relational Query Languages.pdf
Introduction to sql_01
SQL Operator - for advance database concept
WEEK-2 DML and operators power point presentation
SQL : introduction
SQL Tutorial for Beginners
Lecture - MY-SQL/ SQL Commands - DDL.pptx
Farheen abdul hameed ip project (MY SQL);
Complete SQL Tutorial In Hindi By Rishabh Mishra.pdf
Complete SQL Tutorial In Hindi By Rishabh Mishra (Basic to Advance).pdf
Null values, insert, delete and update in database
Sql tutorial
06.01 sql select distinct
Lecture 21 Insert Update Delete.pptx
Chapter Five - Relational Query Languages.pdf

More from Esmatullah Adel (6)

PPTX
Mapping in database
PPTX
Enhanced entity relationship model
PPTX
Relationship in database
PPTX
Identifiers in database
PPTX
Requirements analysis
PPTX
Introduction to database
Mapping in database
Enhanced entity relationship model
Relationship in database
Identifiers in database
Requirements analysis
Introduction to database

Recently uploaded (20)

PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
A Presentation on Artificial Intelligence
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Empathic Computing: Creating Shared Understanding
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Modernizing your data center with Dell and AMD
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Cloud computing and distributed systems.
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Electronic commerce courselecture one. Pdf
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Chapter 3 Spatial Domain Image Processing.pdf
A Presentation on Artificial Intelligence
Network Security Unit 5.pdf for BCA BBA.
Empathic Computing: Creating Shared Understanding
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Modernizing your data center with Dell and AMD
NewMind AI Weekly Chronicles - August'25 Week I
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Digital-Transformation-Roadmap-for-Companies.pptx
Cloud computing and distributed systems.
Dropbox Q2 2025 Financial Results & Investor Presentation
The Rise and Fall of 3GPP – Time for a Sabbatical?
“AI and Expert System Decision Support & Business Intelligence Systems”
Electronic commerce courselecture one. Pdf
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Mobile App Security Testing_ A Comprehensive Guide.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Understanding_Digital_Forensics_Presentation.pptx

Introduction to sql_02

  • 1. Introduction to SQL_02 ‫کننده‬ ‫تهیه‬:‫عادل‬ ‫هللا‬ ‫عصمت‬ ‫با‬ ‫معرفی‬SQL
  • 2. Topics: • SQL SELECT TOP Clause • SQL LIKE Operator • SQL IN Operator • SQL INSERT INTO Statement • SQL UPDATE Statement • SQL DELETE Statement •‫واره‬ ‫جمله‬Select top،SQL •‫عملیه‬like،SQL •‫عملیه‬In،SQL •‫دستور‬Insert into،SQL •‫دستور‬update،SQL •‫دستور‬delete،SQL 2:04 AM Gharjistan University Computer Science Faculty Farah Branch 2
  • 3. SQL SELECT TOP Clause: • The SELECT TOP clause is used to specify the number of records to return. • The SELECT TOP clause can be very useful on large tables with thousands of records. Returning a large number of records can impact on performance. • Note: Not all database systems support the SELECT TOP clause. •‫واره‬ ‫جمله‬select top‫برای‬ ‫ریکاردهایکه‬ ‫تعداد‬ ‫کردن‬ ‫مشخص‬ ‫میرود‬ ‫بکار‬ ‫میشود‬ ‫داده‬ ‫برگشت‬. •‫واره‬ ‫جمله‬select top‫جدول‬ ‫در‬ ‫هزاران‬ ‫تعداد‬ ‫به‬ ‫که‬ ‫بزرگ‬ ‫های‬ ‫واقع‬ ‫مفید‬ ‫بسیار‬ ‫داشته‬ ‫ریکارد‬‫شده‬ ‫میتواند‬.‫ب‬ ‫ریکاردها‬ ‫دادن‬ ‫برگشت‬‫ه‬ ‫اجراعات‬ ‫کیفیت‬ ‫روی‬ ‫زیاد‬ ‫تعداد‬ ‫میتواند‬ ‫مانده‬ ‫تأثیر‬. •‫یادداشت‬:‫دیتاب‬ ‫های‬ ‫سیستم‬ ‫تمام‬‫یس‬ ‫واره‬ ‫جمله‬select top‫پشتیبانی‬ ‫را‬ ‫نمیکند‬. 2:04 AM Gharjistan University Computer Science Faculty Farah Branch 3
  • 4. Continue… • SQL Server / MS Access Syntax: • SELECT TOP number|percent column_name(s) FROM table_name; • MySQL Syntax: • SELECT column_name(s) FROM table_name LIMIT number; • Examples: 1. SELECT TOP 2 * FROM Customers; 2. SELECT TOP 50 PERCENT * FROM Customers; 3. SELECT * FROM Persons LIMIT 5; 2:04 AM Gharjistan University Computer Science Faculty Farah Branch 4
  • 5. SQL LIKE Operator: • The LIKE operator is used in a WHERE clause to search for a specified pattern in a column. • Syntax: • SELECT column_name(s) FROM table_name WHERE column_name LIKE pattern; •‫عملیه‬like‫واره‬ ‫جمله‬ ‫در‬where ‫در‬ ‫خاص‬ ‫شیوه‬ ‫یک‬ ‫دریافتن‬ ‫برای‬ ‫میرود‬ ‫بکار‬ ‫ستون‬ ‫یک‬. •‫ساختار‬: • SELECT column_name(s) FROM table_name WHERE column_name LIKE pattern; 2:04 AM Gharjistan University Computer Science Faculty Farah Branch 5
  • 6. Continue… • Examples: • SELECT * FROM Customers WHERE City LIKE 's%'; • SELECT * FROM Customers WHERE City LIKE '%s'; • SELECT * FROM Customers WHERE Country LIKE '%land%'; 2:04 AM Gharjistan University Computer Science Faculty Farah Branch 6
  • 7. SQL IN Operator: • The IN operator allows you to specify multiple values in a WHERE clause. • Syntax: • SELECT column_name(s) FROM table_name WHERE column_name IN (value1,value2,...); •‫عملیه‬IN‫کردن‬ ‫مشخص‬ ‫بخاطر‬ ‫واره‬ ‫جمله‬ ‫در‬ ‫قیمت‬ ‫چندین‬where ‫میرود‬ ‫بکار‬. •‫ساختار‬: • SELECT column_name(s) FROM table_name WHERE column_name IN (value1,value2,...); 2:04 AM Gharjistan University Computer Science Faculty Farah Branch 7
  • 8. Continue… • Example: • SELECT * FROM Customers WHERE City IN ('Paris','London'); 2:04 AM Gharjistan University Computer Science Faculty Farah Branch 8
  • 9. SQL INSERT INTO Statement: • The INSERT INTO statement is used to insert new records in a table. • Syntax: • It is possible to write the INSERT INTO statement in two forms. • The first form does not specify the column names where the data will be inserted, only their values as follow: •‫دستور‬insert into‫درج‬ ‫برای‬ ‫دیتابیس‬ ‫به‬ ‫جدید‬ ‫ریکارد‬ ‫کردن‬‫بکار‬ ‫میرود‬. •‫ساختار‬: •‫دستور‬insert into‫شکل‬ ‫بدو‬ ‫شود‬ ‫نوشته‬ ‫ممکن‬. •‫نمی‬ ‫مشخص‬ ‫ها‬ ‫ستون‬ ‫که‬ ‫اول‬ ‫روش‬ ‫جدول‬ ‫یک‬ ‫درج‬ ‫ها‬ ‫قیمت‬ ‫فقط‬ ‫و‬ ‫شود‬ ‫ذیل‬ ‫قرار‬ ‫میگردد‬: Nangarhar University Database1 9
  • 10. Continue… • INSERT INTO table_name VALUES (value1,value2,value3,...); • The second form specifies both the column names and the values to be inserted: • INSERT INTO table_name (column1,column2,column3, ...) VALUES (value1,value2,value3,...); • INSERT INTO table_name VALUES (value1,value2,value3,...); •‫هم‬ ‫و‬ ‫ها‬ ‫ستون‬ ‫هم‬ ‫دوم‬ ‫روش‬ ‫در‬ ‫مشخص‬ ‫میگردد‬ ‫درج‬ ‫که‬ ‫های‬ ‫قیمت‬ ‫ذیل‬ ‫قرار‬ ‫میشود‬: • INSERT INTO table_name (column1,column2,column3, ...) VALUES (value1,value2,value3,...); Nangarhar University Database1 10
  • 11. Continue… • Examples: 1. INSERT INTO Customers (CustomerName, City, Country) VALUES ('Cardinal', 'Stavanger', 'Norway'); 2. INSERT INTO Customers VALUES ('Cardinal', 'Stavanger', 'Norway'); 2:04 AM Gharjistan University Computer Science Faculty Farah Branch 11
  • 12. SQL UPDATE Statement: • The UPDATE statement is used to update existing records in a table. • Syntax: UPDATE table_name SET column1=value1, column2=value2,... WHERE some_column=some_value; •‫دستور‬Update‫روز‬ ‫به‬ ‫برای‬ ‫یک‬ ‫در‬ ‫موجود‬ ‫ریکاردهای‬ ‫کردن‬ ‫میرود‬ ‫بکار‬ ‫جدول‬. •‫ساختار‬: • UPDATE table_name SET column1=value1, column2=value2,... WHERE some_column=some_value; 2:04 AM Gharjistan University Computer Science Faculty Farah Branch 12
  • 13. Continue… • Examples: • UPDATE Customers SET ContactName='Alfred Schmidt', City='Hamburg‘ WHERE CustomerName='Alfreds Futterkiste'; 2:04 AM Gharjistan University Computer Science Faculty Farah Branch 13
  • 14. Continue… • Update Warning! • Be careful when updating records. If we had omitted the WHERE clause, in the example above, like this: • UPDATE Customers SET ContactName='Alfred Schmidt', City='Hamburg'; • All the records in the customer table will be updated. •‫درآوردن‬ ‫روز‬ ‫به‬ ‫هشدار‬: •‫آوردن‬ ‫روز‬ ‫به‬ ‫در‬ ‫که‬ ‫باشید‬ ‫متوجه‬ ‫واره‬ ‫جمله‬ ‫هرگاه‬ ‫ریکاردها‬where ‫رو‬ ‫به‬ ‫ها‬ ‫ریکارد‬ ‫تمام‬ ‫ننویسیم‬ ‫را‬‫ز‬ ‫ذیل‬ ‫قرار‬ ‫شد‬ ‫خواهد‬ ‫درآورده‬: • UPDATE Customers SET ContactName='Alfred Schmidt', City='Hamburg'; 2:04 AM Gharjistan University Computer Science Faculty Farah Branch 14
  • 15. SQL DELETE Statement: • The DELETE statement is used to delete records in a table. • Syntax: • DELETE FROM table_name WHERE some_column=some_value; •‫دستور‬delete‫کردن‬ ‫حذف‬ ‫برای‬ ‫بکار‬ ‫جدول‬ ‫یک‬ ‫در‬ ‫ریکاردها‬ ‫میرود‬. •‫ساختار‬: • DELETE FROM table_name WHERE some_column=some_value; 2:04 AM Gharjistan University Computer Science Faculty Farah Branch 15
  • 16. Continue… • Examples: • DELETE FROM Customers WHERE CustomerName='Alfreds Futterkiste' AND ContactName='Maria Anders'; Nangarhar University Database1 16
  • 17. Delete All Data: • It is possible to delete all rows in a table without deleting the table. This means that the table structure, attributes, and indexes will be intact: • Syntax: • DELETE FROM table_name; or DELETE * FROM table_name; •‫یک‬ ‫در‬ ‫سطرها‬ ‫تمام‬ ‫که‬ ‫است‬ ‫ممکن‬ ‫حذف‬ ‫جدول‬ ‫خود‬ ‫اینکه‬ ‫بدون‬ ‫جدول‬ ‫کرد‬ ‫حذف‬ ‫شود‬.‫که‬ ‫معنا‬ ‫این‬ ‫به‬ ‫و‬ ‫خاصه‬ ‫صفات‬ ،‫جدول‬ ‫ساختار‬ index‫باقی‬ ‫درست‬ ‫و‬ ‫ثابت‬ ‫آن‬ ‫های‬ ‫ماند‬ ‫خواهد‬. •‫ساختار‬: • DELETE FROM table_name; or DELETE * FROM table_name; Nangarhar University Database1 17
  • 18. Continue… • Note: Be very careful when deleting records. You cannot undo this statement! •‫نوت‬: •‫هاه‬ ‫ریکارد‬ ‫کردن‬ ‫حذف‬ ‫وقت‬ ‫در‬ ‫دوبا‬ ‫چونکه‬ ‫باشید‬ ‫مواظب‬ ‫بسیار‬‫ره‬ ‫را‬ ‫دستور‬ ‫این‬ ‫که‬ ‫نمیتوانید‬undo ‫کنید‬. Nangarhar University Database1 18
  • 19. 2:04 AM Gharjistan University Computer Science Faculty Farah Branch 19