SlideShare a Scribd company logo
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
Most read
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
Most read
22
Arithmetic operators :
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

What's hot (20)

Basic SQL and History
 Basic SQL and History Basic SQL and History
Basic SQL and History
SomeshwarMoholkar
 
Introduction to SQL
Introduction to SQLIntroduction to SQL
Introduction to SQL
Tayyab Hussain
 
introdution to SQL and SQL functions
introdution to SQL and SQL functionsintrodution to SQL and SQL functions
introdution to SQL and SQL functions
farwa waqar
 
Stored procedure
Stored procedureStored procedure
Stored procedure
baabtra.com - No. 1 supplier of quality freshers
 
SQL Overview
SQL OverviewSQL Overview
SQL Overview
Stewart Rogers
 
SQL - DML and DDL Commands
SQL - DML and DDL CommandsSQL - DML and DDL Commands
SQL - DML and DDL Commands
Shrija Madhu
 
Basic sql Commands
Basic sql CommandsBasic sql Commands
Basic sql Commands
MUHAMMED MASHAHIL PUKKUNNUMMAL
 
Sql queries presentation
Sql queries presentationSql queries presentation
Sql queries presentation
NITISH KUMAR
 
Sql Server Basics
Sql Server BasicsSql Server Basics
Sql Server Basics
rainynovember12
 
SQL
SQLSQL
SQL
Vineeta Garg
 
Sql and Sql commands
Sql and Sql commandsSql and Sql commands
Sql and Sql commands
Knowledge Center Computer
 
Introduction to sql
Introduction to sqlIntroduction to sql
Introduction to sql
VARSHAKUMARI49
 
Sql join
Sql  joinSql  join
Sql join
Vikas Gupta
 
SQL commands
SQL commandsSQL commands
SQL commands
GirdharRatne
 
Sql joins
Sql joinsSql joins
Sql joins
Berkeley
 
5. stored procedure and functions
5. stored procedure and functions5. stored procedure and functions
5. stored procedure and functions
Amrit Kaur
 
SQL Views
SQL ViewsSQL Views
SQL Views
baabtra.com - No. 1 supplier of quality freshers
 
Sql select
Sql select Sql select
Sql select
Mudasir Syed
 
Aggregate functions in SQL.pptx
Aggregate functions in SQL.pptxAggregate functions in SQL.pptx
Aggregate functions in SQL.pptx
SherinRappai
 
Procedures and triggers in SQL
Procedures and triggers in SQLProcedures and triggers in SQL
Procedures and triggers in SQL
Vikash Sharma
 

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

SQL Assessment Command Statements
SQL Assessment Command StatementsSQL Assessment Command Statements
SQL Assessment Command Statements
Shaun Wilson
 
about-SQL AND ETC.pptx
about-SQL AND ETC.pptxabout-SQL AND ETC.pptx
about-SQL AND ETC.pptx
jwhuqyqtayaw
 
Relational database management system
Relational database management systemRelational database management system
Relational database management system
Praveen Soni
 
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfytxjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
WrushabhShirsat3
 
unit-ii.pptx
unit-ii.pptxunit-ii.pptx
unit-ii.pptx
NilamHonmane
 
SQL
SQLSQL
SQL
Mohamed Essam
 
sql.pptx
sql.pptxsql.pptx
sql.pptx
slavskrillex
 
SQL.pptx for the begineers and good know
SQL.pptx for the begineers and good knowSQL.pptx for the begineers and good know
SQL.pptx for the begineers and good know
PavithSingh
 
DBMS.pdf
DBMS.pdfDBMS.pdf
DBMS.pdf
Rishab Saini
 
Introduction to SQL
Introduction to SQLIntroduction to SQL
Introduction to SQL
MLG College of Learning, Inc
 
SQL NAD DB.pptx
SQL NAD DB.pptxSQL NAD DB.pptx
SQL NAD DB.pptx
muhammadhumza26
 
Mysql database
Mysql databaseMysql database
Mysql database
mayank78634
 
full detailled SQL notesquestion bank (1).pdf
full detailled SQL notesquestion bank (1).pdffull detailled SQL notesquestion bank (1).pdf
full detailled SQL notesquestion bank (1).pdf
yvpachorib23
 
SQL UNIT FOUR.pptxDiscDiscoverabilitDiscoverability Scorey Scoreoverability S...
SQL UNIT FOUR.pptxDiscDiscoverabilitDiscoverability Scorey Scoreoverability S...SQL UNIT FOUR.pptxDiscDiscoverabilitDiscoverability Scorey Scoreoverability S...
SQL UNIT FOUR.pptxDiscDiscoverabilitDiscoverability Scorey Scoreoverability S...
sultanahimed3
 
Introduction to SQL..pdf
Introduction to SQL..pdfIntroduction to SQL..pdf
Introduction to SQL..pdf
mayurisonawane29
 
slides about : Introduction_to_SQL.pptx
slides about :  Introduction_to_SQL.pptxslides about :  Introduction_to_SQL.pptx
slides about : Introduction_to_SQL.pptx
DrMarwaElsherif
 
SQL POWERPOINT PRESENTATION ON SQL .pptx
SQL POWERPOINT PRESENTATION ON SQL .pptxSQL POWERPOINT PRESENTATION ON SQL .pptx
SQL POWERPOINT PRESENTATION ON SQL .pptx
alakeshbarua2
 
sql_data.pdf
sql_data.pdfsql_data.pdf
sql_data.pdf
VandanaGoyal21
 
Sql project ..
Sql project ..Sql project ..
Sql project ..
Piyush Singh
 
Database queries
Database queriesDatabase queries
Database queries
IIUM
 
SQL Assessment Command Statements
SQL Assessment Command StatementsSQL Assessment Command Statements
SQL Assessment Command Statements
Shaun Wilson
 
about-SQL AND ETC.pptx
about-SQL AND ETC.pptxabout-SQL AND ETC.pptx
about-SQL AND ETC.pptx
jwhuqyqtayaw
 
Relational database management system
Relational database management systemRelational database management system
Relational database management system
Praveen Soni
 
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfytxjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
WrushabhShirsat3
 
SQL.pptx for the begineers and good know
SQL.pptx for the begineers and good knowSQL.pptx for the begineers and good know
SQL.pptx for the begineers and good know
PavithSingh
 
full detailled SQL notesquestion bank (1).pdf
full detailled SQL notesquestion bank (1).pdffull detailled SQL notesquestion bank (1).pdf
full detailled SQL notesquestion bank (1).pdf
yvpachorib23
 
SQL UNIT FOUR.pptxDiscDiscoverabilitDiscoverability Scorey Scoreoverability S...
SQL UNIT FOUR.pptxDiscDiscoverabilitDiscoverability Scorey Scoreoverability S...SQL UNIT FOUR.pptxDiscDiscoverabilitDiscoverability Scorey Scoreoverability S...
SQL UNIT FOUR.pptxDiscDiscoverabilitDiscoverability Scorey Scoreoverability S...
sultanahimed3
 
slides about : Introduction_to_SQL.pptx
slides about :  Introduction_to_SQL.pptxslides about :  Introduction_to_SQL.pptx
slides about : Introduction_to_SQL.pptx
DrMarwaElsherif
 
SQL POWERPOINT PRESENTATION ON SQL .pptx
SQL POWERPOINT PRESENTATION ON SQL .pptxSQL POWERPOINT PRESENTATION ON SQL .pptx
SQL POWERPOINT PRESENTATION ON SQL .pptx
alakeshbarua2
 
Database queries
Database queriesDatabase queries
Database queries
IIUM
 
Ad

Recently uploaded (20)

QUIZ-O-FORCE FINAL SET BY SUDIPTA & SUBHAM.pptx
QUIZ-O-FORCE FINAL SET BY SUDIPTA & SUBHAM.pptxQUIZ-O-FORCE FINAL SET BY SUDIPTA & SUBHAM.pptx
QUIZ-O-FORCE FINAL SET BY SUDIPTA & SUBHAM.pptx
Sourav Kr Podder
 
Exploring Identity Through Colombian Companies
Exploring Identity Through Colombian CompaniesExploring Identity Through Colombian Companies
Exploring Identity Through Colombian Companies
OlgaLeonorTorresSnch
 
How to Create Time Off Request in Odoo 18 Time Off
How to Create Time Off Request in Odoo 18 Time OffHow to Create Time Off Request in Odoo 18 Time Off
How to Create Time Off Request in Odoo 18 Time Off
Celine George
 
How to Configure Add to Cart in Odoo 18 Website
How to Configure Add to Cart in Odoo 18 WebsiteHow to Configure Add to Cart in Odoo 18 Website
How to Configure Add to Cart in Odoo 18 Website
Celine George
 
প্রত্যুৎপন্নমতিত্ব - Prottutponnomotittwa 2025.pdf
প্রত্যুৎপন্নমতিত্ব - Prottutponnomotittwa 2025.pdfপ্রত্যুৎপন্নমতিত্ব - Prottutponnomotittwa 2025.pdf
প্রত্যুৎপন্নমতিত্ব - Prottutponnomotittwa 2025.pdf
Pragya - UEM Kolkata Quiz Club
 
POS Reporting in Odoo 18 - Odoo 18 Slides
POS Reporting in Odoo 18 - Odoo 18 SlidesPOS Reporting in Odoo 18 - Odoo 18 Slides
POS Reporting in Odoo 18 - Odoo 18 Slides
Celine George
 
Critical Thinking and Bias with Jibi Moses
Critical Thinking and Bias with Jibi MosesCritical Thinking and Bias with Jibi Moses
Critical Thinking and Bias with Jibi Moses
Excellence Foundation for South Sudan
 
Introduction to Online CME for Nurse Practitioners.pdf
Introduction to Online CME for Nurse Practitioners.pdfIntroduction to Online CME for Nurse Practitioners.pdf
Introduction to Online CME for Nurse Practitioners.pdf
CME4Life
 
Dashboard Overview in Odoo 18 - Odoo Slides
Dashboard Overview in Odoo 18 - Odoo SlidesDashboard Overview in Odoo 18 - Odoo Slides
Dashboard Overview in Odoo 18 - Odoo Slides
Celine George
 
State institute of educational technology
State institute of educational technologyState institute of educational technology
State institute of educational technology
vp5806484
 
IDSP(INTEGRATED DISEASE SURVEILLANCE PROGRAMME...
IDSP(INTEGRATED DISEASE SURVEILLANCE PROGRAMME...IDSP(INTEGRATED DISEASE SURVEILLANCE PROGRAMME...
IDSP(INTEGRATED DISEASE SURVEILLANCE PROGRAMME...
SweetytamannaMohapat
 
Stewart Butler - OECD - How to design and deliver higher technical education ...
Stewart Butler - OECD - How to design and deliver higher technical education ...Stewart Butler - OECD - How to design and deliver higher technical education ...
Stewart Butler - OECD - How to design and deliver higher technical education ...
EduSkills OECD
 
How to Manage Orders in Odoo 18 Lunch - Odoo Slides
How to Manage Orders in Odoo 18 Lunch - Odoo SlidesHow to Manage Orders in Odoo 18 Lunch - Odoo Slides
How to Manage Orders in Odoo 18 Lunch - Odoo Slides
Celine George
 
Swachata Quiz - Prelims - 01.10.24 - Quiz Club IIT Patna
Swachata Quiz - Prelims - 01.10.24 - Quiz Club IIT PatnaSwachata Quiz - Prelims - 01.10.24 - Quiz Club IIT Patna
Swachata Quiz - Prelims - 01.10.24 - Quiz Club IIT Patna
Quiz Club, Indian Institute of Technology, Patna
 
CBSE - Grade 11 - Mathematics - Ch 2 - Relations And Functions - Notes (PDF F...
CBSE - Grade 11 - Mathematics - Ch 2 - Relations And Functions - Notes (PDF F...CBSE - Grade 11 - Mathematics - Ch 2 - Relations And Functions - Notes (PDF F...
CBSE - Grade 11 - Mathematics - Ch 2 - Relations And Functions - Notes (PDF F...
Sritoma Majumder
 
"Dictyoptera: The Order of Cockroaches and Mantises" Or, more specifically: ...
"Dictyoptera: The Order of Cockroaches and Mantises"  Or, more specifically: ..."Dictyoptera: The Order of Cockroaches and Mantises"  Or, more specifically: ...
"Dictyoptera: The Order of Cockroaches and Mantises" Or, more specifically: ...
Arshad Shaikh
 
Writing Research Papers: Guidance for Research Community
Writing Research Papers: Guidance for Research CommunityWriting Research Papers: Guidance for Research Community
Writing Research Papers: Guidance for Research Community
Rishi Bankim Chandra Evening College, Naihati, North 24 Parganas, West Bengal, India
 
A Brief Introduction About Jack Lutkus
A Brief Introduction About  Jack  LutkusA Brief Introduction About  Jack  Lutkus
A Brief Introduction About Jack Lutkus
Jack Lutkus
 
STUDENT LOAN TRUST FUND DEFAULTERS GHANA
STUDENT LOAN TRUST FUND DEFAULTERS GHANASTUDENT LOAN TRUST FUND DEFAULTERS GHANA
STUDENT LOAN TRUST FUND DEFAULTERS GHANA
Kweku Zurek
 
Forestry Model Exit Exam_2025_Wollega University, Gimbi Campus.pdf
Forestry Model Exit Exam_2025_Wollega University, Gimbi Campus.pdfForestry Model Exit Exam_2025_Wollega University, Gimbi Campus.pdf
Forestry Model Exit Exam_2025_Wollega University, Gimbi Campus.pdf
ChalaKelbessa
 
QUIZ-O-FORCE FINAL SET BY SUDIPTA & SUBHAM.pptx
QUIZ-O-FORCE FINAL SET BY SUDIPTA & SUBHAM.pptxQUIZ-O-FORCE FINAL SET BY SUDIPTA & SUBHAM.pptx
QUIZ-O-FORCE FINAL SET BY SUDIPTA & SUBHAM.pptx
Sourav Kr Podder
 
Exploring Identity Through Colombian Companies
Exploring Identity Through Colombian CompaniesExploring Identity Through Colombian Companies
Exploring Identity Through Colombian Companies
OlgaLeonorTorresSnch
 
How to Create Time Off Request in Odoo 18 Time Off
How to Create Time Off Request in Odoo 18 Time OffHow to Create Time Off Request in Odoo 18 Time Off
How to Create Time Off Request in Odoo 18 Time Off
Celine George
 
How to Configure Add to Cart in Odoo 18 Website
How to Configure Add to Cart in Odoo 18 WebsiteHow to Configure Add to Cart in Odoo 18 Website
How to Configure Add to Cart in Odoo 18 Website
Celine George
 
প্রত্যুৎপন্নমতিত্ব - Prottutponnomotittwa 2025.pdf
প্রত্যুৎপন্নমতিত্ব - Prottutponnomotittwa 2025.pdfপ্রত্যুৎপন্নমতিত্ব - Prottutponnomotittwa 2025.pdf
প্রত্যুৎপন্নমতিত্ব - Prottutponnomotittwa 2025.pdf
Pragya - UEM Kolkata Quiz Club
 
POS Reporting in Odoo 18 - Odoo 18 Slides
POS Reporting in Odoo 18 - Odoo 18 SlidesPOS Reporting in Odoo 18 - Odoo 18 Slides
POS Reporting in Odoo 18 - Odoo 18 Slides
Celine George
 
Introduction to Online CME for Nurse Practitioners.pdf
Introduction to Online CME for Nurse Practitioners.pdfIntroduction to Online CME for Nurse Practitioners.pdf
Introduction to Online CME for Nurse Practitioners.pdf
CME4Life
 
Dashboard Overview in Odoo 18 - Odoo Slides
Dashboard Overview in Odoo 18 - Odoo SlidesDashboard Overview in Odoo 18 - Odoo Slides
Dashboard Overview in Odoo 18 - Odoo Slides
Celine George
 
State institute of educational technology
State institute of educational technologyState institute of educational technology
State institute of educational technology
vp5806484
 
IDSP(INTEGRATED DISEASE SURVEILLANCE PROGRAMME...
IDSP(INTEGRATED DISEASE SURVEILLANCE PROGRAMME...IDSP(INTEGRATED DISEASE SURVEILLANCE PROGRAMME...
IDSP(INTEGRATED DISEASE SURVEILLANCE PROGRAMME...
SweetytamannaMohapat
 
Stewart Butler - OECD - How to design and deliver higher technical education ...
Stewart Butler - OECD - How to design and deliver higher technical education ...Stewart Butler - OECD - How to design and deliver higher technical education ...
Stewart Butler - OECD - How to design and deliver higher technical education ...
EduSkills OECD
 
How to Manage Orders in Odoo 18 Lunch - Odoo Slides
How to Manage Orders in Odoo 18 Lunch - Odoo SlidesHow to Manage Orders in Odoo 18 Lunch - Odoo Slides
How to Manage Orders in Odoo 18 Lunch - Odoo Slides
Celine George
 
CBSE - Grade 11 - Mathematics - Ch 2 - Relations And Functions - Notes (PDF F...
CBSE - Grade 11 - Mathematics - Ch 2 - Relations And Functions - Notes (PDF F...CBSE - Grade 11 - Mathematics - Ch 2 - Relations And Functions - Notes (PDF F...
CBSE - Grade 11 - Mathematics - Ch 2 - Relations And Functions - Notes (PDF F...
Sritoma Majumder
 
"Dictyoptera: The Order of Cockroaches and Mantises" Or, more specifically: ...
"Dictyoptera: The Order of Cockroaches and Mantises"  Or, more specifically: ..."Dictyoptera: The Order of Cockroaches and Mantises"  Or, more specifically: ...
"Dictyoptera: The Order of Cockroaches and Mantises" Or, more specifically: ...
Arshad Shaikh
 
A Brief Introduction About Jack Lutkus
A Brief Introduction About  Jack  LutkusA Brief Introduction About  Jack  Lutkus
A Brief Introduction About Jack Lutkus
Jack Lutkus
 
STUDENT LOAN TRUST FUND DEFAULTERS GHANA
STUDENT LOAN TRUST FUND DEFAULTERS GHANASTUDENT LOAN TRUST FUND DEFAULTERS GHANA
STUDENT LOAN TRUST FUND DEFAULTERS GHANA
Kweku Zurek
 
Forestry Model Exit Exam_2025_Wollega University, Gimbi Campus.pdf
Forestry Model Exit Exam_2025_Wollega University, Gimbi Campus.pdfForestry Model Exit Exam_2025_Wollega University, Gimbi Campus.pdf
Forestry Model Exit Exam_2025_Wollega University, Gimbi Campus.pdf
ChalaKelbessa
 
Ad

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