0% found this document useful (0 votes)
24 views5 pages

S3L1: Q.1 Ans

The document contains questions and answers related to SQL and PL/SQL. It discusses deleting and inserting rows into tables, updating values in tables, and using PL/SQL blocks. Key points include: - Questions ask about valid and invalid SQL and PL/SQL statements. - Answers demonstrate deleting rows from a table, inserting multiple rows into a new grocery items table, and updating values in the new table. - A PL/SQL block is provided to select maximum department ID from a departments table and output it. - Another block selects elevation values from a countries table and outputs them. - Questions ask about exceptions that could occur from SQL statements.

Uploaded by

Nav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views5 pages

S3L1: Q.1 Ans

The document contains questions and answers related to SQL and PL/SQL. It discusses deleting and inserting rows into tables, updating values in tables, and using PL/SQL blocks. Key points include: - Questions ask about valid and invalid SQL and PL/SQL statements. - Answers demonstrate deleting rows from a table, inserting multiple rows into a new grocery items table, and updating values in the new table. - A PL/SQL block is provided to select maximum department ID from a departments table and output it. - Another block selects elevation values from a countries table and outputs them. - Questions ask about exceptions that could occur from SQL statements.

Uploaded by

Nav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

S3L1:

Q.1
Ans : Delete all rows from STUDENTS
Q.2
Ans: A. Does an explicit insert
Q.3
Ans: create table grocery_items (product_id number(10) primary key,
Brand varchar (40),
Description varchar (40));
Q.4
Ans: 1. insert into grocery_item (product_id,brand,description) values
(110,Colgate,Toothpaste);
2. insert into grocery_item (product_id,brand,description) values (111, Ivory, Soap);

3. insert into grocery_item (product_id,brand,description) values (112, Heinz,


Ketchup);

Q.5
Ans: insert into grocery_item (product_id,brand,description) values (113, cola, coca);

Q.6
Ans: update grocery_item set description =tomato catsup where product_id = 112;

Q.8
Ans : update grocery_item set brand = Dove where product_id = 111;

S3L2

Q1.
Ans :
Statement
Valid in
Not Valid

PL/SQL
in PL/SQL
ALTER USER SET password='oracle';

no

CREATE TABLE test (a NUMBER);

no

DROP TABLE test;

no

SELECT emp_id INTO v_id FROM employees;

no
GRANT SELECT ON employees TO PUBLIC;

no

INSERT INTO grocery_items (product_id, brand, de-

no
scription)

VALUES (199,'Coke','Soda');

REVOKE UPDATE ON employees FROM PUBLIC;

no
ALTER TABLE employees

RENAME COLUMN employee_id TO emp_id;

no
DELETE FROM grocery_items

WHERE description='Soap';
no

Q2. DECLARE
v_max_deptno number;
department_id v_max_deptno %TYPE;
BEGIN
Select max(department_id ) into v_max_deptno from departments;
dbms_output.put_LINE(Maximunm department id is ' || v_max_deptno );
END;

Q.3
Ans: DECLARE
v_country_name wf_countries.country_name%TYPE
:= 'United States of America';
v_lowest_elevation wf_countries.lowest_elevation%TYPE;
v_highest_elevation wf_countries.highest_elevation%TYPE;
BEGIN

SELECT lowest_elevation, highest_elevation into


v_lowest_elevation,v_highest_elevation
FROM wf_countries where COUNTRY_NAME = v_country_name;
DBMS_OUTPUT.PUT_LINE('The lowest elevation in
'||v_country_name||' is '||v_lowest_elevation
||' and the highest elevation is '||
v_highest_elevation||'.');
END;
Q.4

Ans: A - exact fetch returns more than requested number of rows


B : No data found
Q.5
Ans : will not work because table doesnt exist.
A. CREATE TABLE emp_dup AS select
EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_D
ATE,JOB_IDSALARY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID
FROM employees;

B.
C.
D.
E.

Select first_name,last_name from emp_dup.


Code run
Select first_name,last_name from emp_dup.
DECLARE last_name VARCHAR2(25) := 'Chen'; BEGIN UPDATE emp_dup SET
first_name = 'Jennifer' WHERE last_name = last_name; END;
F. Update emp_sup Set first_name=Jennifer where first_name=fay;
G. It works.

You might also like