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 (19)

Sql basics and DDL statements
Sql basics and DDL statementsSql basics and DDL statements
Sql basics and DDL statements
Mohd Tousif
 
Sql commands
Sql commandsSql commands
Sql commands
Balakumaran Arunachalam
 
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
 
1 ddl
1 ddl1 ddl
1 ddl
Mr Patrick NIYISHAKA
 
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
Sql
jyothislides
 
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
 
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
 
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
 
Learning sql from w3schools
Learning sql from w3schoolsLearning sql from w3schools
Learning sql from w3schools
farhan516
 
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
 

Similar to PHP mysql Sql (20)

SQL DATABASE MANAGAEMENT SYSTEM FOR CLASS 12 CBSE
SQL DATABASE MANAGAEMENT SYSTEM FOR CLASS 12  CBSESQL DATABASE MANAGAEMENT SYSTEM FOR CLASS 12  CBSE
SQL DATABASE MANAGAEMENT SYSTEM FOR CLASS 12 CBSE
sdnsdf
 
Sql intro & ddl 1
Sql intro & ddl 1Sql intro & ddl 1
Sql intro & ddl 1
Dr. C.V. Suresh Babu
 
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
 
SQL: Data Definition Language(DDL) command
SQL: Data Definition Language(DDL) commandSQL: Data Definition Language(DDL) command
SQL: Data Definition Language(DDL) command
sonali sonavane
 
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 constraints
Vivek Singh
 
Lab2 ddl commands
Lab2 ddl commandsLab2 ddl commands
Lab2 ddl commands
Balqees Al.Mubarak
 
12 SQL
12 SQL12 SQL
12 SQL
Praveen M Jigajinni
 
12 SQL
12 SQL12 SQL
12 SQL
Praveen M Jigajinni
 
SQL2.pptx
SQL2.pptxSQL2.pptx
SQL2.pptx
RareDeath
 
SQL commands powerpoint presentation. Ppt
SQL commands powerpoint presentation. PptSQL commands powerpoint presentation. Ppt
SQL commands powerpoint presentation. Ppt
umadevikakarlapudi
 
SQL Basics, DDL, DML, DQL, Learn The BAsics Of SQL.pdf
SQL Basics, DDL, DML, DQL, Learn The BAsics Of SQL.pdfSQL Basics, DDL, DML, DQL, Learn The BAsics Of SQL.pdf
SQL Basics, DDL, DML, DQL, Learn The BAsics Of SQL.pdf
JavairiaRaza1
 
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 data base management and design
SQl     data base management  and designSQl     data base management  and design
SQl data base management and design
franckelsania20
 
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 DATABASE MANAGAEMENT SYSTEM FOR CLASS 12 CBSE
SQL DATABASE MANAGAEMENT SYSTEM FOR CLASS 12  CBSESQL DATABASE MANAGAEMENT SYSTEM FOR CLASS 12  CBSE
SQL DATABASE MANAGAEMENT SYSTEM FOR CLASS 12 CBSE
sdnsdf
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasad
paddu123
 
SQL: Data Definition Language(DDL) command
SQL: Data Definition Language(DDL) commandSQL: Data Definition Language(DDL) command
SQL: Data Definition Language(DDL) command
sonali sonavane
 
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 constraints
Vivek Singh
 
SQL commands powerpoint presentation. Ppt
SQL commands powerpoint presentation. PptSQL commands powerpoint presentation. Ppt
SQL commands powerpoint presentation. Ppt
umadevikakarlapudi
 
SQL Basics, DDL, DML, DQL, Learn The BAsics Of SQL.pdf
SQL Basics, DDL, DML, DQL, Learn The BAsics Of SQL.pdfSQL Basics, DDL, DML, DQL, Learn The BAsics Of SQL.pdf
SQL Basics, DDL, DML, DQL, Learn The BAsics Of SQL.pdf
JavairiaRaza1
 
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 data base management and design
SQl     data base management  and designSQl     data base management  and design
SQl data base management and design
franckelsania20
 
Sql ch 12 - creating database
Sql ch 12 - creating databaseSql ch 12 - creating database
Sql ch 12 - creating database
Mukesh Tekwani
 
Ad

More from Mudasir Syed (20)

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
 
Ajax
Ajax Ajax
Ajax
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
 
Sql select
Sql select Sql select
Sql select
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
 
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
 
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
 
Ad

Recently uploaded (20)

Introduction to Generative AI and Copilot.pdf
Introduction to Generative AI and Copilot.pdfIntroduction to Generative AI and Copilot.pdf
Introduction to Generative AI and Copilot.pdf
TechSoup
 
The Man In The Back – Exceptional Delaware.pdf
The Man In The Back – Exceptional Delaware.pdfThe Man In The Back – Exceptional Delaware.pdf
The Man In The Back – Exceptional Delaware.pdf
dennisongomezk
 
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition IILDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDM & Mia eStudios
 
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptxROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
Belicia R.S
 
Chalukyas of Gujrat, Solanki Dynasty NEP.pptx
Chalukyas of Gujrat, Solanki Dynasty NEP.pptxChalukyas of Gujrat, Solanki Dynasty NEP.pptx
Chalukyas of Gujrat, Solanki Dynasty NEP.pptx
Dr. Ravi Shankar Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
How to Create an Event in Odoo 18 - Odoo 18 Slides
How to Create an Event in Odoo 18 - Odoo 18 SlidesHow to Create an Event in Odoo 18 - Odoo 18 Slides
How to Create an Event in Odoo 18 - Odoo 18 Slides
Celine George
 
How to Manage Multi Language for Invoice in Odoo 18
How to Manage Multi Language for Invoice in Odoo 18How to Manage Multi Language for Invoice in Odoo 18
How to Manage Multi Language for Invoice in Odoo 18
Celine George
 
LDMMIA Spring Ending Guest Grad Student News
LDMMIA Spring Ending Guest Grad Student NewsLDMMIA Spring Ending Guest Grad Student News
LDMMIA Spring Ending Guest Grad Student News
LDM & Mia eStudios
 
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptxPEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
Arshad Shaikh
 
Publishing Your Memoir with Brooke Warner
Publishing Your Memoir with Brooke WarnerPublishing Your Memoir with Brooke Warner
Publishing Your Memoir with Brooke Warner
Brooke Warner
 
Sustainable Innovation with Immersive Learning
Sustainable Innovation with Immersive LearningSustainable Innovation with Immersive Learning
Sustainable Innovation with Immersive Learning
Leonel Morgado
 
How to Manage Inventory Movement in Odoo 18 POS
How to Manage Inventory Movement in Odoo 18 POSHow to Manage Inventory Movement in Odoo 18 POS
How to Manage Inventory Movement in Odoo 18 POS
Celine George
 
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptxRai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Dr. Ravi Shankar Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
Allomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdfAllomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdf
Abha Pandey
 
Revista digital preescolar en transformación
Revista digital preescolar en transformaciónRevista digital preescolar en transformación
Revista digital preescolar en transformación
guerragallardo26
 
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Pragya - UEM Kolkata Quiz Club
 
LDMMIA GRAD Student Check-in Orientation Sampler
LDMMIA GRAD Student Check-in Orientation SamplerLDMMIA GRAD Student Check-in Orientation Sampler
LDMMIA GRAD Student Check-in Orientation Sampler
LDM & Mia eStudios
 
Ray Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big CycleRay Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big Cycle
Dadang Solihin
 
Capitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptxCapitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptx
CapitolTechU
 
BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
Quiz Club of PSG College of Arts & Science
 
Introduction to Generative AI and Copilot.pdf
Introduction to Generative AI and Copilot.pdfIntroduction to Generative AI and Copilot.pdf
Introduction to Generative AI and Copilot.pdf
TechSoup
 
The Man In The Back – Exceptional Delaware.pdf
The Man In The Back – Exceptional Delaware.pdfThe Man In The Back – Exceptional Delaware.pdf
The Man In The Back – Exceptional Delaware.pdf
dennisongomezk
 
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition IILDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDM & Mia eStudios
 
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptxROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
Belicia R.S
 
How to Create an Event in Odoo 18 - Odoo 18 Slides
How to Create an Event in Odoo 18 - Odoo 18 SlidesHow to Create an Event in Odoo 18 - Odoo 18 Slides
How to Create an Event in Odoo 18 - Odoo 18 Slides
Celine George
 
How to Manage Multi Language for Invoice in Odoo 18
How to Manage Multi Language for Invoice in Odoo 18How to Manage Multi Language for Invoice in Odoo 18
How to Manage Multi Language for Invoice in Odoo 18
Celine George
 
LDMMIA Spring Ending Guest Grad Student News
LDMMIA Spring Ending Guest Grad Student NewsLDMMIA Spring Ending Guest Grad Student News
LDMMIA Spring Ending Guest Grad Student News
LDM & Mia eStudios
 
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptxPEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
Arshad Shaikh
 
Publishing Your Memoir with Brooke Warner
Publishing Your Memoir with Brooke WarnerPublishing Your Memoir with Brooke Warner
Publishing Your Memoir with Brooke Warner
Brooke Warner
 
Sustainable Innovation with Immersive Learning
Sustainable Innovation with Immersive LearningSustainable Innovation with Immersive Learning
Sustainable Innovation with Immersive Learning
Leonel Morgado
 
How to Manage Inventory Movement in Odoo 18 POS
How to Manage Inventory Movement in Odoo 18 POSHow to Manage Inventory Movement in Odoo 18 POS
How to Manage Inventory Movement in Odoo 18 POS
Celine George
 
Allomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdfAllomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdf
Abha Pandey
 
Revista digital preescolar en transformación
Revista digital preescolar en transformaciónRevista digital preescolar en transformación
Revista digital preescolar en transformación
guerragallardo26
 
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Pragya - UEM Kolkata Quiz Club
 
LDMMIA GRAD Student Check-in Orientation Sampler
LDMMIA GRAD Student Check-in Orientation SamplerLDMMIA GRAD Student Check-in Orientation Sampler
LDMMIA GRAD Student Check-in Orientation Sampler
LDM & Mia eStudios
 
Ray Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big CycleRay Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big Cycle
Dadang Solihin
 
Capitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptxCapitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptx
CapitolTechU
 

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