SlideShare a Scribd company logo
Introduction to SQL
SQL
 SQL (Structure Query Language)
It is relational database language that enables you to
create and operate on relational database.
Feature of SQL
 It is a non procedural language.
 It is a 4GL programming language.
(i.e. only What to do? not How to do?).
 It is a case insensitive language.
Constraints of SQL
 A constraint is a condition or check that is applied to a
column or set of columns in a table.
 Null Constraint: It means a Unknown Value.
Eg. mobile number(10) null
 Not Null Constraint: It means always a Known
Value.
Eg. name varchar2(20) not null
 Unique Constraint: It ensures that no two rows
have the same value in the specified column(s). i.e
Known Value (Distinct) or Unknown Value.
Eg. ecode number(5) unique
 Primary Key Constraint: It is similar to Unique
constraint except that the Primary Key can not allow
Null values so that this constraint must be applied to
columns declared as Not Null. i.e Always Known Value
(Distinct).
Eg. empid char(5) primary key
Constraints of SQL
 Default Constraint: A default value can be specified for
a column using default clause when a user does not enter
a value for that column.
Eg. grade char(2) default ‘E1’
Constraints of SQL
Foreign Key Constraint:
 Whenever two tables are related by a common column then Foreign Key is present in
the Child table (Related Table or Detail Table) and it is derived from primary key of Parent
Table (Primary Table or Master Table).
 Eg. Two Tables:
 Items (Itemno, Description, Price)
 Orders (Orderno, Orderdate, Itemno, Qty)
 where Itemno & Orderno are Primary Key and Itemno is Foreign Key. i.e both the tables
are related through common column Itemno.
 Note: It may be possible that Primary Key and Foreign Key are same.
 Eg. create table Items
 ( Itemno char(5) Primary Key,
 …………….);
 create table Orders
 ( Orderno number(5) Primary Key,
 Itemno char(5),
 constraint fk foreign key (itemno) references items(itemno)
 …………….
 );
Constraints of SQL (Contd:)
Classification of SQL Commands
 DDL Commands
 DML Commands
 DCL Commands
 Query Language
DDL Commands
DDL (Data Definition Language):
 It provides commands for defining various database
objects (i.e defining relation schemas, deleting relations,
creating indexes, and modifying relation schemas etc.)
 Eg. Create, Alter, Drop etc.
 The tables are created by using Create Table command and also its columns are
named, data types and sizes are supplied for each column.
 Syntax: create table <table_name>
 (
 <col1> <datatype> [<size>] [<constraint>],
 <col2> <datatype> [<size>] [<constraint>],
 ………..
 <coln> <datatype> [<size>] [<constraint>]
 );
 Eg. create table emp1
 (
 empid char(4) primary key,
 ename varchar2(20) not null,

 );
Create Command
EmpidEmpid EnameEname SalSal
E001E001 SmithSmith 50005000
E002E002 JohnJohn 1000010000
E003E003 JamesJames 25002500
Alter Command
 Altering Table: The alter table command is used to modify
the structure of existing table. (i.e adding a column, add an
integrity constraint etc.).
 Adding Columns: The new column will be added with
NULL values for all rows currently in table.
 Syntax: alter table <table_name>
 add column(<col1> <datatype> <size> [<constraint>],
 <col2> <datatype> <size> <constraint>]
…….);
 Eg. alter table emp
 add column(tel_number number(11) );
Alter table
 Modifying Column Definitions: To change
datatype, size, default value and NOT NULL column
constraint of a column definition.
 Syntax:
 alter table <table_name>
 modify <col_name> <new_datatype> <new_size>;
 Eg. alter table emp
 modify tel_number int(13) ;
Alter table (Contd:)
 Deleting Column: To change datatype, size, default
value and NOT NULL column constraint of a column
definition.
 Syntax:
 alter table <table_name>
 drop <col_name>;
 Eg. alter table emp
 drop tel_number;
Drop table
 Drop Table Command: It removes a table from the
database .
 Syntax:
 drop table <table_name>;
 Eg. Drop table emp;
Data Manipulation Language(DML)
 (Data Manipulation Language): It enables users to
manipulate data (i.e commands to insert, delete, and
modify tuples in the database).
 Eg. Insert, Update, Delete etc.
Insert table
 Inserting Data into Table
 The data can be inserted in a table using Insert Into
command.
 Syntax: insert into <table_name> [<column_lists>]
 values (<value1>, <value2>, …………….);
 Eg. insert into emp1
 values(‘E001’,’Vipin’,5000);
 Note: Here the order of values matches the order of
columns in the create table command of the table.
 Or insert into emp1 (empid, ename, sal)
 values(‘E001’,’Vipin’,5000);
Note: The columns not listed in the insert into command will have
their default values or null values.
 Modifying Data with Update Command
 This is a DML statement used to modify or change some or all of the
values in an existing row of a table.
 Syntax: update <table_name>
 set col1 = <new_value>,
 col2 = < new_value>,
 …..coln = <new_value>
 [where <condition>];
 Eg. update emp
 set sal= 400; ‘updates all rows
 Eg. update emp
 set sal= sal*2, ename= ‘JONES’
 where empno = 7844; ‘update only one row
Update table
 This is also a DML statement used to remove row(s) of a
table.
 Syntax: delete from <table_name>
 [where <condition>];
 Eg. delete from emp
 where sal < 5000;
Delete table

More Related Content

PDF
Ankit
Ankit Dubey
 
PPTX
STRUCTURE OF SQL QUERIES
VENNILAV6
 
PPT
Introduction to sql
VARSHAKUMARI49
 
PPTX
SQL Queries Information
Nishant Munjal
 
PPTX
SQL: Structured Query Language
Rohit Bisht
 
PPTX
SQL Basics
Hammad Rasheed
 
PPT
Chapter 07 ddl_sql
Nazir Ahmed
 
PDF
Sql commands
Mohd Tousif
 
STRUCTURE OF SQL QUERIES
VENNILAV6
 
Introduction to sql
VARSHAKUMARI49
 
SQL Queries Information
Nishant Munjal
 
SQL: Structured Query Language
Rohit Bisht
 
SQL Basics
Hammad Rasheed
 
Chapter 07 ddl_sql
Nazir Ahmed
 
Sql commands
Mohd Tousif
 

What's hot (19)

PPT
Sql basics and DDL statements
Mohd Tousif
 
ODP
Sql commands
Balakumaran Arunachalam
 
PPTX
Intro to T-SQL – 2nd session
Medhat Dawoud
 
PDF
Sql smart reference_by_prasad
paddu123
 
PDF
Data Manipulation(DML) and Transaction Control (TCL)
MuhammadWaheed44
 
PPTX
Sql basic things
Nishil Jain
 
PPTX
SQL(DDL & DML)
Sharad Dubey
 
PDF
Assignment#07
Sunita Milind Dol
 
PPT
Sql
jyothislides
 
PPTX
Database Management - Lecture 2 - SQL select, insert, update and delete
Al-Mamun Sarkar
 
PDF
Relational database management system
Praveen Soni
 
PDF
Assignment#02
Sunita Milind Dol
 
PPTX
MySQL Essential Training
HudaRaghibKadhim
 
DOCX
Learning sql from w3schools
farhan516
 
PDF
Assignment#04
Sunita Milind Dol
 
PPTX
Oracle: DML
DataminingTools Inc
 
PPTX
Structure query language (sql)
Nalina Kumari
 
PDF
SQL Fundamentals - Lecture 2
MuhammadWaheed44
 
Sql basics and DDL statements
Mohd Tousif
 
Intro to T-SQL – 2nd session
Medhat Dawoud
 
Sql smart reference_by_prasad
paddu123
 
Data Manipulation(DML) and Transaction Control (TCL)
MuhammadWaheed44
 
Sql basic things
Nishil Jain
 
SQL(DDL & DML)
Sharad Dubey
 
Assignment#07
Sunita Milind Dol
 
Database Management - Lecture 2 - SQL select, insert, update and delete
Al-Mamun Sarkar
 
Relational database management system
Praveen Soni
 
Assignment#02
Sunita Milind Dol
 
MySQL Essential Training
HudaRaghibKadhim
 
Learning sql from w3schools
farhan516
 
Assignment#04
Sunita Milind Dol
 
Oracle: DML
DataminingTools Inc
 
Structure query language (sql)
Nalina Kumari
 
SQL Fundamentals - Lecture 2
MuhammadWaheed44
 
Ad

Similar to PHP mysql Sql (20)

PPTX
SQL: Data Definition Language(DDL) command
sonali sonavane
 
PPTX
Sql commands
Pooja Dixit
 
PPTX
SQL _UNIT_DBMS_PRESENTSTATION_SQL _UNIT_DBMS_PRESENTSTATION
deeptanshudas100
 
PDF
Dms 22319 micro project
ARVIND SARDAR
 
PDF
Introduction to SQL..pdf
mayurisonawane29
 
PDF
CS3481_Database Management Laboratory .pdf
Kirubaburi R
 
PPTX
Database Akjljljlkjlkjkljlkjldiministration.pptx
EliasPetros
 
PPTX
SQL commands powerpoint presentation. Ppt
umadevikakarlapudi
 
PPTX
SQL ppt.pptx
fa4185561
 
PPTX
SQL2.pptx
RareDeath
 
PPTX
MS SQL - Database Programming Concepts by RSolutions
RSolutions
 
PPTX
SQL Commands
Sachidananda M H
 
PPT
Lecture-9-10-11-12(a-b).ppt modern database
mee23nu
 
PPTX
DBMSLab_SQL_4thsem_CI_17163544545446962.pptx
dgfs55437
 
PDF
DBMS unit-3.pdf
Prof. Dr. K. Adisesha
 
DOCX
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
SakkaravarthiS1
 
PPTX
Unit - II.pptx
MrsSavitaKumbhare
 
DOCX
SQL Tutorial for BCA-2
Raj vardhan
 
PDF
Rdbms day3
Nitesh Singh
 
PDF
Lecture on DBMS & MySQL.pdf v. C. .
MayankSinghRawat6
 
SQL: Data Definition Language(DDL) command
sonali sonavane
 
Sql commands
Pooja Dixit
 
SQL _UNIT_DBMS_PRESENTSTATION_SQL _UNIT_DBMS_PRESENTSTATION
deeptanshudas100
 
Dms 22319 micro project
ARVIND SARDAR
 
Introduction to SQL..pdf
mayurisonawane29
 
CS3481_Database Management Laboratory .pdf
Kirubaburi R
 
Database Akjljljlkjlkjkljlkjldiministration.pptx
EliasPetros
 
SQL commands powerpoint presentation. Ppt
umadevikakarlapudi
 
SQL ppt.pptx
fa4185561
 
SQL2.pptx
RareDeath
 
MS SQL - Database Programming Concepts by RSolutions
RSolutions
 
SQL Commands
Sachidananda M H
 
Lecture-9-10-11-12(a-b).ppt modern database
mee23nu
 
DBMSLab_SQL_4thsem_CI_17163544545446962.pptx
dgfs55437
 
DBMS unit-3.pdf
Prof. Dr. K. Adisesha
 
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
SakkaravarthiS1
 
Unit - II.pptx
MrsSavitaKumbhare
 
SQL Tutorial for BCA-2
Raj vardhan
 
Rdbms day3
Nitesh Singh
 
Lecture on DBMS & MySQL.pdf v. C. .
MayankSinghRawat6
 
Ad

More from Mudasir Syed (20)

PPT
Error reporting in php
Mudasir Syed
 
PPT
Cookies in php lecture 2
Mudasir Syed
 
PPT
Cookies in php lecture 1
Mudasir Syed
 
PPTX
Ajax
Mudasir Syed
 
PPT
Reporting using FPDF
Mudasir Syed
 
PPT
Oop in php lecture 2
Mudasir Syed
 
PPT
Oop in php lecture 2
Mudasir Syed
 
PPT
Filing system in PHP
Mudasir Syed
 
PPT
Time manipulation lecture 2
Mudasir Syed
 
PPT
Time manipulation lecture 1
Mudasir Syed
 
PPT
Php Mysql
Mudasir Syed
 
PPT
Adminstrating Through PHPMyAdmin
Mudasir Syed
 
PPT
Sql select
Mudasir Syed
 
PPT
PHP mysql Mysql joins
Mudasir Syed
 
PPTX
PHP mysql Introduction database
Mudasir Syed
 
PPT
PHP mysql Installing my sql 5.1
Mudasir Syed
 
PPT
PHP mysql Er diagram
Mudasir Syed
 
PPT
PHP mysql Database normalizatin
Mudasir Syed
 
PPT
PHP mysql Aggregate functions
Mudasir Syed
 
PPT
Form validation with built in functions
Mudasir Syed
 
Error reporting in php
Mudasir Syed
 
Cookies in php lecture 2
Mudasir Syed
 
Cookies in php lecture 1
Mudasir Syed
 
Reporting using FPDF
Mudasir Syed
 
Oop in php lecture 2
Mudasir Syed
 
Oop in php lecture 2
Mudasir Syed
 
Filing system in PHP
Mudasir Syed
 
Time manipulation lecture 2
Mudasir Syed
 
Time manipulation lecture 1
Mudasir Syed
 
Php Mysql
Mudasir Syed
 
Adminstrating Through PHPMyAdmin
Mudasir Syed
 
Sql select
Mudasir Syed
 
PHP mysql Mysql joins
Mudasir Syed
 
PHP mysql Introduction database
Mudasir Syed
 
PHP mysql Installing my sql 5.1
Mudasir Syed
 
PHP mysql Er diagram
Mudasir Syed
 
PHP mysql Database normalizatin
Mudasir Syed
 
PHP mysql Aggregate functions
Mudasir Syed
 
Form validation with built in functions
Mudasir Syed
 

Recently uploaded (20)

PDF
Review of Related Literature & Studies.pdf
Thelma Villaflores
 
PPTX
Care of patients with elImination deviation.pptx
AneetaSharma15
 
PPTX
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
PPTX
Kanban Cards _ Mass Action in Odoo 18.2 - Odoo Slides
Celine George
 
PDF
UTS Health Student Promotional Representative_Position Description.pdf
Faculty of Health, University of Technology Sydney
 
PDF
The-Invisible-Living-World-Beyond-Our-Naked-Eye chapter 2.pdf/8th science cur...
Sandeep Swamy
 
PDF
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
DOCX
Action Plan_ARAL PROGRAM_ STAND ALONE SHS.docx
Levenmartlacuna1
 
PPTX
Measures_of_location_-_Averages_and__percentiles_by_DR SURYA K.pptx
Surya Ganesh
 
PPTX
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
PPTX
Software Engineering BSC DS UNIT 1 .pptx
Dr. Pallawi Bulakh
 
PPTX
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
PDF
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
PPT
Python Programming Unit II Control Statements.ppt
CUO VEERANAN VEERANAN
 
PDF
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
PDF
Phylum Arthropoda: Characteristics and Classification, Entomology Lecture
Miraj Khan
 
PPTX
How to Close Subscription in Odoo 18 - Odoo Slides
Celine George
 
PPTX
An introduction to Dialogue writing.pptx
drsiddhantnagine
 
PPTX
Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh Kushwaha
Bhupesh Kushwaha
 
PDF
Health-The-Ultimate-Treasure (1).pdf/8th class science curiosity /samyans edu...
Sandeep Swamy
 
Review of Related Literature & Studies.pdf
Thelma Villaflores
 
Care of patients with elImination deviation.pptx
AneetaSharma15
 
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
Kanban Cards _ Mass Action in Odoo 18.2 - Odoo Slides
Celine George
 
UTS Health Student Promotional Representative_Position Description.pdf
Faculty of Health, University of Technology Sydney
 
The-Invisible-Living-World-Beyond-Our-Naked-Eye chapter 2.pdf/8th science cur...
Sandeep Swamy
 
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
Action Plan_ARAL PROGRAM_ STAND ALONE SHS.docx
Levenmartlacuna1
 
Measures_of_location_-_Averages_and__percentiles_by_DR SURYA K.pptx
Surya Ganesh
 
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
Software Engineering BSC DS UNIT 1 .pptx
Dr. Pallawi Bulakh
 
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
Python Programming Unit II Control Statements.ppt
CUO VEERANAN VEERANAN
 
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
Phylum Arthropoda: Characteristics and Classification, Entomology Lecture
Miraj Khan
 
How to Close Subscription in Odoo 18 - Odoo Slides
Celine George
 
An introduction to Dialogue writing.pptx
drsiddhantnagine
 
Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh Kushwaha
Bhupesh Kushwaha
 
Health-The-Ultimate-Treasure (1).pdf/8th class science curiosity /samyans edu...
Sandeep Swamy
 

PHP mysql Sql

  • 2. SQL  SQL (Structure Query Language) It is relational database language that enables you to create and operate on relational database.
  • 3. Feature of SQL  It is a non procedural language.  It is a 4GL programming language. (i.e. only What to do? not How to do?).  It is a case insensitive language.
  • 4. Constraints of SQL  A constraint is a condition or check that is applied to a column or set of columns in a table.  Null Constraint: It means a Unknown Value. Eg. mobile number(10) null  Not Null Constraint: It means always a Known Value. Eg. name varchar2(20) not null
  • 5.  Unique Constraint: It ensures that no two rows have the same value in the specified column(s). i.e Known Value (Distinct) or Unknown Value. Eg. ecode number(5) unique  Primary Key Constraint: It is similar to Unique constraint except that the Primary Key can not allow Null values so that this constraint must be applied to columns declared as Not Null. i.e Always Known Value (Distinct). Eg. empid char(5) primary key Constraints of SQL
  • 6.  Default Constraint: A default value can be specified for a column using default clause when a user does not enter a value for that column. Eg. grade char(2) default ‘E1’ Constraints of SQL
  • 7. Foreign Key Constraint:  Whenever two tables are related by a common column then Foreign Key is present in the Child table (Related Table or Detail Table) and it is derived from primary key of Parent Table (Primary Table or Master Table).  Eg. Two Tables:  Items (Itemno, Description, Price)  Orders (Orderno, Orderdate, Itemno, Qty)  where Itemno & Orderno are Primary Key and Itemno is Foreign Key. i.e both the tables are related through common column Itemno.  Note: It may be possible that Primary Key and Foreign Key are same.  Eg. create table Items  ( Itemno char(5) Primary Key,  …………….);  create table Orders  ( Orderno number(5) Primary Key,  Itemno char(5),  constraint fk foreign key (itemno) references items(itemno)  …………….  ); Constraints of SQL (Contd:)
  • 8. Classification of SQL Commands  DDL Commands  DML Commands  DCL Commands  Query Language
  • 9. DDL Commands DDL (Data Definition Language):  It provides commands for defining various database objects (i.e defining relation schemas, deleting relations, creating indexes, and modifying relation schemas etc.)  Eg. Create, Alter, Drop etc.
  • 10.  The tables are created by using Create Table command and also its columns are named, data types and sizes are supplied for each column.  Syntax: create table <table_name>  (  <col1> <datatype> [<size>] [<constraint>],  <col2> <datatype> [<size>] [<constraint>],  ………..  <coln> <datatype> [<size>] [<constraint>]  );  Eg. create table emp1  (  empid char(4) primary key,  ename varchar2(20) not null,   ); Create Command
  • 11. EmpidEmpid EnameEname SalSal E001E001 SmithSmith 50005000 E002E002 JohnJohn 1000010000 E003E003 JamesJames 25002500
  • 12. Alter Command  Altering Table: The alter table command is used to modify the structure of existing table. (i.e adding a column, add an integrity constraint etc.).  Adding Columns: The new column will be added with NULL values for all rows currently in table.  Syntax: alter table <table_name>  add column(<col1> <datatype> <size> [<constraint>],  <col2> <datatype> <size> <constraint>] …….);  Eg. alter table emp  add column(tel_number number(11) );
  • 13. Alter table  Modifying Column Definitions: To change datatype, size, default value and NOT NULL column constraint of a column definition.  Syntax:  alter table <table_name>  modify <col_name> <new_datatype> <new_size>;  Eg. alter table emp  modify tel_number int(13) ;
  • 14. Alter table (Contd:)  Deleting Column: To change datatype, size, default value and NOT NULL column constraint of a column definition.  Syntax:  alter table <table_name>  drop <col_name>;  Eg. alter table emp  drop tel_number;
  • 15. Drop table  Drop Table Command: It removes a table from the database .  Syntax:  drop table <table_name>;  Eg. Drop table emp;
  • 16. Data Manipulation Language(DML)  (Data Manipulation Language): It enables users to manipulate data (i.e commands to insert, delete, and modify tuples in the database).  Eg. Insert, Update, Delete etc.
  • 17. Insert table  Inserting Data into Table  The data can be inserted in a table using Insert Into command.  Syntax: insert into <table_name> [<column_lists>]  values (<value1>, <value2>, …………….);  Eg. insert into emp1  values(‘E001’,’Vipin’,5000);  Note: Here the order of values matches the order of columns in the create table command of the table.  Or insert into emp1 (empid, ename, sal)  values(‘E001’,’Vipin’,5000); Note: The columns not listed in the insert into command will have their default values or null values.
  • 18.  Modifying Data with Update Command  This is a DML statement used to modify or change some or all of the values in an existing row of a table.  Syntax: update <table_name>  set col1 = <new_value>,  col2 = < new_value>,  …..coln = <new_value>  [where <condition>];  Eg. update emp  set sal= 400; ‘updates all rows  Eg. update emp  set sal= sal*2, ename= ‘JONES’  where empno = 7844; ‘update only one row Update table
  • 19.  This is also a DML statement used to remove row(s) of a table.  Syntax: delete from <table_name>  [where <condition>];  Eg. delete from emp  where sal < 5000; Delete table