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

What's hot

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

What's hot (19)

Sql basics and DDL statements
Sql basics and DDL statementsSql basics and DDL statements
Sql basics and DDL statements
 
Sql commands
Sql commandsSql commands
Sql commands
 
Intro to T-SQL – 2nd session
Intro to T-SQL – 2nd sessionIntro to T-SQL – 2nd session
Intro to T-SQL – 2nd session
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasad
 
1 ddl
1 ddl1 ddl
1 ddl
 
Data Manipulation(DML) and Transaction Control (TCL)
Data Manipulation(DML) and Transaction Control (TCL)  Data Manipulation(DML) and Transaction Control (TCL)
Data Manipulation(DML) and Transaction Control (TCL)
 
Sql basic things
Sql basic thingsSql basic things
Sql basic things
 
SQL(DDL & DML)
SQL(DDL & DML)SQL(DDL & DML)
SQL(DDL & DML)
 
Assignment#07
Assignment#07Assignment#07
Assignment#07
 
Sql
SqlSql
Sql
 
Database Management - Lecture 2 - SQL select, insert, update and delete
Database Management - Lecture 2 - SQL select, insert, update and deleteDatabase Management - Lecture 2 - SQL select, insert, update and delete
Database Management - Lecture 2 - SQL select, insert, update and delete
 
Relational database management system
Relational database management systemRelational database management system
Relational database management system
 
Assignment#02
Assignment#02Assignment#02
Assignment#02
 
MySQL Essential Training
MySQL Essential TrainingMySQL Essential Training
MySQL Essential Training
 
Learning sql from w3schools
Learning sql from w3schoolsLearning sql from w3schools
Learning sql from w3schools
 
Assignment#04
Assignment#04Assignment#04
Assignment#04
 
Oracle: DML
Oracle: DMLOracle: DML
Oracle: DML
 
Structure query language (sql)
Structure query language (sql)Structure query language (sql)
Structure query language (sql)
 
SQL Fundamentals - Lecture 2
SQL Fundamentals - Lecture 2SQL Fundamentals - Lecture 2
SQL Fundamentals - Lecture 2
 

Similar to PHP mysql Sql

Sql intro & ddl 1
Sql intro & ddl 1Sql intro & ddl 1
Sql intro & ddl 1
Dr. C.V. Suresh Babu
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasad
paddu123
 
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...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
 
Sql integrity constraints
Sql integrity constraintsSql integrity constraints
Sql integrity constraintsVivek Singh
 
Lab2 ddl commands
Lab2 ddl commandsLab2 ddl commands
Lab2 ddl commands
Balqees Al.Mubarak
 
SQL2.pptx
SQL2.pptxSQL2.pptx
SQL2.pptx
RareDeath
 
DATABASE MANAGMENT SYSTEM (DBMS) AND SQL
DATABASE MANAGMENT SYSTEM (DBMS) AND SQLDATABASE MANAGMENT SYSTEM (DBMS) AND SQL
DATABASE MANAGMENT SYSTEM (DBMS) AND SQL
Dev Chauhan
 
Lab_04.ppt opreating system of computer lab
Lab_04.ppt opreating system of computer labLab_04.ppt opreating system of computer lab
Lab_04.ppt opreating system of computer lab
MUHAMMADANSAR76
 
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
 
Sql ch 12 - creating database
Sql ch 12 - creating databaseSql ch 12 - creating database
Sql ch 12 - creating database
Mukesh Tekwani
 
Assignment#01
Assignment#01Assignment#01
Assignment#01
Sunita Milind Dol
 
Create table
Create tableCreate table
Create table
Nitesh Singh
 
Sql commands
Sql commandsSql commands
Sql commands
Pooja Dixit
 
DBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptxDBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptx
jainendraKUMAR55
 
Introduction to sql new
Introduction to sql newIntroduction to sql new
Introduction to sql newSANTOSH RATH
 
GFGC CHIKKABASUR ( DDL COMMANDS )
GFGC CHIKKABASUR ( DDL COMMANDS )GFGC CHIKKABASUR ( DDL COMMANDS )
GFGC CHIKKABASUR ( DDL COMMANDS )
GOVT FIRST GRADE COLLEGE CHIKKABASUR
 

Similar to PHP mysql Sql (20)

Sql intro & ddl 1
Sql intro & ddl 1Sql intro & ddl 1
Sql intro & ddl 1
 
Sql intro & ddl 1
Sql intro & ddl 1Sql intro & ddl 1
Sql intro & ddl 1
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasad
 
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...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...
 
Sql integrity constraints
Sql integrity constraintsSql integrity constraints
Sql integrity constraints
 
Lab2 ddl commands
Lab2 ddl commandsLab2 ddl commands
Lab2 ddl commands
 
12 SQL
12 SQL12 SQL
12 SQL
 
12 SQL
12 SQL12 SQL
12 SQL
 
SQL2.pptx
SQL2.pptxSQL2.pptx
SQL2.pptx
 
DATABASE MANAGMENT SYSTEM (DBMS) AND SQL
DATABASE MANAGMENT SYSTEM (DBMS) AND SQLDATABASE MANAGMENT SYSTEM (DBMS) AND SQL
DATABASE MANAGMENT SYSTEM (DBMS) AND SQL
 
Lab_04.ppt opreating system of computer lab
Lab_04.ppt opreating system of computer labLab_04.ppt opreating system of computer lab
Lab_04.ppt opreating system of computer lab
 
introdution to SQL and SQL functions
introdution to SQL and SQL functionsintrodution to SQL and SQL functions
introdution to SQL and SQL functions
 
Sql ch 12 - creating database
Sql ch 12 - creating databaseSql ch 12 - creating database
Sql ch 12 - creating database
 
Assignment#01
Assignment#01Assignment#01
Assignment#01
 
Create table
Create tableCreate table
Create table
 
Db1 lecture4
Db1 lecture4Db1 lecture4
Db1 lecture4
 
Sql commands
Sql commandsSql commands
Sql commands
 
DBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptxDBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptx
 
Introduction to sql new
Introduction to sql newIntroduction to sql new
Introduction to sql new
 
GFGC CHIKKABASUR ( DDL COMMANDS )
GFGC CHIKKABASUR ( DDL COMMANDS )GFGC CHIKKABASUR ( DDL COMMANDS )
GFGC CHIKKABASUR ( DDL COMMANDS )
 

More from Mudasir Syed

Error reporting in php
Error reporting in php Error reporting in php
Error reporting in php
Mudasir Syed
 
Cookies in php lecture 2
Cookies in php  lecture  2Cookies in php  lecture  2
Cookies in php lecture 2
Mudasir Syed
 
Cookies in php lecture 1
Cookies in php lecture 1Cookies in php lecture 1
Cookies in php lecture 1
Mudasir Syed
 
Reporting using FPDF
Reporting using FPDFReporting using FPDF
Reporting using FPDF
Mudasir Syed
 
Oop in php lecture 2
Oop in  php lecture 2Oop in  php lecture 2
Oop in php lecture 2
Mudasir Syed
 
Oop in php lecture 2
Oop in  php lecture 2Oop in  php lecture 2
Oop in php lecture 2
Mudasir Syed
 
Filing system in PHP
Filing system in PHPFiling system in PHP
Filing system in PHP
Mudasir Syed
 
Time manipulation lecture 2
Time manipulation lecture 2Time manipulation lecture 2
Time manipulation lecture 2
Mudasir Syed
 
Time manipulation lecture 1
Time manipulation lecture 1 Time manipulation lecture 1
Time manipulation lecture 1
Mudasir Syed
 
Php Mysql
Php Mysql Php Mysql
Php Mysql
Mudasir Syed
 
Adminstrating Through PHPMyAdmin
Adminstrating Through PHPMyAdminAdminstrating Through PHPMyAdmin
Adminstrating Through PHPMyAdmin
Mudasir Syed
 
PHP mysql Mysql joins
PHP mysql  Mysql joinsPHP mysql  Mysql joins
PHP mysql Mysql joins
Mudasir Syed
 
PHP mysql Introduction database
 PHP mysql  Introduction database PHP mysql  Introduction database
PHP mysql Introduction database
Mudasir Syed
 
PHP mysql Installing my sql 5.1
PHP mysql  Installing my sql 5.1PHP mysql  Installing my sql 5.1
PHP mysql Installing my sql 5.1
Mudasir Syed
 
PHP mysql Er diagram
PHP mysql  Er diagramPHP mysql  Er diagram
PHP mysql Er diagram
Mudasir Syed
 
PHP mysql Database normalizatin
PHP mysql  Database normalizatinPHP mysql  Database normalizatin
PHP mysql Database normalizatin
Mudasir Syed
 
PHP mysql Aggregate functions
PHP mysql Aggregate functionsPHP mysql Aggregate functions
PHP mysql Aggregate functions
Mudasir Syed
 
Form validation with built in functions
Form validation with built in functions Form validation with built in functions
Form validation with built in functions
Mudasir Syed
 

More from Mudasir Syed (20)

Error reporting in php
Error reporting in php Error reporting in php
Error reporting in php
 
Cookies in php lecture 2
Cookies in php  lecture  2Cookies in php  lecture  2
Cookies in php lecture 2
 
Cookies in php lecture 1
Cookies in php lecture 1Cookies in php lecture 1
Cookies in php lecture 1
 
Ajax
Ajax Ajax
Ajax
 
Reporting using FPDF
Reporting using FPDFReporting using FPDF
Reporting using FPDF
 
Oop in php lecture 2
Oop in  php lecture 2Oop in  php lecture 2
Oop in php lecture 2
 
Oop in php lecture 2
Oop in  php lecture 2Oop in  php lecture 2
Oop in php lecture 2
 
Filing system in PHP
Filing system in PHPFiling system in PHP
Filing system in PHP
 
Time manipulation lecture 2
Time manipulation lecture 2Time manipulation lecture 2
Time manipulation lecture 2
 
Time manipulation lecture 1
Time manipulation lecture 1 Time manipulation lecture 1
Time manipulation lecture 1
 
Php Mysql
Php Mysql Php Mysql
Php Mysql
 
Adminstrating Through PHPMyAdmin
Adminstrating Through PHPMyAdminAdminstrating Through PHPMyAdmin
Adminstrating Through PHPMyAdmin
 
Sql select
Sql select Sql select
Sql select
 
PHP mysql Mysql joins
PHP mysql  Mysql joinsPHP mysql  Mysql joins
PHP mysql Mysql joins
 
PHP mysql Introduction database
 PHP mysql  Introduction database PHP mysql  Introduction database
PHP mysql Introduction database
 
PHP mysql Installing my sql 5.1
PHP mysql  Installing my sql 5.1PHP mysql  Installing my sql 5.1
PHP mysql Installing my sql 5.1
 
PHP mysql Er diagram
PHP mysql  Er diagramPHP mysql  Er diagram
PHP mysql Er diagram
 
PHP mysql Database normalizatin
PHP mysql  Database normalizatinPHP mysql  Database normalizatin
PHP mysql Database normalizatin
 
PHP mysql Aggregate functions
PHP mysql Aggregate functionsPHP mysql Aggregate functions
PHP mysql Aggregate functions
 
Form validation with built in functions
Form validation with built in functions Form validation with built in functions
Form validation with built in functions
 

Recently uploaded

How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
Kartik Tiwari
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
ArianaBusciglio
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 

Recently uploaded (20)

How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 

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