SlideShare a Scribd company logo
2
Most read
3
Most read
21
Most read
SQL
Structure Query Language
Represented By: Zain Raza
Discipline: Information Technology
5th Semester
Group # 8
Outlines
• What is SQL?
• What SQL Can do?
• Using SQL in Your Web Site
• SQL Statements
• Semicolon after SQL Statements?
• Important SQL Commands
• Create & Drop Database
• RDBMS
• keys
• Demo Database
What is SQL?
• SQL stands for Structured Query Language
• SQL is NOT case sensitive: select is the same as SELECT
• SQL lets you access and manipulate (handle or control) databases
• SQL is an ANSI (American National Standards Institute) standard
What SQL Can do?
• SQL can execute queries against a database
• SQL can retrieve data from a database
• SQL can insert records in a database
• SQL can update records in a database
• SQL can delete records from a database
• SQL can create new databases
• SQL can create new tables in a database
• SQL can create stored procedures in a database
• SQL can create views in a database
• SQL can set permissions on tables, procedures, and views
• there are different versions of the SQL language and they all support at least the major
commands (such as SELECT, UPDATE, DELETE, INSERT, WHERE) statements.
Using SQL in Your Web Site
To build a web site that shows data from a database, you will need:
• An RDBMS database program (i.e. MS Access, SQL Server, MySQL)
• To use a server-side scripting language, like PHP or ASP
• To use SQL to get the data you want
• To use HTML / CSS
SQL Statements
1- SELECT * FROM Customers;
2- SELECT column_name,column_name FROM table_name;
3- SELECT * FROM Customers WHERE Country='Mexico';
4- INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode,
Country)
VALUES ('Cardinal','Tom B. Erichsen','Skagen 21','Stavanger','4006','Norway');
5- UPDATE Customers
SET ContactName='Alfred Schmidt', City='Hamburg'
WHERE CustomerName='Alfreds Futterkiste';
6- DELETE FROM Customers WHERE CustomerName='Alfreds Futterkiste' AND
ContactName='Maria Anders';
7- SELECT * FROM Customers WHERE Country='Germany' AND City='Berlin';
8- SELECT * FROM Customers WHERE City='Berlin' OR City='München';
Semicolon after SQL Statements?
• Some database systems require a semicolon at the end of each
SQL statement.
• Semicolon is the standard way to separate each SQL statement in
database systems that allow more than one SQL statement to be
executed in the same call to the server.
Important SQL Commands
• SELECT - extracts data from a database
• UPDATE - updates data in a database
• DELETE - deletes data from a database
• INSERT INTO - inserts new data into a database
• CREATE DATABASE - creates a new database
• ALTER DATABASE - modifies a database
• CREATE TABLE - creates a new table
• ALTER TABLE - modifies a table
• DROP TABLE - deletes a table
• CREATE INDEX - creates an index (search key)
• DROP INDEX - deletes an index
SQL CREATE & Drop Database
Example:
If you want to create new database <testDB>, then CREATE DATABASE statement
would be as follows:
SQL> CREATE DATABASE testDB
Example:
If you want to delete an existing database <testDB>, then DROP DATABASE
statement would be as follows:
SQL> DROP DATABASE testDB;
RDBMS
• RDBMS stands for Relational Database Management System.
• RDBMS is the basis for SQL, and for all modern database systems
such as MS SQL Server, IBM DB2, Oracle, MySQL, and Microsoft
Access.
• The data in RDBMS is stored in database objects called tables.
• A table is a collection of related data entries and it consists of
columns and rows.
History of MySQL :
• MySQL is an open source SQL database, which is developed by Swedish company MySQL
AB. MySQL is pronounced "my ess-que-ell," in contrast with SQL, pronounced "sequel."
• MySQL is supporting many different platforms including Microsoft Windows, the major
Linux distributions, UNIX, and Mac OS X.
• MySQL has free and paid versions, depending on its usage (non-commercial/commercial)
and features. MySQL comes with a very fast, multi-threaded, multi-user, and robust SQL
database server. History:
• Development of MySQL by Michael Widenius & David Ax mark beginning in 1994.
• First internal release on 23 May 1995.
• Windows version was released on 8 January 1998 for Windows 95 and NT.
• Version 5.1: production release 27 November 2008.
Primary Key:
• A primary key is a field in a table which uniquely identifies each
row/record in a database table. Primary keys must contain unique
values. A primary key column cannot have NULL values.
• A table can have only one primary key, which may consist of single
or multiple fields. When multiple fields are used as a primary key,
they are called a composite key.
• If a table has a primary key defined on any field(s), then you can
not have two records having the same value of that field(s).
Create Primary Key :
• To create a PRIMARY KEY constraint on the "ID" column when
CUSTOMERS table already exists, use the following SQL syntax:
ALTER TABLE CUSTOMER ADD PRIMARY KEY (ID);
Delete Primary Key:
• You can clear the primary key constraints from the table, Use
Syntax:
• ALTER TABLE CUSTOMERS DROP PRIMARY KEY ;
Foreign Key:
• A foreign key is a key used to link two tables together. This is
sometimes called a referencing key.
• Foreign Key is a column or a combination of columns whose values
match a Primary Key in a different table.
• The relationship between 2 tables matches the Primary Key in one
of the tables with a Foreign Key in the second table.
Create foreign key :
• ALTER TABLE ORDERS
ADD FOREIGN KEY (Customer_ID) REFERENCES CUSTOMERS (ID)
Delete Foreign Key :
• To drop a FOREIGN KEY constraint, use the following SQL:
ALTER TABLE ORDERS
DROP FOREIGN KEY;
CHECK Constraint:
• The CHECK Constraint enables a condition to check the value being entered into
a record. If the condition evaluates to false, the record violates the constraint
and isn’t entered into the table. Example: For example, the following SQL
creates a new table called CUSTOMERS and adds five columns. Here, we add a
CHECK with AGE column, so that you can not have any CUSTOMER below 18
years:
CREATE TABLE CUSTOMERS(
ID INT NOT NULL,
NAME VARCHAR (20) NOT NULL,
AGE INT NOT NULL CHECK (AGE >= 18),
ADDRESS CHAR (25) ,
SALARY DECIMAL (18, 2),
PRIMARY KEY (ID)
);
How to add Check Constraint:
• ALTER TABLE CUSTOMERS
• MODIFY AGE INT NOT NULL CHECK (AGE >= 18 )
DROP a CHECK Constraint:
• To drop a CHECK constraint, use the following SQL. This syntax
does not work with MySQL:
ALTER TABLE CUSTOMERS
DROP CONSTRAINT myCheckConstraint;
SQL Operators :
• Operators are used to specify conditions in an SQL statement and
to serve as conjunctions for multiple conditions in a statement.
Arithmetic operators
Comparison operators
Logical operators
Arithmetic operators :
Comparison operators :
Logical operators :

More Related Content

PPTX
Introduction to SQL
Ehsan Hamzei
 
PPTX
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
LGS, GBHS&IC, University Of South-Asia, TARA-Technologies
 
PPTX
Sql commands
Pooja Dixit
 
PPTX
Visual studio
AvinashChunduri2
 
PPTX
SQL Commands
Sachidananda M H
 
PDF
Sql commands
Prof. Dr. K. Adisesha
 
PPTX
PPT ON Arduino
Ravi Phadtare
 
Introduction to SQL
Ehsan Hamzei
 
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
LGS, GBHS&IC, University Of South-Asia, TARA-Technologies
 
Sql commands
Pooja Dixit
 
Visual studio
AvinashChunduri2
 
SQL Commands
Sachidananda M H
 
Sql commands
Prof. Dr. K. Adisesha
 
PPT ON Arduino
Ravi Phadtare
 

What's hot (20)

PDF
SQL Overview
Stewart Rogers
 
PPT
Introduction to-sql
BG Java EE Course
 
PPTX
SQL - DML and DDL Commands
Shrija Madhu
 
PDF
Chapter 4 Structured Query Language
Eddyzulham Mahluzydde
 
PPT
Introduction to sql
VARSHAKUMARI49
 
PDF
SQL Joins With Examples | Edureka
Edureka!
 
PPT
Mysql
TSUBHASHRI
 
PPTX
Structured Query Language (SQL)
Syed Hassan Ali
 
PPTX
Basic SQL and History
SomeshwarMoholkar
 
PPT
Introduction to structured query language (sql)
Sabana Maharjan
 
PPTX
Lab2 ddl commands
Balqees Al.Mubarak
 
PPTX
Structured query language(sql)ppt
Gowarthini
 
PDF
Sql tutorial
Rumman Ansari
 
PDF
PL/SQL TRIGGERS
Lakshman Basnet
 
PDF
MySQL for beginners
Saeid Zebardast
 
PPT
SQL Tutorial - Basic Commands
1keydata
 
PPTX
Sql and Sql commands
Knowledge Center Computer
 
PPTX
introdution to SQL and SQL functions
farwa waqar
 
PPTX
SQL commands
GirdharRatne
 
SQL Overview
Stewart Rogers
 
Introduction to-sql
BG Java EE Course
 
SQL - DML and DDL Commands
Shrija Madhu
 
Chapter 4 Structured Query Language
Eddyzulham Mahluzydde
 
Introduction to sql
VARSHAKUMARI49
 
SQL Joins With Examples | Edureka
Edureka!
 
Mysql
TSUBHASHRI
 
Structured Query Language (SQL)
Syed Hassan Ali
 
Basic SQL and History
SomeshwarMoholkar
 
Introduction to structured query language (sql)
Sabana Maharjan
 
Lab2 ddl commands
Balqees Al.Mubarak
 
Structured query language(sql)ppt
Gowarthini
 
Sql tutorial
Rumman Ansari
 
PL/SQL TRIGGERS
Lakshman Basnet
 
MySQL for beginners
Saeid Zebardast
 
SQL Tutorial - Basic Commands
1keydata
 
Sql and Sql commands
Knowledge Center Computer
 
introdution to SQL and SQL functions
farwa waqar
 
SQL commands
GirdharRatne
 
Ad

Similar to Presentation slides of Sequence Query Language (SQL) (20)

PPTX
shs tvl ict_Programming Introduction to SQl.pptx
Joseph Camarote
 
PPTX
slides about : Introduction_to_SQL.pptx
DrMarwaElsherif
 
PPTX
Introduction to SQL
MLG College of Learning, Inc
 
PPT
MySQL intro
David Rajah Selvaraj
 
PPT
MySQL intro
David Rajah Selvaraj
 
PPTX
SQL Overview-II23-PF20SA8Z.pptx
MAYURUGALE6
 
PPTX
SQL Overview.pptx
MAYURUGALE6
 
PPTX
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
WrushabhShirsat3
 
PPTX
unit-ii.pptx
NilamHonmane
 
PDF
Reviewing SQL Concepts
Hitesh Mohapatra
 
PDF
SQL Intro
koppenolski
 
PPTX
Database Akjljljlkjlkjkljlkjldiministration.pptx
EliasPetros
 
PPT
INTRODUCTION TO SQL QUERIES REALTED BRIEF
VADAPALLYPRAVEENKUMA1
 
PPTX
SQL UNIT FOUR.pptxDiscDiscoverabilitDiscoverability Scorey Scoreoverability S...
sultanahimed3
 
PPTX
SQL PPT.pptx
Kulbir4
 
PPTX
SQL NAD DB.pptx
muhammadhumza26
 
PDF
SQL Complete Tutorial. All Topics Covered
Danish Mehraj
 
PPTX
structure query language with DATABASE MANAGEMENT
RSathyaPriyaCSEKIOT
 
PPTX
SQL Assessment Command Statements
Shaun Wilson
 
PDF
SQL Fundamentals - Lecture 2
MuhammadWaheed44
 
shs tvl ict_Programming Introduction to SQl.pptx
Joseph Camarote
 
slides about : Introduction_to_SQL.pptx
DrMarwaElsherif
 
Introduction to SQL
MLG College of Learning, Inc
 
SQL Overview-II23-PF20SA8Z.pptx
MAYURUGALE6
 
SQL Overview.pptx
MAYURUGALE6
 
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
WrushabhShirsat3
 
unit-ii.pptx
NilamHonmane
 
Reviewing SQL Concepts
Hitesh Mohapatra
 
SQL Intro
koppenolski
 
Database Akjljljlkjlkjkljlkjldiministration.pptx
EliasPetros
 
INTRODUCTION TO SQL QUERIES REALTED BRIEF
VADAPALLYPRAVEENKUMA1
 
SQL UNIT FOUR.pptxDiscDiscoverabilitDiscoverability Scorey Scoreoverability S...
sultanahimed3
 
SQL PPT.pptx
Kulbir4
 
SQL NAD DB.pptx
muhammadhumza26
 
SQL Complete Tutorial. All Topics Covered
Danish Mehraj
 
structure query language with DATABASE MANAGEMENT
RSathyaPriyaCSEKIOT
 
SQL Assessment Command Statements
Shaun Wilson
 
SQL Fundamentals - Lecture 2
MuhammadWaheed44
 
Ad

Recently uploaded (20)

PPTX
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
PDF
Health-The-Ultimate-Treasure (1).pdf/8th class science curiosity /samyans edu...
Sandeep Swamy
 
PPTX
INTESTINALPARASITES OR WORM INFESTATIONS.pptx
PRADEEP ABOTHU
 
PDF
2.Reshaping-Indias-Political-Map.ppt/pdf/8th class social science Exploring S...
Sandeep Swamy
 
PPTX
HEALTH CARE DELIVERY SYSTEM - UNIT 2 - GNM 3RD YEAR.pptx
Priyanshu Anand
 
PPTX
Software Engineering BSC DS UNIT 1 .pptx
Dr. Pallawi Bulakh
 
PPTX
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
DOCX
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
PPTX
An introduction to Dialogue writing.pptx
drsiddhantnagine
 
PPTX
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
PPTX
Kanban Cards _ Mass Action in Odoo 18.2 - Odoo Slides
Celine George
 
PPTX
How to Track Skills & Contracts Using Odoo 18 Employee
Celine George
 
PDF
Biological Classification Class 11th NCERT CBSE NEET.pdf
NehaRohtagi1
 
PDF
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
PDF
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
PDF
Module 2: Public Health History [Tutorial Slides]
JonathanHallett4
 
PDF
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
PPTX
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
PPTX
BASICS IN COMPUTER APPLICATIONS - UNIT I
suganthim28
 
PPTX
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
Health-The-Ultimate-Treasure (1).pdf/8th class science curiosity /samyans edu...
Sandeep Swamy
 
INTESTINALPARASITES OR WORM INFESTATIONS.pptx
PRADEEP ABOTHU
 
2.Reshaping-Indias-Political-Map.ppt/pdf/8th class social science Exploring S...
Sandeep Swamy
 
HEALTH CARE DELIVERY SYSTEM - UNIT 2 - GNM 3RD YEAR.pptx
Priyanshu Anand
 
Software Engineering BSC DS UNIT 1 .pptx
Dr. Pallawi Bulakh
 
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
An introduction to Dialogue writing.pptx
drsiddhantnagine
 
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
Kanban Cards _ Mass Action in Odoo 18.2 - Odoo Slides
Celine George
 
How to Track Skills & Contracts Using Odoo 18 Employee
Celine George
 
Biological Classification Class 11th NCERT CBSE NEET.pdf
NehaRohtagi1
 
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
Module 2: Public Health History [Tutorial Slides]
JonathanHallett4
 
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
BASICS IN COMPUTER APPLICATIONS - UNIT I
suganthim28
 
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 

Presentation slides of Sequence Query Language (SQL)

  • 1. SQL Structure Query Language Represented By: Zain Raza Discipline: Information Technology 5th Semester Group # 8
  • 2. Outlines • What is SQL? • What SQL Can do? • Using SQL in Your Web Site • SQL Statements • Semicolon after SQL Statements? • Important SQL Commands • Create & Drop Database • RDBMS • keys • Demo Database
  • 3. What is SQL? • SQL stands for Structured Query Language • SQL is NOT case sensitive: select is the same as SELECT • SQL lets you access and manipulate (handle or control) databases • SQL is an ANSI (American National Standards Institute) standard
  • 4. What SQL Can do? • SQL can execute queries against a database • SQL can retrieve data from a database • SQL can insert records in a database • SQL can update records in a database • SQL can delete records from a database • SQL can create new databases • SQL can create new tables in a database • SQL can create stored procedures in a database • SQL can create views in a database • SQL can set permissions on tables, procedures, and views • there are different versions of the SQL language and they all support at least the major commands (such as SELECT, UPDATE, DELETE, INSERT, WHERE) statements.
  • 5. Using SQL in Your Web Site To build a web site that shows data from a database, you will need: • An RDBMS database program (i.e. MS Access, SQL Server, MySQL) • To use a server-side scripting language, like PHP or ASP • To use SQL to get the data you want • To use HTML / CSS
  • 6. SQL Statements 1- SELECT * FROM Customers; 2- SELECT column_name,column_name FROM table_name; 3- SELECT * FROM Customers WHERE Country='Mexico'; 4- INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode, Country) VALUES ('Cardinal','Tom B. Erichsen','Skagen 21','Stavanger','4006','Norway'); 5- UPDATE Customers SET ContactName='Alfred Schmidt', City='Hamburg' WHERE CustomerName='Alfreds Futterkiste'; 6- DELETE FROM Customers WHERE CustomerName='Alfreds Futterkiste' AND ContactName='Maria Anders'; 7- SELECT * FROM Customers WHERE Country='Germany' AND City='Berlin'; 8- SELECT * FROM Customers WHERE City='Berlin' OR City='München';
  • 7. Semicolon after SQL Statements? • Some database systems require a semicolon at the end of each SQL statement. • Semicolon is the standard way to separate each SQL statement in database systems that allow more than one SQL statement to be executed in the same call to the server.
  • 8. Important SQL Commands • SELECT - extracts data from a database • UPDATE - updates data in a database • DELETE - deletes data from a database • INSERT INTO - inserts new data into a database • CREATE DATABASE - creates a new database • ALTER DATABASE - modifies a database • CREATE TABLE - creates a new table • ALTER TABLE - modifies a table • DROP TABLE - deletes a table • CREATE INDEX - creates an index (search key) • DROP INDEX - deletes an index
  • 9. SQL CREATE & Drop Database Example: If you want to create new database <testDB>, then CREATE DATABASE statement would be as follows: SQL> CREATE DATABASE testDB Example: If you want to delete an existing database <testDB>, then DROP DATABASE statement would be as follows: SQL> DROP DATABASE testDB;
  • 10. RDBMS • RDBMS stands for Relational Database Management System. • RDBMS is the basis for SQL, and for all modern database systems such as MS SQL Server, IBM DB2, Oracle, MySQL, and Microsoft Access. • The data in RDBMS is stored in database objects called tables. • A table is a collection of related data entries and it consists of columns and rows.
  • 11. History of MySQL : • MySQL is an open source SQL database, which is developed by Swedish company MySQL AB. MySQL is pronounced "my ess-que-ell," in contrast with SQL, pronounced "sequel." • MySQL is supporting many different platforms including Microsoft Windows, the major Linux distributions, UNIX, and Mac OS X. • MySQL has free and paid versions, depending on its usage (non-commercial/commercial) and features. MySQL comes with a very fast, multi-threaded, multi-user, and robust SQL database server. History: • Development of MySQL by Michael Widenius & David Ax mark beginning in 1994. • First internal release on 23 May 1995. • Windows version was released on 8 January 1998 for Windows 95 and NT. • Version 5.1: production release 27 November 2008.
  • 12. Primary Key: • A primary key is a field in a table which uniquely identifies each row/record in a database table. Primary keys must contain unique values. A primary key column cannot have NULL values. • A table can have only one primary key, which may consist of single or multiple fields. When multiple fields are used as a primary key, they are called a composite key. • If a table has a primary key defined on any field(s), then you can not have two records having the same value of that field(s).
  • 13. Create Primary Key : • To create a PRIMARY KEY constraint on the "ID" column when CUSTOMERS table already exists, use the following SQL syntax: ALTER TABLE CUSTOMER ADD PRIMARY KEY (ID);
  • 14. Delete Primary Key: • You can clear the primary key constraints from the table, Use Syntax: • ALTER TABLE CUSTOMERS DROP PRIMARY KEY ;
  • 15. Foreign Key: • A foreign key is a key used to link two tables together. This is sometimes called a referencing key. • Foreign Key is a column or a combination of columns whose values match a Primary Key in a different table. • The relationship between 2 tables matches the Primary Key in one of the tables with a Foreign Key in the second table.
  • 16. Create foreign key : • ALTER TABLE ORDERS ADD FOREIGN KEY (Customer_ID) REFERENCES CUSTOMERS (ID)
  • 17. Delete Foreign Key : • To drop a FOREIGN KEY constraint, use the following SQL: ALTER TABLE ORDERS DROP FOREIGN KEY;
  • 18. CHECK Constraint: • The CHECK Constraint enables a condition to check the value being entered into a record. If the condition evaluates to false, the record violates the constraint and isn’t entered into the table. Example: For example, the following SQL creates a new table called CUSTOMERS and adds five columns. Here, we add a CHECK with AGE column, so that you can not have any CUSTOMER below 18 years: CREATE TABLE CUSTOMERS( ID INT NOT NULL, NAME VARCHAR (20) NOT NULL, AGE INT NOT NULL CHECK (AGE >= 18), ADDRESS CHAR (25) , SALARY DECIMAL (18, 2), PRIMARY KEY (ID) );
  • 19. How to add Check Constraint: • ALTER TABLE CUSTOMERS • MODIFY AGE INT NOT NULL CHECK (AGE >= 18 )
  • 20. DROP a CHECK Constraint: • To drop a CHECK constraint, use the following SQL. This syntax does not work with MySQL: ALTER TABLE CUSTOMERS DROP CONSTRAINT myCheckConstraint;
  • 21. SQL Operators : • Operators are used to specify conditions in an SQL statement and to serve as conjunctions for multiple conditions in a statement. Arithmetic operators Comparison operators Logical operators