SlideShare a Scribd company logo
UPDATE - UPDATING A TABLE
• Changes values in a table
Syntax:
UPDATE <table name>/<view name>
 SET <column name> = <new value>
 [,<column name> = <new value>...]
 [<WHERE clause>];
• The WHERE clause specifies the rows to be UPDATEd

• Omitting this clause UPDATEs all rows in the table.
                                                    MGCL12SQL4
Ex:
      UPDATE EMP
         SET salary = salary +1000
             WHERE Job = ‘Analyst’ ;


UPDATE EMP
         SET salary = salary +1000,
          comm = 5000
             WHERE Job = ‘SALESMAN’ ;



                                        MGCL12SQL4
DELETE - DELETING ROWS FROM A TABLE
•Removes one or more rows from a table.


DELETE FROM <table name> [<alias name>]
 [<WHERE clause>];
• The WHERE clause specifies rows to be deleted.
• If the WHERE clause is not included, all rows will be
deleted.



                                                   MGCL12SQL4
DELETE FROM Employee     WHERE name =
'Mihir';
DELETE * FROM Employee;
 DELETE FROM Employee WHERE name NOT
IN (‘Tony’, ‘Tom’);
DELETE FROM Employee      WHERE salary <
10000;



                                    MGCL12SQL4
ALTER TABLE - ADDING ATTRIBUTES TO A
TABLE
•Adds new columns to a table.


ALTER TABLE <table name>
 ADD (<column name> <data type>
 [,<column name> <data type>...]);


Ex:   ALTER TABLE staff
      ADD (phone CHAR(13));
                                     MGCL12SQL4
ALTER TABLE staff
    drop column phone;



ALTER TABLE staff
    modify name varchar2(40);




                                MGCL12SQL4
DROP TABLE – REMOVING A TABLE
Removes specified table from the active database.


DROP TABLE <table name>;


When you DROP a table, all indexes, synonyms, and
views associated with it are DROPped.


Ex:   DROP TABLE emp;

                                                    MGCL12SQL4
CREATE VIEW – CREATING A VIEW
Defines a view that combines data from one or
more tables/views.
A column list must be specified if any of the
columns in the SELECT are calculated columns or
expressions, otherwise view columns inherit default
names from the base table(s)/view(s).
CREATE VIEW <view name> [(<column name>,
<column name>..)]
 AS <SELECT        command>      [WITH    CHECK
OPTION];
                                              MGCL12SQL4
Ex:
CREATE VIEW emp AS SELECT * FROM
   Employee
      WHERE dept = 'SOFTWARE';




                                 MGCL12SQL4
DROP VIEW – REMOVING A VIEW
Removes specified view from the active database.
      DROP VIEW <view name>;
When a view is DROPped, all other views and
synonyms based on it are dropped automatically.
When a table is dropped, all views based on it are also
dropped.
Ex: DROP VIEW empview;




                                                    MGCL12SQL4
Aggregate functions
Aggregate functions work with a group of values and
reduce them to a single value.
COUNT
• counts rows/records
• * can be used instead of ALL
      COUNT ({*/[DISTINCT] <column name>})
• Used in SELECT or HAVING clause to count the
number of rows returned by an SQL command
• DISTINCT omits any repeated values

                                              MGCL12SQL4
•If used in the SELECT clause, all other columns
SELECTed must also be SQL aggregate functions or
columns specified in a GROUP BY clause
Examples
SELECT COUNT (*)     FROM staff   WHERE salary >
15500;
SELECT COUNT (DISTINCT name) FROM Employee;
SELECT COUNT (*) FROM Employee;
 SELECT COUNT(ALL desig) from Employee where
salary >15500;


                                           MGCL12SQL4
MAX and MIN
• Used in SELECT or HAVING clauses
• MAX() function returns the highest value in the specified
column or column expression
• MIN() returns the lowest value
• If used in the SELECT clause, all other columns selected
must also be SQL aggregate functions or columns specified
in a GROUP BY clause.
{MAX/MIN} ([ALL/DISTINCT] <column name>)


SELECT MAX (salary), MIN (salary) FROM Emp;
                                                    MGCL12SQL4
SUM
• Used in the SELECT or HAVING clauses to find the
sum of values for the specified column.
• ALL is the default.
• DISTINCT omits any repeated values.
• If used in the SELECT clause, all other columns
SELECTed must also be SQL aggregate functions or
columns specified in a GROUP BY clause.
      SUM ([ALL/DISTINCT] <column name>)


SELECT SUM(salary) from Emp;
                                              MGCL12SQL4
AVG
Used in the SELECT or HAVING clause to find the
average value for the specified column or column
expression.
ALL is the default.
DISTINCT omits any repeated values.
If used in the SELECT clause, all other columns
SELECTed must also be SQL aggregate functions or
columns specified in a GROUP BY clause.
       AVG ([ALL/DISTINCT] <column name>)
SELECT AVG (Height) FROM Student;
                                            MGCL12SQL4
AGGREGATE CLAUSES : GROUP BY AND
HAVING
GROUP BY clause
• Is used to divide the rows in a table into smaller groups
• Grouping can be done by a column name, or with
aggregate function




                                                       MGCL12SQL4
GROUP BY <column name>[,<column name>...]
• Group functions (AVG, MAX, MIN, SUM, COUNT)
can be used with group by clause to return summary
information for each group
• Any non-aggregate function columns in a SELECT
clause that includes aggregate functions must be specified
in a GROUP BY clause
• You cannot GROUP BY columns of type LOGICAL




                                                     MGCL12SQL4
• Groups rows together that have duplicate values for the
specified column
• SQL aggregate functions (AVG, MAX, MIN, SUM, or
COUNT) in a SELECT clause operate on each group
• Any non-aggregate function columns in a SELECT
clause that includes aggregate functions must be specified
in a GROUP BY clause
• You cannot GROUP BY columns of type LOGICAL
• WHERE clause can be used to exclude rows before
forming groups


                                                     MGCL12SQL4
SELECT Class, COUNT(Sname) FROM Student GROUP
BY Class;
SELECT Dept, COUNT(ename) FROM Emp GROUP
BY dept;
SELECT Class, AVG(Height) FROM Student GROUP
BY Class;
SELECT Dept, MAX(salary) FROM Emp WHERE DOJ
> ’01-Jan-2005’ GROUP BY dept;
SELECT Class, Sec, COUNT(*) FROM Student GROUP
BY Class, Sec;
(Group all students by class, then within each class group
by sec)
                                                      MGCL12SQL4
HAVING clause
• Used to restrict groups returned from GROUP BY
clause
• places condition on groups
• can include aggregate functions
      HAVING [NOT]<search condition>
• In a query using GROUP BY and HAVING clause,
the rows are first grouped, group functions are applied
and then only those groups matching HAVING clause
are displayed


                                                 MGCL12SQL4
SELECT dept, MAX(salary) FROM Emp
     GROUP BY dept
           HAVING COUNT(*) > 10;


SELECT job_code,avg(salary), sum(salary)
from Emp
      GROUP BY job_code
           HAVING job_code=3;



                                           MGCL12SQL4

More Related Content

What's hot

Nested Queries Lecture
Nested Queries LectureNested Queries Lecture
Nested Queries Lecture
Felipe Costa
 
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
 
SQL Views
SQL ViewsSQL Views
Oracle Sql & PLSQL Complete guide
Oracle Sql & PLSQL Complete guideOracle Sql & PLSQL Complete guide
Oracle Sql & PLSQL Complete guide
Raviteja Chowdary Adusumalli
 
MySQL Pro
MySQL ProMySQL Pro
Commands of DML in SQL
Commands of DML in SQLCommands of DML in SQL
Commands of DML in SQL
Ashish Gaurkhede
 
Database Management System 1
Database Management System 1Database Management System 1
Database Management System 1
Swapnali Pawar
 
DDL,DML,SQL Functions and Joins
DDL,DML,SQL Functions and JoinsDDL,DML,SQL Functions and Joins
DDL,DML,SQL Functions and Joins
Ashwin Dinoriya
 
Lab1 select statement
Lab1 select statementLab1 select statement
Lab1 select statement
Balqees Al.Mubarak
 
Les01 (retrieving data using the sql select statement)
Les01 (retrieving data using the sql select statement)Les01 (retrieving data using the sql select statement)
Les01 (retrieving data using the sql select statement)
Achmad Solichin
 
Null values, insert, delete and update in database
Null values, insert, delete and update in databaseNull values, insert, delete and update in database
Null values, insert, delete and update in database
Hemant Suthar
 
SQL select statement and functions
SQL select statement and functionsSQL select statement and functions
SQL select statement and functions
Vikas Gupta
 
Best sql plsql material
Best sql plsql materialBest sql plsql material
Best sql plsql material
pitchaiah yechuri
 
SQL
SQLSQL
Sql DML
Sql DMLSql DML
Sql DML
Vikas Gupta
 
Views, Triggers, Functions, Stored Procedures, Indexing and Joins
Views, Triggers, Functions, Stored Procedures,  Indexing and JoinsViews, Triggers, Functions, Stored Procedures,  Indexing and Joins
Views, Triggers, Functions, Stored Procedures, Indexing and Joins
baabtra.com - No. 1 supplier of quality freshers
 
View & index in SQL
View & index in SQLView & index in SQL
View & index in SQL
Swapnali Pawar
 

What's hot (17)

Nested Queries Lecture
Nested Queries LectureNested Queries Lecture
Nested Queries Lecture
 
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
 
SQL Views
SQL ViewsSQL Views
SQL Views
 
Oracle Sql & PLSQL Complete guide
Oracle Sql & PLSQL Complete guideOracle Sql & PLSQL Complete guide
Oracle Sql & PLSQL Complete guide
 
MySQL Pro
MySQL ProMySQL Pro
MySQL Pro
 
Commands of DML in SQL
Commands of DML in SQLCommands of DML in SQL
Commands of DML in SQL
 
Database Management System 1
Database Management System 1Database Management System 1
Database Management System 1
 
DDL,DML,SQL Functions and Joins
DDL,DML,SQL Functions and JoinsDDL,DML,SQL Functions and Joins
DDL,DML,SQL Functions and Joins
 
Lab1 select statement
Lab1 select statementLab1 select statement
Lab1 select statement
 
Les01 (retrieving data using the sql select statement)
Les01 (retrieving data using the sql select statement)Les01 (retrieving data using the sql select statement)
Les01 (retrieving data using the sql select statement)
 
Null values, insert, delete and update in database
Null values, insert, delete and update in databaseNull values, insert, delete and update in database
Null values, insert, delete and update in database
 
SQL select statement and functions
SQL select statement and functionsSQL select statement and functions
SQL select statement and functions
 
Best sql plsql material
Best sql plsql materialBest sql plsql material
Best sql plsql material
 
SQL
SQLSQL
SQL
 
Sql DML
Sql DMLSql DML
Sql DML
 
Views, Triggers, Functions, Stored Procedures, Indexing and Joins
Views, Triggers, Functions, Stored Procedures,  Indexing and JoinsViews, Triggers, Functions, Stored Procedures,  Indexing and Joins
Views, Triggers, Functions, Stored Procedures, Indexing and Joins
 
View & index in SQL
View & index in SQLView & index in SQL
View & index in SQL
 

Viewers also liked

Ashraya
AshrayaAshraya
Ashraya
DYUTI
 
Николай Коперник
Николай КоперникНиколай Коперник
Николай КоперникArtur
 
Taller Dels Animalons
Taller Dels AnimalonsTaller Dels Animalons
Taller Dels Animalons
guest4ab9ec
 
Gan La Taiwan Day5
Gan La Taiwan Day5Gan La Taiwan Day5
Gan La Taiwan Day5Ethan Kuo
 
Baby Sleeping Habits By Evebel
Baby Sleeping Habits By EvebelBaby Sleeping Habits By Evebel
Baby Sleeping Habits By Evebel
Lynn Li
 
Telecomunications
TelecomunicationsTelecomunications
NEW UNIFORM
NEW UNIFORMNEW UNIFORM
NEW UNIFORM
kecepirit
 
Fire Anniversary pdf
Fire Anniversary pdfFire Anniversary pdf
Kordamine kontrolltööks katoliku kirikust
Kordamine kontrolltööks katoliku kirikustKordamine kontrolltööks katoliku kirikust
Kordamine kontrolltööks katoliku kirikust
Dagmar Seljamäe
 
Using Facebook To Create Your Web Personality
Using Facebook To Create Your Web PersonalityUsing Facebook To Create Your Web Personality
Using Facebook To Create Your Web Personality
woelfelr
 
R2R Meeting 14 pdf
R2R Meeting 14 pdfR2R Meeting 14 pdf
cv 2 pdf henry
cv 2 pdf henrycv 2 pdf henry
cv 2 pdf henry
Henry Doank'z
 
Mikayla And Kendra Gray
Mikayla And Kendra GrayMikayla And Kendra Gray
Mikayla And Kendra Gray
Mikayla and Kendra Gray
 
Trans Media Final
Trans Media FinalTrans Media Final
Trans Media Final
kellen8
 
ПРОЕКТ «СТУДІЯ «НАШ ДОМ»
ПРОЕКТ «СТУДІЯ «НАШ ДОМ»ПРОЕКТ «СТУДІЯ «НАШ ДОМ»
ПРОЕКТ «СТУДІЯ «НАШ ДОМ»
Maidan Monitoring Information Center
 
Galbavy Koncesie
Galbavy KoncesieGalbavy Koncesie
Galbavy Koncesieguestc27e91
 

Viewers also liked (18)

Networking
NetworkingNetworking
Networking
 
Ashraya
AshrayaAshraya
Ashraya
 
Николай Коперник
Николай КоперникНиколай Коперник
Николай Коперник
 
Taller Dels Animalons
Taller Dels AnimalonsTaller Dels Animalons
Taller Dels Animalons
 
Gan La Taiwan Day5
Gan La Taiwan Day5Gan La Taiwan Day5
Gan La Taiwan Day5
 
Baby Sleeping Habits By Evebel
Baby Sleeping Habits By EvebelBaby Sleeping Habits By Evebel
Baby Sleeping Habits By Evebel
 
AIEDDs_Basic EOD
AIEDDs_Basic EODAIEDDs_Basic EOD
AIEDDs_Basic EOD
 
Telecomunications
TelecomunicationsTelecomunications
Telecomunications
 
NEW UNIFORM
NEW UNIFORMNEW UNIFORM
NEW UNIFORM
 
Fire Anniversary pdf
Fire Anniversary pdfFire Anniversary pdf
Fire Anniversary pdf
 
Kordamine kontrolltööks katoliku kirikust
Kordamine kontrolltööks katoliku kirikustKordamine kontrolltööks katoliku kirikust
Kordamine kontrolltööks katoliku kirikust
 
Using Facebook To Create Your Web Personality
Using Facebook To Create Your Web PersonalityUsing Facebook To Create Your Web Personality
Using Facebook To Create Your Web Personality
 
R2R Meeting 14 pdf
R2R Meeting 14 pdfR2R Meeting 14 pdf
R2R Meeting 14 pdf
 
cv 2 pdf henry
cv 2 pdf henrycv 2 pdf henry
cv 2 pdf henry
 
Mikayla And Kendra Gray
Mikayla And Kendra GrayMikayla And Kendra Gray
Mikayla And Kendra Gray
 
Trans Media Final
Trans Media FinalTrans Media Final
Trans Media Final
 
ПРОЕКТ «СТУДІЯ «НАШ ДОМ»
ПРОЕКТ «СТУДІЯ «НАШ ДОМ»ПРОЕКТ «СТУДІЯ «НАШ ДОМ»
ПРОЕКТ «СТУДІЯ «НАШ ДОМ»
 
Galbavy Koncesie
Galbavy KoncesieGalbavy Koncesie
Galbavy Koncesie
 

Similar to Updat Dir

Its about a sql topic for basic structured query language
Its about a sql topic for basic structured query languageIts about a sql topic for basic structured query language
Its about a sql topic for basic structured query language
IMsKanchanaI
 
Sql2
Sql2Sql2
Introduction to oracle functions
Introduction to oracle functionsIntroduction to oracle functions
Introduction to oracle functions
Nitesh Singh
 
Introduction to Oracle Functions--(SQL)--Abhishek Sharma
Introduction to Oracle Functions--(SQL)--Abhishek SharmaIntroduction to Oracle Functions--(SQL)--Abhishek Sharma
Introduction to Oracle Functions--(SQL)--Abhishek Sharma
अभिषेक शर्मा
 
Oraclesql
OraclesqlOraclesql
Oraclesql
Priya Goyal
 
5. Group Functions
5. Group Functions5. Group Functions
5. Group Functions
Evelyn Oluchukwu
 
MySQL-commands.pdf
MySQL-commands.pdfMySQL-commands.pdf
MySQL-commands.pdf
ssuserc5aa74
 
Sql
SqlSql
Sql query [select, sub] 4
Sql query [select, sub] 4Sql query [select, sub] 4
Sql query [select, sub] 4
Dr. C.V. Suresh Babu
 
Basic SQL Statments
Basic SQL StatmentsBasic SQL Statments
Basic SQL Statments
Umair Shakir
 
0808.pdf
0808.pdf0808.pdf
0808.pdf
ssuser0562f1
 
0808.pdf
0808.pdf0808.pdf
0808.pdf
ssuser0562f1
 
SQL : Structured Query Language
SQL : Structured Query LanguageSQL : Structured Query Language
SQL : Structured Query Language
Abhishek Gautam
 
Sql
SqlSql
Chinabankppt
ChinabankpptChinabankppt
Chinabankppt
newrforce
 
Sql select statement
Sql select statementSql select statement
Sql select statement
Vivek Singh
 
Interacting with Oracle Database
Interacting with Oracle DatabaseInteracting with Oracle Database
Interacting with Oracle Database
Chhom Karath
 
Les01
Les01Les01
SQL Query
SQL QuerySQL Query
SQL Query
Imam340267
 
Sql server ___________session 3(sql 2008)
Sql server  ___________session 3(sql 2008)Sql server  ___________session 3(sql 2008)
Sql server ___________session 3(sql 2008)
Ehtisham Ali
 

Similar to Updat Dir (20)

Its about a sql topic for basic structured query language
Its about a sql topic for basic structured query languageIts about a sql topic for basic structured query language
Its about a sql topic for basic structured query language
 
Sql2
Sql2Sql2
Sql2
 
Introduction to oracle functions
Introduction to oracle functionsIntroduction to oracle functions
Introduction to oracle functions
 
Introduction to Oracle Functions--(SQL)--Abhishek Sharma
Introduction to Oracle Functions--(SQL)--Abhishek SharmaIntroduction to Oracle Functions--(SQL)--Abhishek Sharma
Introduction to Oracle Functions--(SQL)--Abhishek Sharma
 
Oraclesql
OraclesqlOraclesql
Oraclesql
 
5. Group Functions
5. Group Functions5. Group Functions
5. Group Functions
 
MySQL-commands.pdf
MySQL-commands.pdfMySQL-commands.pdf
MySQL-commands.pdf
 
Sql
SqlSql
Sql
 
Sql query [select, sub] 4
Sql query [select, sub] 4Sql query [select, sub] 4
Sql query [select, sub] 4
 
Basic SQL Statments
Basic SQL StatmentsBasic SQL Statments
Basic SQL Statments
 
0808.pdf
0808.pdf0808.pdf
0808.pdf
 
0808.pdf
0808.pdf0808.pdf
0808.pdf
 
SQL : Structured Query Language
SQL : Structured Query LanguageSQL : Structured Query Language
SQL : Structured Query Language
 
Sql
SqlSql
Sql
 
Chinabankppt
ChinabankpptChinabankppt
Chinabankppt
 
Sql select statement
Sql select statementSql select statement
Sql select statement
 
Interacting with Oracle Database
Interacting with Oracle DatabaseInteracting with Oracle Database
Interacting with Oracle Database
 
Les01
Les01Les01
Les01
 
SQL Query
SQL QuerySQL Query
SQL Query
 
Sql server ___________session 3(sql 2008)
Sql server  ___________session 3(sql 2008)Sql server  ___________session 3(sql 2008)
Sql server ___________session 3(sql 2008)
 

Recently uploaded

Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
Zilliz
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 

Recently uploaded (20)

Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 

Updat Dir

  • 1. UPDATE - UPDATING A TABLE • Changes values in a table Syntax: UPDATE <table name>/<view name> SET <column name> = <new value> [,<column name> = <new value>...] [<WHERE clause>]; • The WHERE clause specifies the rows to be UPDATEd • Omitting this clause UPDATEs all rows in the table. MGCL12SQL4
  • 2. Ex: UPDATE EMP SET salary = salary +1000 WHERE Job = ‘Analyst’ ; UPDATE EMP SET salary = salary +1000, comm = 5000 WHERE Job = ‘SALESMAN’ ; MGCL12SQL4
  • 3. DELETE - DELETING ROWS FROM A TABLE •Removes one or more rows from a table. DELETE FROM <table name> [<alias name>] [<WHERE clause>]; • The WHERE clause specifies rows to be deleted. • If the WHERE clause is not included, all rows will be deleted. MGCL12SQL4
  • 4. DELETE FROM Employee WHERE name = 'Mihir'; DELETE * FROM Employee; DELETE FROM Employee WHERE name NOT IN (‘Tony’, ‘Tom’); DELETE FROM Employee WHERE salary < 10000; MGCL12SQL4
  • 5. ALTER TABLE - ADDING ATTRIBUTES TO A TABLE •Adds new columns to a table. ALTER TABLE <table name> ADD (<column name> <data type> [,<column name> <data type>...]); Ex: ALTER TABLE staff ADD (phone CHAR(13)); MGCL12SQL4
  • 6. ALTER TABLE staff drop column phone; ALTER TABLE staff modify name varchar2(40); MGCL12SQL4
  • 7. DROP TABLE – REMOVING A TABLE Removes specified table from the active database. DROP TABLE <table name>; When you DROP a table, all indexes, synonyms, and views associated with it are DROPped. Ex: DROP TABLE emp; MGCL12SQL4
  • 8. CREATE VIEW – CREATING A VIEW Defines a view that combines data from one or more tables/views. A column list must be specified if any of the columns in the SELECT are calculated columns or expressions, otherwise view columns inherit default names from the base table(s)/view(s). CREATE VIEW <view name> [(<column name>, <column name>..)] AS <SELECT command> [WITH CHECK OPTION]; MGCL12SQL4
  • 9. Ex: CREATE VIEW emp AS SELECT * FROM Employee WHERE dept = 'SOFTWARE'; MGCL12SQL4
  • 10. DROP VIEW – REMOVING A VIEW Removes specified view from the active database. DROP VIEW <view name>; When a view is DROPped, all other views and synonyms based on it are dropped automatically. When a table is dropped, all views based on it are also dropped. Ex: DROP VIEW empview; MGCL12SQL4
  • 11. Aggregate functions Aggregate functions work with a group of values and reduce them to a single value. COUNT • counts rows/records • * can be used instead of ALL COUNT ({*/[DISTINCT] <column name>}) • Used in SELECT or HAVING clause to count the number of rows returned by an SQL command • DISTINCT omits any repeated values MGCL12SQL4
  • 12. •If used in the SELECT clause, all other columns SELECTed must also be SQL aggregate functions or columns specified in a GROUP BY clause Examples SELECT COUNT (*) FROM staff WHERE salary > 15500; SELECT COUNT (DISTINCT name) FROM Employee; SELECT COUNT (*) FROM Employee; SELECT COUNT(ALL desig) from Employee where salary >15500; MGCL12SQL4
  • 13. MAX and MIN • Used in SELECT or HAVING clauses • MAX() function returns the highest value in the specified column or column expression • MIN() returns the lowest value • If used in the SELECT clause, all other columns selected must also be SQL aggregate functions or columns specified in a GROUP BY clause. {MAX/MIN} ([ALL/DISTINCT] <column name>) SELECT MAX (salary), MIN (salary) FROM Emp; MGCL12SQL4
  • 14. SUM • Used in the SELECT or HAVING clauses to find the sum of values for the specified column. • ALL is the default. • DISTINCT omits any repeated values. • If used in the SELECT clause, all other columns SELECTed must also be SQL aggregate functions or columns specified in a GROUP BY clause. SUM ([ALL/DISTINCT] <column name>) SELECT SUM(salary) from Emp; MGCL12SQL4
  • 15. AVG Used in the SELECT or HAVING clause to find the average value for the specified column or column expression. ALL is the default. DISTINCT omits any repeated values. If used in the SELECT clause, all other columns SELECTed must also be SQL aggregate functions or columns specified in a GROUP BY clause. AVG ([ALL/DISTINCT] <column name>) SELECT AVG (Height) FROM Student; MGCL12SQL4
  • 16. AGGREGATE CLAUSES : GROUP BY AND HAVING GROUP BY clause • Is used to divide the rows in a table into smaller groups • Grouping can be done by a column name, or with aggregate function MGCL12SQL4
  • 17. GROUP BY <column name>[,<column name>...] • Group functions (AVG, MAX, MIN, SUM, COUNT) can be used with group by clause to return summary information for each group • Any non-aggregate function columns in a SELECT clause that includes aggregate functions must be specified in a GROUP BY clause • You cannot GROUP BY columns of type LOGICAL MGCL12SQL4
  • 18. • Groups rows together that have duplicate values for the specified column • SQL aggregate functions (AVG, MAX, MIN, SUM, or COUNT) in a SELECT clause operate on each group • Any non-aggregate function columns in a SELECT clause that includes aggregate functions must be specified in a GROUP BY clause • You cannot GROUP BY columns of type LOGICAL • WHERE clause can be used to exclude rows before forming groups MGCL12SQL4
  • 19. SELECT Class, COUNT(Sname) FROM Student GROUP BY Class; SELECT Dept, COUNT(ename) FROM Emp GROUP BY dept; SELECT Class, AVG(Height) FROM Student GROUP BY Class; SELECT Dept, MAX(salary) FROM Emp WHERE DOJ > ’01-Jan-2005’ GROUP BY dept; SELECT Class, Sec, COUNT(*) FROM Student GROUP BY Class, Sec; (Group all students by class, then within each class group by sec) MGCL12SQL4
  • 20. HAVING clause • Used to restrict groups returned from GROUP BY clause • places condition on groups • can include aggregate functions HAVING [NOT]<search condition> • In a query using GROUP BY and HAVING clause, the rows are first grouped, group functions are applied and then only those groups matching HAVING clause are displayed MGCL12SQL4
  • 21. SELECT dept, MAX(salary) FROM Emp GROUP BY dept HAVING COUNT(*) > 10; SELECT job_code,avg(salary), sum(salary) from Emp GROUP BY job_code HAVING job_code=3; MGCL12SQL4