SlideShare a Scribd company logo
1 of 16
MIS 301 RELATIONAL DATABASE
MANAGEMENT SYSTEM
DATABASE MANAGEMENT SYSTEM
Structured Query Language(SQL)-2
LECTURE 10,11,12
PROF. KRISHNA ROY
Types of SQL Commands
•DDL or Data Definition Language Command
• DML or Data Manipulation Language Command
•DCL or Data Control Language Command
• TCL or Transaction Control Language Command
• DQL or Data Query Language Command
PROF. KRISHNA ROY, FMS, BCREC 2
20-09-2023
Data definition language
• DDL is used for creating table structures, modifying existing
structures as well as for removing such structures
• DDL commands are auto-committed i.e. changes made by these
commands are permanently saved in the database.
• DDL commands are CREATE, ALTER, DROP, TRUNCATE
PROF. KRISHNA ROY, FMS, BCREC 3
20-09-2023
ddl command create
• This command creates a new table in the database.
• Syntax:
create table <table name>
( attrib1 datatype(size),
attrib2 datatype(size),
: :
attribn datatype(size));
• Example:
create table student
( roll_no char(10),
name char(20)
dt_of_birth date,
stream char(10)
city char(10),
marks number(5,1));
PROF. KRISHNA ROY, FMS, BCREC 4
20-09-2023
ddl command create
The following constraints are commonly used with the CREATE TABLE command
• NOT NULL - Ensures that a column cannot have a NULL value
• UNIQUE - Ensures that all values in a column are different
• PRIMARY KEY - A combination of a NOT NULL and UNIQUE. Uniquely identifies each row
in a table
• FOREIGN KEY - Uniquely identifies a row/record in another table
• CHECK - Ensures that all values in a column satisfies a specific condition
• DEFAULT - Sets a default value for a column when no value is specified
Example:
create table student
( roll_no char(10) not null primary key,
name char(20) not null,
dt_of_birth date,
mob_no number(10) unique,
stream char(10) check (stream in (‘Marketing’,’MIS’,’Finance’,’HR’)
city_code char(10) foreign key references city(city_code) default ‘Durgapur’,
marks number(5,1));
PROF. KRISHNA ROY, FMS, BCREC 5
20-09-2023
DDl command alter
• Alter command is used for changing the table structure.
• Alter command with the add clause adds new attribute definitions to an
existing table.
• Syntax with add clause
alter table <table name>
add ( attrib1 datatype(size),
: :
attribn datatype(size));
• Example
alter table student
add ( fname char(20),
result bool);
PROF. KRISHNA ROY, FMS, BCREC 6
20-09-2023
DDl command alter
• Alter command is used for changing the table structure.
• Alter command with the modify clause changes the type and size of existing
attributes.
• Syntax with modify clause
alter table <table name>
modify ( attrib1 datatype(size),
: :
attribn datatype(size));
• Example
alter table student
modify( roll_no number(10),
name char(30));
PROF. KRISHNA ROY, FMS, BCREC 7
20-09-2023
DDl command drop
• Drop command is used for removing the table structure
along with contents.
• Syntax
drop table <table name>;
• Example
drop table student;
PROF. KRISHNA ROY, FMS, BCREC 8
20-09-2023
DDl command truncate
• Truncate command is used for removing the table
contents and not the table definition.
• Syntax
truncate table <table name>;
• Example
truncate table student;
PROF. KRISHNA ROY, FMS, BCREC 9
20-09-2023
Data manipulation language
• DML is used for changing contents of the database
• DML commands are not auto-committed i.e. changes made by
these commands are not permanently saved in the database and
can be rolled back.
• DML commands are INSERT, UPDATE AND DELETE.
PROF. KRISHNA ROY, FMS, BCREC 10
20-09-2023
DML command insert
• The insert command is used for adding a row of data or record into a table
• There are more or less three variations of the insert command
as follows:
1. insert into <tablename>
values(val1, val2, ……, valn); here the field values must be provided
sequentially. No field value may be omitted though it may be replaced by
NULL(representing absence of a value)
Example:
insert into student values(123,’John’,’25-Mar-97’, ’marketing’, ’Durgapur’, 81.5, ’Robbins’, TRUE);
PROF. KRISHNA ROY, FMS, BCREC 11
20-09-2023
DML command insert
• The insert command is used for adding a row of data or record
into a table
• There are more or less three variations of the insert command
as follows:
2. insert into <tablename> (attrib1, attrib2,…, attribn)
values(val1, val2, ……, valn); here the field values must be
provided only for mentioned attributes in the mentioned sequence.
Example:
insert into student(name,marks,result,roll_no) values(‘Nikhil’, 75.0,TRUE,212);
PROF. KRISHNA ROY, FMS, BCREC 12
20-09-2023
DML command insert
• The insert command is used for adding a row of data or record into a table
• There are more or less three variations of the insert command
as follows:
3. insert into <tablename> (attrib1, attrib2,…, attribn)
values(&val1, &val2, ……, &valn); here the field values are input at runtime after
prompting and then the accepted entries are inserted as a record.
Example:
insert into student(name,marks,result,roll_no) values(‘&name’, &marks, &result, &roll_no);
Enter value for name: Girish
Enter value for marks: 25.5
Enter value for result: FALSE
Enter value for roll_no: 102
 Every time this command(macro substitution) is repeated, a new record can be input by the user with new values. The first
2 formats of insert, if repeated, insert duplicate records.
PROF. KRISHNA ROY, FMS, BCREC 13
20-09-2023
DML command update
• The update command is used for modifying/changing the content of a table
• In absence of the where clause , update command updates all the records
• The set clause is used to assign a constant value or an expression(after evaluation)
to an attribute in a tuple.
• Syntax: update <table name> set attrib1=value/expr, attrib2=value/expr, ……;
• Example: update student set stream=‘Finance’, marks=marks+10;
Stream for all students are set to Finance irrespective of their previous stream and
everyone’s marks are increased by 10
• In presence of the where clause, only the records satisfying the where clause are updated.
• Syntax: update <table name> set attrib1=value/expr, attrib2=value/expr, … where condition;
• Example: update student set stream=‘Finance’, marks=marks+10 where city=‘Durgapur’ and marks<33;
Stream for students residing in Durgapur and having obtained less than 33 marks are set to
Finance irrespective of their previous stream and their marks are increased by 10
PROF. KRISHNA ROY, FMS, BCREC 14
20-09-2023
DML command delete
• The delete command is used for removing entire records/tuples from a table
• In absence of the where clause , delete removes all the records from the table.
• If where clause is used then the records satisfying the where clause only, are
deleted.
• Syntax: delete from <table name>;
• Example: delete from student;
All student records are deleted leaving the empty table structure/definition.
• In presence of the where clause, only the records satisfying the where clause are updated.
• Syntax: delete from <table name> where condition;
• Example: delete from student where marks<33;
Records of students securing less than 33 are deleted. Rest of the records remain intact.
• delete either deletes entire records or not at all . Part of the record i.e. some of the
attributes can not be deleted using this command
PROF. KRISHNA ROY, FMS, BCREC 15
20-09-2023
• Till we meet again in the next class……….
PROF. KRISHNA ROY, FMS, BCREC 16
20-09-2023

More Related Content

Similar to MIS 301 RELATIONAL DATABASE MANAGEMENT SYSTEM 10,11&12.pptx

Introduction to sql new
Introduction to sql newIntroduction to sql new
Introduction to sql new
SANTOSH RATH
 
Creating a database
Creating a databaseCreating a database
Creating a database
Rahul Gupta
 
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptxMy lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
EliasPetros
 

Similar to MIS 301 RELATIONAL DATABASE MANAGEMENT SYSTEM 10,11&12.pptx (20)

SQL(DDL & DML)
SQL(DDL & DML)SQL(DDL & DML)
SQL(DDL & DML)
 
Sql statement,functions and joins
Sql statement,functions and joinsSql statement,functions and joins
Sql statement,functions and joins
 
Sqlbysandeep
SqlbysandeepSqlbysandeep
Sqlbysandeep
 
SQL commands
SQL commandsSQL commands
SQL commands
 
Oracle sql material
Oracle sql materialOracle sql material
Oracle sql material
 
Lab
LabLab
Lab
 
8. sql
8. sql8. sql
8. sql
 
DDL(Data defination Language ) Using Oracle
DDL(Data defination Language ) Using OracleDDL(Data defination Language ) Using Oracle
DDL(Data defination Language ) Using Oracle
 
STRUCTURED QUERY LANGUAGE
STRUCTURED QUERY LANGUAGESTRUCTURED QUERY LANGUAGE
STRUCTURED QUERY LANGUAGE
 
Introduction to sql new
Introduction to sql newIntroduction to sql new
Introduction to sql new
 
Unit - II.pptx
Unit - II.pptxUnit - II.pptx
Unit - II.pptx
 
unit-5 sql notes.docx
unit-5 sql notes.docxunit-5 sql notes.docx
unit-5 sql notes.docx
 
Creating a database
Creating a databaseCreating a database
Creating a database
 
Sql basics and DDL statements
Sql basics and DDL statementsSql basics and DDL statements
Sql basics and DDL statements
 
COMPUTERS SQL
COMPUTERS SQL COMPUTERS SQL
COMPUTERS SQL
 
Structured Query Language(SQL)
Structured Query Language(SQL)Structured Query Language(SQL)
Structured Query Language(SQL)
 
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptxMy lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
 
Basic sql Commands
Basic sql CommandsBasic sql Commands
Basic sql Commands
 
COMMANDS PPT(1).pdf
COMMANDS PPT(1).pdfCOMMANDS PPT(1).pdf
COMMANDS PPT(1).pdf
 
sql.pptx
sql.pptxsql.pptx
sql.pptx
 

More from KrishnaRoy45

More from KrishnaRoy45 (20)

MIS 301 RELATIONAL DATABASE MANAGEMENT SYSTEM 2&3.pptx
MIS 301 RELATIONAL DATABASE MANAGEMENT SYSTEM 2&3.pptxMIS 301 RELATIONAL DATABASE MANAGEMENT SYSTEM 2&3.pptx
MIS 301 RELATIONAL DATABASE MANAGEMENT SYSTEM 2&3.pptx
 
MIS 301 RELATIONAL DATABASE MANAGEMENT SYSTEM 1.pptx
MIS 301 RELATIONAL DATABASE MANAGEMENT SYSTEM 1.pptxMIS 301 RELATIONAL DATABASE MANAGEMENT SYSTEM 1.pptx
MIS 301 RELATIONAL DATABASE MANAGEMENT SYSTEM 1.pptx
 
MB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT 17.pptx
MB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT  17.pptxMB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT  17.pptx
MB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT 17.pptx
 
MB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT 15&16.pptx
MB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT  15&16.pptxMB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT  15&16.pptx
MB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT 15&16.pptx
 
MB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT 6&7.pptx
MB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT 6&7.pptxMB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT 6&7.pptx
MB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT 6&7.pptx
 
MB301 ENTREPRENEURSHIP & PROJECT MANAGEMENT 9&10.pptx
MB301 ENTREPRENEURSHIP & PROJECT MANAGEMENT 9&10.pptxMB301 ENTREPRENEURSHIP & PROJECT MANAGEMENT 9&10.pptx
MB301 ENTREPRENEURSHIP & PROJECT MANAGEMENT 9&10.pptx
 
MB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT 5.pptx
MB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT 5.pptxMB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT 5.pptx
MB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT 5.pptx
 
MB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT 11&12.pptx
MB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT 11&12.pptxMB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT 11&12.pptx
MB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT 11&12.pptx
 
MB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT 19.pptx
MB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT  19.pptxMB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT  19.pptx
MB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT 19.pptx
 
MB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT 3.pptx
MB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT 3.pptxMB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT 3.pptx
MB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT 3.pptx
 
MB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT 13&14.pptx
MB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT  13&14.pptxMB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT  13&14.pptx
MB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT 13&14.pptx
 
MB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT 1.pptx
MB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT 1.pptxMB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT 1.pptx
MB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT 1.pptx
 
MB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT 2.pptx
MB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT 2.pptxMB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT 2.pptx
MB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT 2.pptx
 
MB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT 18.pptx
MB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT  18.pptxMB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT  18.pptx
MB 301 ENTREPRENEURSHIP & PROJECT MANAGEMENT 18.pptx
 
MB 103 business communication 5_6.pptx
MB 103 business communication 5_6.pptxMB 103 business communication 5_6.pptx
MB 103 business communication 5_6.pptx
 
MB 103 business communication 7_8.pptx
MB 103 business communication 7_8.pptxMB 103 business communication 7_8.pptx
MB 103 business communication 7_8.pptx
 
MB 103 business communication 3_4.pptx
MB 103 business communication 3_4.pptxMB 103 business communication 3_4.pptx
MB 103 business communication 3_4.pptx
 
MB 103 business communication 9_10.pptx
MB 103 business communication 9_10.pptxMB 103 business communication 9_10.pptx
MB 103 business communication 9_10.pptx
 
MB 103 business communication 2.pptx
MB 103 business communication 2.pptxMB 103 business communication 2.pptx
MB 103 business communication 2.pptx
 
MB 103 business communication 1.pptx
MB 103 business communication 1.pptxMB 103 business communication 1.pptx
MB 103 business communication 1.pptx
 

Recently uploaded

Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
HyderabadDolls
 
Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...
Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...
Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...
nirzagarg
 
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
Gartner's Data Analytics Maturity Model.pptx
Gartner's Data Analytics Maturity Model.pptxGartner's Data Analytics Maturity Model.pptx
Gartner's Data Analytics Maturity Model.pptx
chadhar227
 
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
gajnagarg
 
Computer science Sql cheat sheet.pdf.pdf
Computer science Sql cheat sheet.pdf.pdfComputer science Sql cheat sheet.pdf.pdf
Computer science Sql cheat sheet.pdf.pdf
SayantanBiswas37
 
Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...
gajnagarg
 
Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...
gajnagarg
 
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...
gajnagarg
 
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...
nirzagarg
 
Sealdah % High Class Call Girls Kolkata - 450+ Call Girl Cash Payment 8005736...
Sealdah % High Class Call Girls Kolkata - 450+ Call Girl Cash Payment 8005736...Sealdah % High Class Call Girls Kolkata - 450+ Call Girl Cash Payment 8005736...
Sealdah % High Class Call Girls Kolkata - 450+ Call Girl Cash Payment 8005736...
HyderabadDolls
 
Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...
Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...
Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...
HyderabadDolls
 

Recently uploaded (20)

Kings of Saudi Arabia, information about them
Kings of Saudi Arabia, information about themKings of Saudi Arabia, information about them
Kings of Saudi Arabia, information about them
 
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Research
 
20240412-SmartCityIndex-2024-Full-Report.pdf
20240412-SmartCityIndex-2024-Full-Report.pdf20240412-SmartCityIndex-2024-Full-Report.pdf
20240412-SmartCityIndex-2024-Full-Report.pdf
 
Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...
Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...
Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...
 
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Gartner's Data Analytics Maturity Model.pptx
Gartner's Data Analytics Maturity Model.pptxGartner's Data Analytics Maturity Model.pptx
Gartner's Data Analytics Maturity Model.pptx
 
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
 
Computer science Sql cheat sheet.pdf.pdf
Computer science Sql cheat sheet.pdf.pdfComputer science Sql cheat sheet.pdf.pdf
Computer science Sql cheat sheet.pdf.pdf
 
Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...
 
Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...
 
Fun all Day Call Girls in Jaipur 9332606886 High Profile Call Girls You Ca...
Fun all Day Call Girls in Jaipur   9332606886  High Profile Call Girls You Ca...Fun all Day Call Girls in Jaipur   9332606886  High Profile Call Girls You Ca...
Fun all Day Call Girls in Jaipur 9332606886 High Profile Call Girls You Ca...
 
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...
 
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...
 
Sealdah % High Class Call Girls Kolkata - 450+ Call Girl Cash Payment 8005736...
Sealdah % High Class Call Girls Kolkata - 450+ Call Girl Cash Payment 8005736...Sealdah % High Class Call Girls Kolkata - 450+ Call Girl Cash Payment 8005736...
Sealdah % High Class Call Girls Kolkata - 450+ Call Girl Cash Payment 8005736...
 
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
 
Gomti Nagar & best call girls in Lucknow | 9548273370 Independent Escorts & D...
Gomti Nagar & best call girls in Lucknow | 9548273370 Independent Escorts & D...Gomti Nagar & best call girls in Lucknow | 9548273370 Independent Escorts & D...
Gomti Nagar & best call girls in Lucknow | 9548273370 Independent Escorts & D...
 
Statistics notes ,it includes mean to index numbers
Statistics notes ,it includes mean to index numbersStatistics notes ,it includes mean to index numbers
Statistics notes ,it includes mean to index numbers
 
Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...
Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...
Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...
 
TrafficWave Generator Will Instantly drive targeted and engaging traffic back...
TrafficWave Generator Will Instantly drive targeted and engaging traffic back...TrafficWave Generator Will Instantly drive targeted and engaging traffic back...
TrafficWave Generator Will Instantly drive targeted and engaging traffic back...
 

MIS 301 RELATIONAL DATABASE MANAGEMENT SYSTEM 10,11&12.pptx

  • 1. MIS 301 RELATIONAL DATABASE MANAGEMENT SYSTEM DATABASE MANAGEMENT SYSTEM Structured Query Language(SQL)-2 LECTURE 10,11,12 PROF. KRISHNA ROY
  • 2. Types of SQL Commands •DDL or Data Definition Language Command • DML or Data Manipulation Language Command •DCL or Data Control Language Command • TCL or Transaction Control Language Command • DQL or Data Query Language Command PROF. KRISHNA ROY, FMS, BCREC 2 20-09-2023
  • 3. Data definition language • DDL is used for creating table structures, modifying existing structures as well as for removing such structures • DDL commands are auto-committed i.e. changes made by these commands are permanently saved in the database. • DDL commands are CREATE, ALTER, DROP, TRUNCATE PROF. KRISHNA ROY, FMS, BCREC 3 20-09-2023
  • 4. ddl command create • This command creates a new table in the database. • Syntax: create table <table name> ( attrib1 datatype(size), attrib2 datatype(size), : : attribn datatype(size)); • Example: create table student ( roll_no char(10), name char(20) dt_of_birth date, stream char(10) city char(10), marks number(5,1)); PROF. KRISHNA ROY, FMS, BCREC 4 20-09-2023
  • 5. ddl command create The following constraints are commonly used with the CREATE TABLE command • NOT NULL - Ensures that a column cannot have a NULL value • UNIQUE - Ensures that all values in a column are different • PRIMARY KEY - A combination of a NOT NULL and UNIQUE. Uniquely identifies each row in a table • FOREIGN KEY - Uniquely identifies a row/record in another table • CHECK - Ensures that all values in a column satisfies a specific condition • DEFAULT - Sets a default value for a column when no value is specified Example: create table student ( roll_no char(10) not null primary key, name char(20) not null, dt_of_birth date, mob_no number(10) unique, stream char(10) check (stream in (‘Marketing’,’MIS’,’Finance’,’HR’) city_code char(10) foreign key references city(city_code) default ‘Durgapur’, marks number(5,1)); PROF. KRISHNA ROY, FMS, BCREC 5 20-09-2023
  • 6. DDl command alter • Alter command is used for changing the table structure. • Alter command with the add clause adds new attribute definitions to an existing table. • Syntax with add clause alter table <table name> add ( attrib1 datatype(size), : : attribn datatype(size)); • Example alter table student add ( fname char(20), result bool); PROF. KRISHNA ROY, FMS, BCREC 6 20-09-2023
  • 7. DDl command alter • Alter command is used for changing the table structure. • Alter command with the modify clause changes the type and size of existing attributes. • Syntax with modify clause alter table <table name> modify ( attrib1 datatype(size), : : attribn datatype(size)); • Example alter table student modify( roll_no number(10), name char(30)); PROF. KRISHNA ROY, FMS, BCREC 7 20-09-2023
  • 8. DDl command drop • Drop command is used for removing the table structure along with contents. • Syntax drop table <table name>; • Example drop table student; PROF. KRISHNA ROY, FMS, BCREC 8 20-09-2023
  • 9. DDl command truncate • Truncate command is used for removing the table contents and not the table definition. • Syntax truncate table <table name>; • Example truncate table student; PROF. KRISHNA ROY, FMS, BCREC 9 20-09-2023
  • 10. Data manipulation language • DML is used for changing contents of the database • DML commands are not auto-committed i.e. changes made by these commands are not permanently saved in the database and can be rolled back. • DML commands are INSERT, UPDATE AND DELETE. PROF. KRISHNA ROY, FMS, BCREC 10 20-09-2023
  • 11. DML command insert • The insert command is used for adding a row of data or record into a table • There are more or less three variations of the insert command as follows: 1. insert into <tablename> values(val1, val2, ……, valn); here the field values must be provided sequentially. No field value may be omitted though it may be replaced by NULL(representing absence of a value) Example: insert into student values(123,’John’,’25-Mar-97’, ’marketing’, ’Durgapur’, 81.5, ’Robbins’, TRUE); PROF. KRISHNA ROY, FMS, BCREC 11 20-09-2023
  • 12. DML command insert • The insert command is used for adding a row of data or record into a table • There are more or less three variations of the insert command as follows: 2. insert into <tablename> (attrib1, attrib2,…, attribn) values(val1, val2, ……, valn); here the field values must be provided only for mentioned attributes in the mentioned sequence. Example: insert into student(name,marks,result,roll_no) values(‘Nikhil’, 75.0,TRUE,212); PROF. KRISHNA ROY, FMS, BCREC 12 20-09-2023
  • 13. DML command insert • The insert command is used for adding a row of data or record into a table • There are more or less three variations of the insert command as follows: 3. insert into <tablename> (attrib1, attrib2,…, attribn) values(&val1, &val2, ……, &valn); here the field values are input at runtime after prompting and then the accepted entries are inserted as a record. Example: insert into student(name,marks,result,roll_no) values(‘&name’, &marks, &result, &roll_no); Enter value for name: Girish Enter value for marks: 25.5 Enter value for result: FALSE Enter value for roll_no: 102  Every time this command(macro substitution) is repeated, a new record can be input by the user with new values. The first 2 formats of insert, if repeated, insert duplicate records. PROF. KRISHNA ROY, FMS, BCREC 13 20-09-2023
  • 14. DML command update • The update command is used for modifying/changing the content of a table • In absence of the where clause , update command updates all the records • The set clause is used to assign a constant value or an expression(after evaluation) to an attribute in a tuple. • Syntax: update <table name> set attrib1=value/expr, attrib2=value/expr, ……; • Example: update student set stream=‘Finance’, marks=marks+10; Stream for all students are set to Finance irrespective of their previous stream and everyone’s marks are increased by 10 • In presence of the where clause, only the records satisfying the where clause are updated. • Syntax: update <table name> set attrib1=value/expr, attrib2=value/expr, … where condition; • Example: update student set stream=‘Finance’, marks=marks+10 where city=‘Durgapur’ and marks<33; Stream for students residing in Durgapur and having obtained less than 33 marks are set to Finance irrespective of their previous stream and their marks are increased by 10 PROF. KRISHNA ROY, FMS, BCREC 14 20-09-2023
  • 15. DML command delete • The delete command is used for removing entire records/tuples from a table • In absence of the where clause , delete removes all the records from the table. • If where clause is used then the records satisfying the where clause only, are deleted. • Syntax: delete from <table name>; • Example: delete from student; All student records are deleted leaving the empty table structure/definition. • In presence of the where clause, only the records satisfying the where clause are updated. • Syntax: delete from <table name> where condition; • Example: delete from student where marks<33; Records of students securing less than 33 are deleted. Rest of the records remain intact. • delete either deletes entire records or not at all . Part of the record i.e. some of the attributes can not be deleted using this command PROF. KRISHNA ROY, FMS, BCREC 15 20-09-2023
  • 16. • Till we meet again in the next class………. PROF. KRISHNA ROY, FMS, BCREC 16 20-09-2023