Thursday, July 7, 2016

DBMS Lesson 5 SQL Part 2

Today our Lesson is about DML.අද අපි කතාකරන්නේ DML ගැන.If you haven't gone through previous Lessons click below links.

Lesson 1,Lesson 2,Lesson 3,Lesson 4 part 1,Lesson 4 part 2,Lesson 5 part 1

What is DML?? DML කියන්නේ මොකක්ද??
Data Manipulation Language(DML) that provides set of operations to support basic data manipulation from a database.
DB එකක මූලික දත්ත මෙහෙයවීම් කිරීම සදහා ලබා දී ඇති  ක්‍රියාවලීන්

Operations like/ක්‍රියාවලීන්

  • Retrieval of data/දත්ත ගැනීම්
  • Insertion of data/දත්ත ඇතුලත් කිරීම්
  • Modification of data/දත්ත වෙනස් කිරීම්
  • Deletion of data in a database/දත්ත ඉවත් කිරීම්
Lets talk about how retrieve data from a created database.දත්ත ගැනීම් ගැන අප දැන් කතා කරමු.
There are several clauses used to do that.
DB එකක දත්ත ගැනීම සදහා clauses භාවිතා වේ.
  • Select < attribute > From < relation > [ Where < condition > ]
Above written statement is called a QUERY and words like select,from,where etc are the CLAUSES.

ඉහත ලියා ඇති වගන්තිය Query වන අතර select,from,where  යන ඒවා Clauses වේ.

Let's learn those clauses through examples....


Example 1:
Q:Display Supplier details

Example 2:
Q:Display Cities of Suppliers

Example 3:
Q:Display details of suppliers whose status more than 20

Example 4:
Q:Display number and names of suppliers who live in Jaffna

Example 5:
Q:Display details of Suppliers who live in Colombo or whose status equal to 20

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


A1:Select SNo,Name,Status,City From Supplier    

A2:Select City from Supplier
      or
     Select * From Supplier

Clause like Distinct can be used to remove duplication

A2:Select Distinct City from Supplier
A3:Select * from Supplier Where Status > 20

A4:Select SNo,Name from Supplier Where City='Jaffna'


A5:Select * from Supplier Where City='Colombo' or Status=20

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Answer 1---> 1
Answer 2--->
Answer 2 with distinct->

Answer 3--->

Answer 4--->

Answer 5--->


Click here to download Additional Exercises
Note:Answers are given try them and go through the answers provided..


Click Here to download this lesson in PDF Format



Next post will be the continuation of this.Keep in Touch...

No comments:

Post a Comment