SlideShare a Scribd company logo
1 of 34
Lecture-6
Dr.Purnendu 1
Database Language
• Structured Query Language (SQL) is the database
language by the use of which we can perform certain
operations on the existing database and also we can use
this language to create a database.
• SQL uses certain commands like Create, Drop, and Insert
etc. to carry out the required tasks.
Dr.Purnendu 2
• These SQL commands are mainly categorized into five categories as:
• DDL – Data Definition Language
• DML – Data Manipulation Language
• DQL-Data Query Language
• DCL – Data Control Language
• Though many resources claim there to be another category of SQL clauses TCL –
Transaction Control Language. So we will see in detail about TCL as well.
(https://www.geeksforgeeks.org/sql-ddl-dql-dml-dcl-tcl-commands/)
Dr.Purnendu 3
SQL Commands
Dr.Purnendu 4
Activity 1: Create a table Person_info with 5
attributes and insert 5 rows into it and then show
the table
Dr.Purnendu 5
Activity 1: Create a table Person_info with 5
attributes and insert 5 rows into it and then show
the table.
Dr.Purnendu 6
Install EMP/DEPT table
Dr.Purnendu 7
Use describe table_name to get the schema
and its related Info.
Dr.Purnendu 8
Click on (SQL WorkshopObject Browser) to see all the tables that we have created on
left hand side and on right side u can see the attributes and other info.
Dr.Purnendu 9
Import your CSV or excel data directly to work on that,
go to App Builderclick on create and then from a file
to upload ur csv/excel file
Dr.Purnendu 10
So now you can work around this table
Dr.Purnendu 11
Describe AI to see the schema
Dr.Purnendu 12
Insert multiple rows(values) in the table, select all and then run.
Note:Remember that these commands may change for different platforms
(e.g MYSQL)
Dr.Purnendu 13
Apex command to insert multiple rows.
• begin
• INSERT INTO AI VALUES (76, 2023, 'clothings', 'Caps', 600, 0.99);
• INSERT INTO AI VALUES (77, 2022, 'Bikes', 'Touring Bikes', 6600, 0.90);
• end;
Dr.Purnendu 14
For MYSQL the multiple rows insertion follows this way.
So better choose 1 platform and work on it.
So in this course we will learn Apex Oracle and some
time MYSQL too.
Dr.Purnendu 15
Data Definition Language (DDL)
Dr.Purnendu 16
Data Definition Language (DDL)
• Specification notation for defining the database schema
Example: create table instructor (
ID char(5),
name varchar(20),
dept_name varchar(20),
salary numeric(8,2))
• DDL compiler generates a set of table templates stored in a
data dictionary
• Data dictionary contains metadata (i.e., data about data)
• Database schema
• Integrity constraints
• Primary key (roll uniquely identifies student)
• Authorization
• Who can access what
Dr.Purnendu 17
Data Definition Language (DDL)
• Examples of DDL commands:
• CREATE – is used to create the database or its
objects (like table, index, function, views, store
procedure and triggers).
• DROP – is used to delete objects from the database.
• ALTER-is used to alter the structure of the database.
• TRUNCATE–is used to remove all records from a
table, including all spaces allocated for the records are
removed.
• COMMENT –is used to add comments to the data
dictionary.
• RENAME –is used to rename an object existing in the
database.
Dr.Purnendu 18
Alter in Apex Oracle: ALTER-is used to alter the structure of the database, Earlier the table Person_info
have attributes such as ( PersonID int, LastName varchar(255), FirstName varchar(255), Address
varchar(255), City varchar(255) ) but at line 2 and 3 we have added a new attribute named
phone_number.
Dr.Purnendu 19
Alter in Apex Oracle-Output
Dr.Purnendu 20
Alter in Oracle
Dr.Purnendu 21
Truncate will remove the data but table will still be there e.g here
data inside table Person_info will be deleted although table will still
be there.
Dr.Purnendu 22
After truncate we can see that data is not found, but we know that after
running truncate only data gets deleted but schema does not deletes. So to
check the schema type command (describe Person_Info)
Dr.Purnendu 23
Truncate and Drop (Oracle)
Dr.Purnendu 24
So, now after running truncate all the data is removed only schema is left.
It is faster than DELETE as it removes all rows in a single operation.
Dr.Purnendu 25
Dropping Student table and then trying to see its
schema, it shows object not found that means
(Schema+Data) all dropped.
Dr.Purnendu 26
Delete: Here we have Created a table name AAA and inserted multiple values into it, now delete
the first row where AAA_ID=1, note here we will use ‘where’ clause and we will study about it in
coming sessions.
Dr.Purnendu 27
Delete Command: It may be slower than TRUNCATE
because it removes rows one at a time.
Before Delete
After running Delete
command
Dr.Purnendu 28
Activity 2: Do the following activities
1) Create a table (schema),
2) Add the rows(values) using insert,
3) Delete the table,
4) Truncate the table,
5) Apply all the Alter commands given at
(https://www.w3schools.com/sql/sql_alter.asp)
6) Drop that table.
Note: Have a screen shot of all these activities and mail me the
word format(extension: Name_Classrollno) at:
purnendu.pandey@kiet.edu
Dr.Purnendu 29
DML(Data Manipulation Language)
• DML(Data Manipulation Language) : The SQL commands that
deals with the manipulation of data present in the database belong to
DML or Data Manipulation Language and this includes most of the
SQL statements.
• Examples of DML:
• INSERT – is used to insert data into a table.
• UPDATE – is used to update existing data within a table.
• DELETE – is used to delete records from a database table.
• MERGE – is used to make changes in one table based on values
matched from anther. It can be used to combine insert, update,
and delete operations into one statement.
Dr.Purnendu 30
DML(Data Manipulation Language)
Dr.Purnendu 31
DQL-Data Query Language
• SELECT – is used to retrieve data from the a database.
Dr.Purnendu 32
Insert
Dr.Purnendu 33
DCL(Data Control Language)
• DCL (Data Control Language): DCL includes commands
such as GRANT and REVOKE which mainly deals with the
rights, permissions and other controls of the database
system.
• Examples of DCL commands:
• GRANT-gives user’s access privileges to database.
• REVOKE-withdraw user’s access privileges given by
using the GRANT command.
Dr.Purnendu 34

More Related Content

Similar to SQL commands in database management system

dbs class 7.ppt
dbs class 7.pptdbs class 7.ppt
dbs class 7.pptMARasheed3
 
Relational Database Language.pptx
Relational Database Language.pptxRelational Database Language.pptx
Relational Database Language.pptxSheethal Aji Mani
 
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptxMy lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptxEliasPetros
 
Db2 migration -_tips,_tricks,_and_pitfalls
Db2 migration -_tips,_tricks,_and_pitfallsDb2 migration -_tips,_tricks,_and_pitfalls
Db2 migration -_tips,_tricks,_and_pitfallssam2sung2
 
Most useful queries
Most useful queriesMost useful queries
Most useful queriesSam Depp
 
Database Management Lab -SQL Queries
Database Management Lab -SQL Queries Database Management Lab -SQL Queries
Database Management Lab -SQL Queries shamim hossain
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...Alex Zaballa
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...Alex Zaballa
 
Getting Started with MySQL I
Getting Started with MySQL IGetting Started with MySQL I
Getting Started with MySQL ISankhya_Analytics
 
从 Oracle 合并到 my sql npr 实例分析
从 Oracle 合并到 my sql   npr 实例分析从 Oracle 合并到 my sql   npr 实例分析
从 Oracle 合并到 my sql npr 实例分析YUCHENG HU
 
Discard inport exchange table & tablespace
Discard inport exchange table & tablespaceDiscard inport exchange table & tablespace
Discard inport exchange table & tablespaceMarco Tusa
 
Lecture on DBMS & MySQL.pdf v. C. .
Lecture on DBMS & MySQL.pdf v.  C.     .Lecture on DBMS & MySQL.pdf v.  C.     .
Lecture on DBMS & MySQL.pdf v. C. .MayankSinghRawat6
 

Similar to SQL commands in database management system (20)

SQL for interview
SQL for interviewSQL for interview
SQL for interview
 
dbs class 7.ppt
dbs class 7.pptdbs class 7.ppt
dbs class 7.ppt
 
Oracle 11g SQL Overview
Oracle 11g SQL OverviewOracle 11g SQL Overview
Oracle 11g SQL Overview
 
Relational Database Language.pptx
Relational Database Language.pptxRelational Database Language.pptx
Relational Database Language.pptx
 
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptxMy lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
 
Rdbms day3
Rdbms day3Rdbms day3
Rdbms day3
 
Db2 migration -_tips,_tricks,_and_pitfalls
Db2 migration -_tips,_tricks,_and_pitfallsDb2 migration -_tips,_tricks,_and_pitfalls
Db2 migration -_tips,_tricks,_and_pitfalls
 
Most useful queries
Most useful queriesMost useful queries
Most useful queries
 
Lab2 ddl commands
Lab2 ddl commandsLab2 ddl commands
Lab2 ddl commands
 
Database Management Lab -SQL Queries
Database Management Lab -SQL Queries Database Management Lab -SQL Queries
Database Management Lab -SQL Queries
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
 
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with ExamplesDML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
 
Getting Started with MySQL I
Getting Started with MySQL IGetting Started with MySQL I
Getting Started with MySQL I
 
Unit - II.pptx
Unit - II.pptxUnit - II.pptx
Unit - II.pptx
 
Module02
Module02Module02
Module02
 
从 Oracle 合并到 my sql npr 实例分析
从 Oracle 合并到 my sql   npr 实例分析从 Oracle 合并到 my sql   npr 实例分析
从 Oracle 合并到 my sql npr 实例分析
 
SQL_NOTES.pdf
SQL_NOTES.pdfSQL_NOTES.pdf
SQL_NOTES.pdf
 
Discard inport exchange table & tablespace
Discard inport exchange table & tablespaceDiscard inport exchange table & tablespace
Discard inport exchange table & tablespace
 
Lecture on DBMS & MySQL.pdf v. C. .
Lecture on DBMS & MySQL.pdf v.  C.     .Lecture on DBMS & MySQL.pdf v.  C.     .
Lecture on DBMS & MySQL.pdf v. C. .
 

Recently uploaded

Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment
 Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment
Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatmentsaipooja36
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxLimon Prince
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhleson0603
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi RajagopalEADTU
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...Nguyen Thanh Tu Collection
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...Nguyen Thanh Tu Collection
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...EduSkills OECD
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppCeline George
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...Nguyen Thanh Tu Collection
 
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45MysoreMuleSoftMeetup
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMELOISARIVERA8
 
philosophy and it's principles based on the life
philosophy and it's principles based on the lifephilosophy and it's principles based on the life
philosophy and it's principles based on the lifeNitinDeodare
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppCeline George
 
Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).Mohamed Rizk Khodair
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxneillewis46
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesAmanpreetKaur157993
 
The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxheathfieldcps1
 
MSc Ag Genetics & Plant Breeding: Insights from Previous Year JNKVV Entrance ...
MSc Ag Genetics & Plant Breeding: Insights from Previous Year JNKVV Entrance ...MSc Ag Genetics & Plant Breeding: Insights from Previous Year JNKVV Entrance ...
MSc Ag Genetics & Plant Breeding: Insights from Previous Year JNKVV Entrance ...Krashi Coaching
 

Recently uploaded (20)

Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment
 Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment
Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment
 
Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"
Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"
Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
“O BEIJO” EM ARTE .
“O BEIJO” EM ARTE                       .“O BEIJO” EM ARTE                       .
“O BEIJO” EM ARTE .
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge App
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
 
philosophy and it's principles based on the life
philosophy and it's principles based on the lifephilosophy and it's principles based on the life
philosophy and it's principles based on the life
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptx
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategies
 
The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptx
 
MSc Ag Genetics & Plant Breeding: Insights from Previous Year JNKVV Entrance ...
MSc Ag Genetics & Plant Breeding: Insights from Previous Year JNKVV Entrance ...MSc Ag Genetics & Plant Breeding: Insights from Previous Year JNKVV Entrance ...
MSc Ag Genetics & Plant Breeding: Insights from Previous Year JNKVV Entrance ...
 

SQL commands in database management system

  • 2. Database Language • Structured Query Language (SQL) is the database language by the use of which we can perform certain operations on the existing database and also we can use this language to create a database. • SQL uses certain commands like Create, Drop, and Insert etc. to carry out the required tasks. Dr.Purnendu 2
  • 3. • These SQL commands are mainly categorized into five categories as: • DDL – Data Definition Language • DML – Data Manipulation Language • DQL-Data Query Language • DCL – Data Control Language • Though many resources claim there to be another category of SQL clauses TCL – Transaction Control Language. So we will see in detail about TCL as well. (https://www.geeksforgeeks.org/sql-ddl-dql-dml-dcl-tcl-commands/) Dr.Purnendu 3
  • 5. Activity 1: Create a table Person_info with 5 attributes and insert 5 rows into it and then show the table Dr.Purnendu 5
  • 6. Activity 1: Create a table Person_info with 5 attributes and insert 5 rows into it and then show the table. Dr.Purnendu 6
  • 8. Use describe table_name to get the schema and its related Info. Dr.Purnendu 8
  • 9. Click on (SQL WorkshopObject Browser) to see all the tables that we have created on left hand side and on right side u can see the attributes and other info. Dr.Purnendu 9
  • 10. Import your CSV or excel data directly to work on that, go to App Builderclick on create and then from a file to upload ur csv/excel file Dr.Purnendu 10
  • 11. So now you can work around this table Dr.Purnendu 11
  • 12. Describe AI to see the schema Dr.Purnendu 12
  • 13. Insert multiple rows(values) in the table, select all and then run. Note:Remember that these commands may change for different platforms (e.g MYSQL) Dr.Purnendu 13
  • 14. Apex command to insert multiple rows. • begin • INSERT INTO AI VALUES (76, 2023, 'clothings', 'Caps', 600, 0.99); • INSERT INTO AI VALUES (77, 2022, 'Bikes', 'Touring Bikes', 6600, 0.90); • end; Dr.Purnendu 14
  • 15. For MYSQL the multiple rows insertion follows this way. So better choose 1 platform and work on it. So in this course we will learn Apex Oracle and some time MYSQL too. Dr.Purnendu 15
  • 16. Data Definition Language (DDL) Dr.Purnendu 16
  • 17. Data Definition Language (DDL) • Specification notation for defining the database schema Example: create table instructor ( ID char(5), name varchar(20), dept_name varchar(20), salary numeric(8,2)) • DDL compiler generates a set of table templates stored in a data dictionary • Data dictionary contains metadata (i.e., data about data) • Database schema • Integrity constraints • Primary key (roll uniquely identifies student) • Authorization • Who can access what Dr.Purnendu 17
  • 18. Data Definition Language (DDL) • Examples of DDL commands: • CREATE – is used to create the database or its objects (like table, index, function, views, store procedure and triggers). • DROP – is used to delete objects from the database. • ALTER-is used to alter the structure of the database. • TRUNCATE–is used to remove all records from a table, including all spaces allocated for the records are removed. • COMMENT –is used to add comments to the data dictionary. • RENAME –is used to rename an object existing in the database. Dr.Purnendu 18
  • 19. Alter in Apex Oracle: ALTER-is used to alter the structure of the database, Earlier the table Person_info have attributes such as ( PersonID int, LastName varchar(255), FirstName varchar(255), Address varchar(255), City varchar(255) ) but at line 2 and 3 we have added a new attribute named phone_number. Dr.Purnendu 19
  • 20. Alter in Apex Oracle-Output Dr.Purnendu 20
  • 22. Truncate will remove the data but table will still be there e.g here data inside table Person_info will be deleted although table will still be there. Dr.Purnendu 22
  • 23. After truncate we can see that data is not found, but we know that after running truncate only data gets deleted but schema does not deletes. So to check the schema type command (describe Person_Info) Dr.Purnendu 23
  • 24. Truncate and Drop (Oracle) Dr.Purnendu 24
  • 25. So, now after running truncate all the data is removed only schema is left. It is faster than DELETE as it removes all rows in a single operation. Dr.Purnendu 25
  • 26. Dropping Student table and then trying to see its schema, it shows object not found that means (Schema+Data) all dropped. Dr.Purnendu 26
  • 27. Delete: Here we have Created a table name AAA and inserted multiple values into it, now delete the first row where AAA_ID=1, note here we will use ‘where’ clause and we will study about it in coming sessions. Dr.Purnendu 27
  • 28. Delete Command: It may be slower than TRUNCATE because it removes rows one at a time. Before Delete After running Delete command Dr.Purnendu 28
  • 29. Activity 2: Do the following activities 1) Create a table (schema), 2) Add the rows(values) using insert, 3) Delete the table, 4) Truncate the table, 5) Apply all the Alter commands given at (https://www.w3schools.com/sql/sql_alter.asp) 6) Drop that table. Note: Have a screen shot of all these activities and mail me the word format(extension: Name_Classrollno) at: purnendu.pandey@kiet.edu Dr.Purnendu 29
  • 30. DML(Data Manipulation Language) • DML(Data Manipulation Language) : The SQL commands that deals with the manipulation of data present in the database belong to DML or Data Manipulation Language and this includes most of the SQL statements. • Examples of DML: • INSERT – is used to insert data into a table. • UPDATE – is used to update existing data within a table. • DELETE – is used to delete records from a database table. • MERGE – is used to make changes in one table based on values matched from anther. It can be used to combine insert, update, and delete operations into one statement. Dr.Purnendu 30
  • 32. DQL-Data Query Language • SELECT – is used to retrieve data from the a database. Dr.Purnendu 32
  • 34. DCL(Data Control Language) • DCL (Data Control Language): DCL includes commands such as GRANT and REVOKE which mainly deals with the rights, permissions and other controls of the database system. • Examples of DCL commands: • GRANT-gives user’s access privileges to database. • REVOKE-withdraw user’s access privileges given by using the GRANT command. Dr.Purnendu 34