Sie sind auf Seite 1von 5

SQL and PLSQL

SL Question Answer

You need to extract details of those products in the SALES A. WHERE prod_id LIKE '%_D123%' ESCAPE '_'
table where the PROD_ID column contains the B. WHERE prod_id LIKE '%\_D123%' ESCAPE '\'
string '_D123'. C. WHERE prod_id LIKE '%_D123%' ESCAPE '%_'
1
D. WHERE prod_id LIKE '%\_D123%' ESCAPE '\_'
Which WHERE clause could be used in the SELECT
statement to get the required output? Answer: B

A. They accept only a single argument.


B. They can be nested only to two levels.
C. Arguments can only be column values or constants.
Which two statements are true regarding single row D. They always return a single result row for every row of a
2 functions? (Choose two.) queried table.
E. They can return a data type value different from the one that
is referenced.

Answer: D,E

A. SELECT TO_CHAR(1890.55,'$0G000D00')
FROM DUAL;
B. SELECT TO_CHAR(1890.55,'$9,999V99')
FROM DUAL;
C. SELECT TO_CHAR(1890.55,'$99,999D99')
Which SQL statements would display the value 1890.55 as FROM DUAL;
3
$1,890.55? (Choose three.) D. SELECT TO_CHAR(1890.55,'$99G999D00')
FROM DUAL;
E. SELECT TO_CHAR(1890.55,'$99G999D99')
FROM DUAL;

Answer: A,D,E

A. It ignores NULL values.


B. Reversing the order of the intersected tables alters the
result.
C. The names of columns in all SELECT statements must be
4 Which statement is true regarding the INTERSECT operator? identical.
D. The number of columns and data types must be identical
for all SELECT statements in the query.

Answer: D
A. SELECT cust_last_name Name, cust_credit_limit +
1000
A. "New Credit Limit"
B. FROM customers;
You need to produce a report where each customer's credit
C. SELECT cust_last_name AS Name, cust_credit_limit +
limit has been incremented by $1000.
1000
D. AS New Credit Limit
In the output, the customer's last name should have the
E. FROM customers;
heading Name and the incremented credit limit should
B. SELECT cust_last_name AS "Name", cust_credit_limit
5 be labeled New Credit Limit.
+ 1000
F. AS "New Credit Limit"
The column headings should have only the first letter of each
G. FROM customers;
word in uppercase .
C. SELECT INITCAP(cust_last_name) "Name",
cust_credit_limit + 1000 INITCAP("NEW CREDIT
Which statement would accomplish this requirement?
LIMIT")
H. FROM customers;

Answer: C

A. Invalid objects cannot be described.


B. An object with status of invalid cannot be a referenced
object.
C. The Oracle server automatically records dependencies
Which three are true statements about dependent objects? among objects.
(Choose three) D. All schema objects have a status that is recorded in
6 the data dictionary.
E. You can view whether an object is valid or invalid in
the USER_STATUS data dictionary view.
F. You can view whether an object is valid or invalid in
the USER_OBJECTS data dictionary view.

Answer: A,C,F

A. Packages can be nested.


B. You can pass parameters to packages.
C. A package is loaded into memory each time it is
invoked.
Which two statements about packages are true? (Choose
D. The contents of packages can be shared by many
7 two)
applications.
E. You can achieve information hiding by making
package constructs private.

Answer: D,E

A. FOR EACH ROW trigger on the EMP table


B. Statement-level trigger on the EMP table.
C. FOR EACH ROW trigger on the AUDIT_TABLE table.
You need to create a trigger on the EMP table that
D. Statement-level trigger on the AUDIT_TABLE table.
monitors every row that is changed and places
8 E. FOR EACH ROW statement-level trigger on the EMP
this information into the AUDIT_TABLE.
table.
What type of trigger do you create?
Answer: A
A. Trigger type
B. Trigger body
C. Trigger event
What part of a database trigger determines the number of D. Trigger timing
9
times the trigger body executes?

Answer: A

CREATE OR REPLACE TRIGGER secure_emp BEFORE


LOGON ON employees

BEGIN

IF (TO_CHAR(SYSDATE, 'DY') IN ('SAT', 'SUN')) OR A. DML trigger


(TO_CHAR(SYSDATE, 'HH24:MI') B. INSTEAD OF trigger
NOT BETWEEN '08:00' AND '18:00') THEN C. Application trigger
10 D. System event trigger
RAISE_APPLICATION_ERROR (-20500, 'You may
insert into the EMPLOYEES table only during business E. This is an invalid trigger.
hours.');
END IF; Answer: E

END;
/
What type of trigger is it?

CREATE OR REPLACE TRIGGER update_emp AFTER


UPDATE ON emp
BEGIN A. 1
INSERT INTO audit_table (who, dated) VALUES (USER, B. 10
SYSDATE); C. None
11 END;
D. A value equal to the number of rows in the EMP table.
You issue an UPDATE command in the EMP table that
Answer: A
results in changing 10 rows.

How many rows are inserted into the AUDIT_TABLE?

A. SHOW FUNCTION_ERROR
When creating a function in SQL *Plus, you receive this
message: "Warning: Function created with compilation
B. SHOW USER_ERRORS
12 errors." C. SHOW ERRORS
Which command can you issue to see the actual error D. SHOW ALL_ERRORS
message?
Answer: C

Examine this procedure:

CREATE OR REPLACE PROCEDURE ADD_PLAYER (V_ID


IN NUMBER, V_LAST_NAME VARCHAR2) IS
A. EXECUTE UPD_BAT_STAT(V_ID);
BEGIN
B. UPD_BAT_STAT(V_ID);
INSERT INTO PLAYER (ID,LAST_NAME) VALUES (V_ID,
C. RUN UPD_BAT_STAT(V_ID);
13 V_LAST_NAME); COMMIT;
D. START UPD_BAT_STAT(V_ID);
END;

This procedure must invoke the APD_BAT_STAT procedure


Answer: B
and pass a parameter.

Which statement, when added to the above procedure will


successfully invoke the UPD_BAT_STAT procedure?
A. Both USING and ON clauses can be used for equijoins
and nonequijoins.
B. A maximum of one pair of columns can be joined
between two tables using the ON clause.
Which two statements are true regarding the USING C. The ON clause can be used to join tables on columns
14 and ON clauses in table joins? (Choose two.) that have different names but compatible data types.
D. The WHERE clause can be used to apply additional
conditions in SELECT statements containing the ON
or the USING clause.

Answer: C,D

A. SELECT cust_income_level, DISTINCT


cust_credit_limit * 0.50 AS "50% Credit Limit"
FROM customers;
Using the CUSTOMERS table, you need to generate a B. SELECT DISTINCT cust_income_level, DISTINCT
report that shows 50% of each credit amount in each cust_credit_limit * 0.50 AS "50% Credit Limit"
income level. The report should NOT show any FROM customers;
15 repeated credit amounts in each income level. C. SELECT DISTINCT cust_income_level ' '
cust_credit_limit * 0.50 AS "50% Credit Limit"
Which query would give the required result? FROM customers;
D. SELECT cust_income_level ' ' cust_credit_limit * 0.50
AS "50% Credit Limit" FROM customers;

Answer: C

a)=45.6
16 a) ROUND(45.56, 1)=? B) TRUNC(45.56, 1)=?
b)=45.5

17 Write a syntax using NVL Select NVL( string1, replace_with ) from table
The below query gives an error. why?
18 For missing group by clause
SELECT department_id, AVG(salary) FROM employees

Select name, Salary,


write a query to show salary range like below: case
name Salary Salary Range when salary > 60000 then ‘High’
Raju 50000 Medium when salary > 30000 and salary <= 60000 then ‘Medium’
19
Sumon 60000 Medium when salary <=30000 then ‘Low’
Arif 100000 High else null
Rahim 30000 Low end “Salary Range”
from table;

CREATE OR REPLACE FUNCTION text_length(a CLOB)


RETURN NUMBER
IS
20 Create a function to count the length of a sentence.
BEGIN
RETURN DBMS_LOB.GETLENGTH(a);
END;

Das könnte Ihnen auch gefallen