Professional Documents
Culture Documents
(3)Alter:- ALTER is used to modify existing database data structures (database, table).
Example:-
ALTER TABLE user ADD COLUMN lastname VARCHAR(255) NOT NULL;
(2)Insert:- INSERT command is used to add new rows into the database table.
Example:-
INSERT INTO student (name, lastname) VALUES ('Dmytro',
'Shvechikov');
Aggregate functions:- Aggregate functions in DBMS take multiple rows from the table
and return a value according to the query.
(1)AVG Function
This function returns the average value of the numeric column that is
supplied as a parameter.
(2)COUNT Function
The count function returns the number of rows in the result. It does not
count the null values.
Example: Write a query to return number of rows where salary > 20000.
Select COUNT(*) from Employee where Salary > 20000;
(3)MAX Function
The MAX function is used to find maximum value in the column that is
supplied as a parameter. It can be used on any type of data.
(5)STDDEV Function
Example −
Select VARIANCE(salary) from Employee
Q-5.What is a view? What are its types? Write the syntax for creating a view
A database view is a subset of a database and is based on a query that runs on
one or more database tables. Database views are saved in the database as
named queries and can be used to save frequently used, complex queries.
There are two types of database views:
Dynamic views :- Dynamic views can contain data from one or two tables and
automatically include all of the columns from the specified table or tables.
Dynamic views are automatically updated when related objects or extended
objects are created or changed.
Static views :- Static views can contain data from multiple tables and the
required columns from these tables must be specified in the SELECT and
WHERE clauses of the static view. Static views must be manually updated
when related objects or extended objects are created or changed.
Syntax:-
CREATE VIEW view_name AS
SELECT column1, column2, ...
FROM table_name
WHERE condition;
Q-6. Define PL/SQL. Write PL/SQL block to print sum of even numbers
Define:- PL/SQL is a block of codes that used to write the entire program blocks/ procedure/
function, etc.
Write PL/SQL block to print sum of even numbers
declare
NUM number:=0;
Sum number:=0;
begin
loop
NUM1 := NUM+2;
Sum:=Sum+Num1;
exit when NUM1=100;
end loop;
dbms_output.put_line (sum);
end;