DBMS UNIT 3.2
DBMS UNIT 3.2
Like operator :
1.The LIKE operator is used to compare a value to similar
values using wildcard operators.
2.It uses two wild characters as ‘%’ and ‘_’ where ‘%’
represents all characters of the pattern and ‘_’ represents
one single character from the pattern.
3.Eg : Select ename from emp where ename like ‘S%’;
4.This will return all employee names starting with ‘S’.
5.Select ename from emp where ename like ‘_a%;
6.This will return all employee names whose second character is
‘a’
1.SQL Date and Time operations are used for operations on date
and time provided by users.
2.SQL supports various date and time data types and formats.
The specific date format depends on the database system being
used.
String functions:
1.The string is a collection of characters used to store
multiple characters.
2.Most of the time we need to modify and access the strings.
SQL has built-in string functions.
3.The SQL built-in string functions take an input string and
return an output string.
4.String functions are used to perform various character
manipulation
Aggregate functions:
1.An aggregate function is a function where the values of
multiple rows are grouped together as input on certain
criteria to form a single value of more significant meaning.
View:
1.A view is a virtual table based on the result set of the SQL
statement.
2.The fields in a view are fields from one or more than one
table in the database.
3.SQL functions, where join statements can be added to a view
and the data in it can be presented as if it were from one
table.
4.The database engine recreates the data, using the view’s SQL
statement, every time a user queries a view.
5.A view can be updated using the create or replace view
command. For deleting a view, a drop query can be used.
6.View has two types:
1. Simple view: The fields in a view are fields from one
table in the database.
2. Complex view: The fields in a view are fields from
more than one table in the database.
7.Advantages of views:
a.Complexity: Views help to reduce complexity.
b.Security: It increases security by excluding the
sensitive information from the view.
c.Query Simplicity: It helps to simplify commands from the
user.
d.Consistency: A view can present a consistent, unchanged
image of the structure of the database.
8.CREATE VIEW Syntax:
CREATE VIEW view_name AS SELECT column1, column2… from
table_name WHERE condition ;
- Example: CREATE VIEW vw_student AS SELECT stud_id,
stud_name,ssc_per from student;
1.Declaration section:
A block begins with a declarative section where variables,
cursors are declared. It is an Optional block.
2.Execution section:
Executable SQL or PL/SQL Statements are needed to write here
for the execution. It is a mandatory block.
3.Exception section:
It is used to handle exceptions. It is an Optional block.
4.End statement:
It is used to indicate termination of a PL/SQL block. It
is mandatory.
Advantages of PL/SQL:
User-defined exceptions:
1.The user defined exceptions are the exception defined by
the user, after the Declare part of the PL/SQL
structure.
2.The word ‘EXCEPTION’ is used to declare these exceptions
3.They must be raised explicitly by using the RAISE
statement
5.Example:
Example :
declare
age number := 15;
age_too_low exception;
begin
if age < 18 then
raise age_too_low; -- Explicitly raise the
user-defined exception
end if;
dbms_output.put_line('Age is valid: ' || age);
exception
when age_too_low then
dbms_output.put_line('Error: Age is below 18 and not
allowed.');
End;
Cursor:
1. Atomicity
2. Consistency
3. Isolation
4. Durability