0% found this document useful (0 votes)
19 views

Dbms Lab 2

The document discusses SQL operations like update, delete, renaming columns, logical operators, pattern matching, functions and sorting. It provides examples of updating a table, deleting rows, renaming columns, using logical, between and like operators. It also discusses various SQL functions like avg, min, max, count, sum and sorting data. The objective is to manipulate operations on tables using SQL's data manipulation language.

Uploaded by

Abhinav Kaushik
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Dbms Lab 2

The document discusses SQL operations like update, delete, renaming columns, logical operators, pattern matching, functions and sorting. It provides examples of updating a table, deleting rows, renaming columns, using logical, between and like operators. It also discusses various SQL functions like avg, min, max, count, sum and sorting data. The objective is to manipulate operations on tables using SQL's data manipulation language.

Uploaded by

Abhinav Kaushik
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

Theory and Concept

Assignment-2
Objective:- To Manupulate the Operations on the table.
DML ( Data Manipulation Language) Data manipulation is

 The retrieval of information stored in the database.


 The insertion of new information into the database.
 The deletion of information from the database.
 The modification of information stored by the appropriate data model. There are basically
two types.
(i) Procedural DML:- require a user to specify what data are needed and how to get
those data.
(ii) Non Procedural DML : require a user to specify what data are needed without
specifying how to get those data.

Updating the content of a table:


In creation situation we may wish to change a value in table without changing all values in the
tuple . For this purpose the update statement can be used.

Update table name


Set columnname = experision, columnname =expression……
Where columnname = expression;

Deletion Operation:-
A delete reQuestionst is expressed in much the same way as Questionry. We can delete whole
tuple ( rows) we can delete values on only particulars attributes.

Deletion of all rows

Syntax:
Delete from tablename :

Deletion of specified number of rows


Syntax:

Delete from table name


Where search condition ;

Computation in expression lists used to select data

+ Addition - Subtraction
* multiplication ** exponentiation
/ Division () Enclosed operation

- - 1
Renaming columns used with Expression Lists: - The default output column names can be
renamed by the user if required

Syntax:

Select column name result_columnname,


Columnname result_columnname,
From table name;

Logical Operators:
The logical operators that can be used in SQL sentenced are

AND all of must be included


OR any of may be included
NOT none of could be included

Range Searching: Between operation is used for range searching.

Pattern Searching:
The most commonly used operation on string is pattern matching using the operation ‘like’ we
describe patterns by using two special characters.

 Percent (%) ; the % character matches any substring we consider the following examples.
 ‘Perry %’ matches any string beginning with perry
 ‘% idge % matches any string containing’ idge as substring.
 ‘ - - - ‘ matches any string exactly three characters.
 ‘ - - - % matches any string of at least of three characters.

Oracle functions:
Functions are used to manipulate data items and return result. function follow the format of
function _name (argument1, argument2 ..) .An arrangement is user defined variable or constant.
The structure of function is such that it accepts zero or more arguments.
Examples:
Avg return average value of n

Syntax:
Avg ([distinct/all]n)
Min return minimum value of expr.

Syntax:
MIN((distict/all )expr)
Count Returns the no of rows where expr is not null

- - 2
Syntax:
Count ([distinct/all)expr]
Count (*) Returns the no rows in the table, including duplicates and those with nulls.
Max Return max value of expr

Syntax:

Max ([distinct/all]expr)
Sum Returns sum of values of n

Syntax:
Sum ([distinct/all]n)

Sorting of data in table

Syntax:
Select columnname, columnname
From table
Order by columnname;

- - 3
Assignment No. # 2

Question.1 Using the table client master and product master answer the following
Questionries.

i. Change the selling price of ‘1.44 floppy drive to Rs.1150.00


ii. Delete the record with client 0001 from the client master table.
iii. Change the city of client_no’0005’ to Bombay.
iv. Change the bal_due of client_no ‘0001, to 1000.
v. Find the products whose selling price is more than 1500 and also find the new selling
price as original selling price *15.
vi. Find out the clients who stay in a city whose second letter is a.
vii. Find out the name of all clients having ‘a’ as the second letter in their names.
viii. List the products in sorted order of their description.
ix. Count the total number of orders
x. Calculate the average price of all the products.
xi. Calculate the minimum price of products.
xii. Determine the maximum and minimum prices . Rename the tittle as ‘max_price’ and
min_price respectively.
xiii. Count the number of products having price greater than or equal to 1500.

- - 4

You might also like