0 ratings0% found this document useful (0 votes) 164 views29 pagesPython and SQL
This contains some questions of ikm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
— ‘ a
Which of the following statements correctly describe capabilities of referential integrity in databases?
A) Itensures that a row is a unique instance of an entity.
8) Itensures that altable can refer another table through a constraint pointer.
©) Itensures joins between two tables through a common column.
0)
3)
— aoe wee 3-— ae oo :
Which of the following are NOT data definition commands in ANSI SQL?
A) CREATE ASSERTION.
8) GRANTROLE
C)_ ALTER DOMAIN
b) INSERTING
E) DROP TRANSLATION—————
Which of the following overriding clauses that can be used in ANSI SQL INSERT statement?
A) OVERRIDING SESSION VALUE
B) OVERRIDING INSERT VALUE
C) OVERRIDING MEMORY VALUE
E) OVERRIDING SELECT VALUEExamine the structure of the two tables EMPLOYEES and DEPARTMENTS below (DEPT_HEAD in
DEPARTMENTS references EMPLOYEE_ID in EMPLOYEES)
EMPLOYEES:
EMPLOYEE_ID - NUMBER(4)
FIRST_NAME - VARCHAR2(10)
JOB - VARCHAR2(9)
MGR_YN - VARCHAR2(2)
HIRE_DATE - DATE
SALARY - NUMBER
COMM_PCT - NUMBER(7,2)
DEPARTMENT_ID - NUMBER(2)
DEPARTMENTS:
DEPARTMENT_ID - NUMBER(?)
DEPT_NAME - VARCHAR2(48)
DEPT_HEAD - NUMBER(4)
LOC CODE - VARCHAR2(S)DEPARTMENTS:
DEPARTMENT_ID - NUMBER(?)
DEPT_NAME - VARCHAR2(48)
DEPT_HEAD - NUMBER(4)
LOC_CODE - VARCHAR2(5)
What does the following statement interpret?
SELECT FIRST_NAME || LAST_NAME FROM EMPLOYEES
WHERE NOT (EMPLOYEE_ID = ANY(SELECT DEPT_HEAD FROM DEPARTMENTS)
A) Lists the employees who head at least one department in the organization.
B) Lists the employees who head all the departments in the organization.
©) Lists te employees who do not head more than one department in the organization.
D) Lists the employees who do not head their own department.
), Lists the employees who do not head a department in the organization.~ a 7
According to theory, which of the following can be considered best practices when deciding to create an
index in ANSI SQL?
A) Build indexes on columns of character string types.
C) Build an index for each column of the table.
E) Build indexes on columns of integer type.Examine the CONTRACTORS table structure.
CONT_ID NUMBER
TASK_ID NUMBER
STATUS VARCHAR2(10)
TASK_START_DATE DATE
TASK_END_DATE DATE
USERID VARCHAR2(10)
The unit supervisor would like to update the contractor status from NULL or ASSIGNtriED to COMPLETED
using the following ANSI SQL statement. I
UPDATE CONTRACTORS SET Status = 'COMPLETED' *****""**
What does ********** need to be replaced with?
‘A)_ WHERE STATUS IS NULL OR STATUS = "ASSIGNED!
B) WHERE STATUS = NULL AND STATUS = ‘ASSIGNED’
C) WHERE STATUS = NULL OR STATUS = 'ASSIGNED"
D) WHERE STATUS IN(NULL, 'ASSIGNED')
E) WHERE STATUS IS ‘ASSIGNED’ OR NULLThe PRODUCTS and SALES tables are connected through PROD_ID column, while the SALES and
CUSTOMERS tables are connected through the CUST_ID column.
Find the outcome of the following query.
SELECT p.prod_id, prod_name, prod_list price, quantity sold, cust Jast_name FROM products P
NATURAL JOIN sales s NATURAL JOIN customers c WHERE prod. id = 148
A) It generates an error because all three tables must have a common column.
B) It generates an error because all columns used should have a qualifier.
9
D) It generates an error because natural join can only be used with two tables.
E) It executes successfully._ a anne 10 - ——
Which of the following values are returned by an ANSI SQL subquery expression if a subquery returns
zero rows?
B) Raise a VALUE_ERROR exception
C) Raise aNO_DATA_FOUND exception
D) oO
£) FALSEWhich of the following are valid statements regarding the DEFAULT clause in an ANS! SQLINSERT
statement?
‘A)_ Default values for columns can be randomly generated at the time of insert.
B) The default clause cannot be specified for all the colurnns in the INSERT statement.
— een a eo WD - _—_—__.
‘The ORDERS table reference the PRODUCTS table through the product id column. Which of the following
are the valid outcomes for the referential integrity?
es
B) If a product is removed from the database, all matching entries will be deleted immediately.
C) Ifa product is removed from the database, all matching entries will be set to NULL.
D) If a product is removed from the database, the deletion of matching order entries will be
deferred until next transaction.
E) Ifthe product id is updated, all the order entries matching the old product id will be deleted.The structure of Table T is (ID1 NUMBER NOT NULL, ID2 NUMBER)
Which of the following is substituted for *#****
which have duplicate values for 1D2
in the DELETE statement below to delete the rows
DELETE FROM T t1 WHERE ROWID > ***#*#*
AA) (SELECT MIN(ROWID) FROM T't2 WHERE t2.102 = 12.102)
B) (SELECT COUNT|ROWID) FROM T t2 WHERE t2.ID1 = ¢1.1D1)
C) (SELECT MAX(ROWID) FROM T t2 WHERE t2.ID1 = t1.1D2)
D) (SELECT MIN(ROWID) FROM 7)
E) (SELECT MAX(ROWID) FROM T WHERE COUNT(ID2) >1)Which of the following statements correctly describe the inter-compatibility Feature of SQL data types?
‘A)_An INTEGER static value can be inserted into a NUMERIC(10, 0) column.
C) ADOUBLE static value can be inserted into a TIME column.
D) A VARCHAR(3) static value can be inserted into a datetime column.A table EMPLOYEES contain five employee rows representing three departments. A new employee joins
the organization who is not yet assigned to any department so it is set to null.
All the employee's name, joining date and department name to be fisted. The following query is not
displaying the newly joined employee. What change need to made so that all employees are listed.
SELECT EMP_NAME, HIRE_DATE, DEPT_NAME FROM Employees NATURAL JOIN Departments;
A) Append a predicate (WHERE DEPT_|D IS NULL) using OR.
B)
C)_Use UNION to display the employee data for employees not yet assigned to any department.
D) Use CROSS JOIN to produce Cartesian product of both tables. I
E) Use FULL OUTER JOIN to display unmatched rows from both tables,
- 16-
Examine the ANSI SQL referential integrity definition in the ORDERS table below,
ALTER TABLE orders
ADD FOREIGN KEY(product_id) REFERENCES products(product. id)
MATCH FULL
ON UPDATE RESTRICT
What does the following statements interpret the referential update action in the PRODUCT table?
A) There is no referential update action at all. The referential constraint only specifies a constraintExamine the ANSI SQL referential integrity definition in the ORDERS table below.
ALTER TABLE orders
‘ADD FOREIGN KEY(product, id) REFERENCES products(product_ id)
MATCH FULL
ON UPDATE RESTRICT
‘What does the following statements interpret the referential update action in the PRODUCT table?
A) There is no referential update action at all. The referential constraint only specifies a constraint
check.
B) Any change to a PRODUCT_ID in the PROCUDTS table causes the PRODUCT_1D column in
matching rows of the ORDERS table to be set to its default value.
)_ Any change to a PRODUCT_ID in the PROCUDTS table causes the corresponding PRODUCT_ID
value in the matching rows of the ORDERS to be set to default value.
ee
E) Any change to a PRODUCT_ID in the PROCUDTS fable causes the sane change to the
corresponding PRODUCT_ID column in the matching rows of the ORDERS table.
i on 7 seeeee VT
Which of the following statements correctly describe the usage of CHECK constraint in ANSI SQL?
A) It cannot be applied on primary key column.There are two tables EMP(ID, NAME. DEPTID) and DEPT(ID, NAME). EMP has 10 records and DEPT has S
records. Based on this, which of the following are valid statements.
SELECT * FROM EMP, DEPT;
A) The query has a syntax error,
B) The query
D}_ The query will return 10 rows,
E) The query will return 15 rows,
- 19---
Which of the following scenarios will an ANSI SQL subquery be utilized? I
A) Find differences in aggregate sales done for all products in the current and previous year.
B}_Find the moving average of product sales in the current year against last five years.
E) Find the average quarterly sales of a product which costs more than $100020.
What is the outcome of the query?
SELECT COUNT(*) + COUNT(*)
A) It returns 0 (zero)
B) It returns 2 (two)
O) It returns 1 (one)
E) Itreturms NULL
- 21———-
Which of the following correctly describe what happens if the ANSI SQL UPDATE statement below is
executed without the predicate information?
500 WHERE sales id = '822818-018'
A) The commission forall sales orders will be modified as 1500in the sales table,
8) The sales order, whose earlier commission was 1500, will not be re-updated.
C)_ NULL values if the COMMISSION column will not be updated as 1500.
D) It will fail with an error because the predicate is mandatory in an UPDATE statement.
E) The sales orders, whose earlier commission was NULL, will excluded in the UPDATE statement.~ —: 22——
Which of the following statements correctly describe the usage of the constructs supported in the
syntax of the FOR loop given below?
FOR a IN 10..100 LOOP
A) The bounds 10..100 can be replaced with 100..10 and then the rest of the statement will get
executed.
8) The FOR loop terminates with an END statement, I
€)_ The set of statements within the loop will not get executed if 10,,100is replaced with 10.10
b) R ountin plemented within the e taterient with FOR
E) It is necessary to declare and define the data type of the counter a before using it in the FOR
loop.panennee DQenneeeeneeneene
What will be the outcome of executing the PL/SQL block?
<>
declare
salary number := 1000;
bonus number.
iteration integer:
max_salary constant number ;= 1300;
begin
goto check salary;
<>
declare
bonus n
begin
cale_salary.salary = salary + cale_salary.salary*bonus;
if salary is null theneet print;
end if; '
dbms_output.put_line('salary increased by' || bonus*100 || ' per cent’);
cale_salary.jteration := cale_salary.iteration + 1;
end calc_bonus;
¢alc_salary,bonus := 0.2;
>
if salary < max salary and iteration < 3 thenend calc. salary;
A) salary increased by 10 per cent
Q
D)
e)
salary increased by 10 per cent
salary increased by 10 per cent
salary = 1111
salary increased by 10 per cent
salary = 1111
salary increased by 10 per cent
salary = 1332
salary increased by 10 per cent
salary increased by 10 per cent
salary = 1331ee 24
What is the output of executing the PL/SQL block below?
declare
s varchar2(100);
begin
select coalesce(nullif(case when 5
end,100),500) into s from dual;
dbms_ output put linet’
end;
A) s=500
B) s=300
D) s=100
€) s=200
Us);
hen 10 when s <>" then 300 else nvi2(s, 200, 400)26 a
Atable, m_ table is mutating for a row-tevel trigger. Which of the following statements carrectly describe
considerations applicable with te mutating table, for any row-level trigger and for any statement-level
trigger?
4)
8)
Q
D)
13)
While executing the row-level trigger, the values accessed from the m_table table can be
recorded by using a PL/SQL table inside a nested table.
The statement-level trigger comprises of the queries in which the values recorded from the row-
level trigger applicable for the m_table table are used.
Since the m_table table is mutating for @ row level trigger, the table can be queried neither in a
row-level trigger nor in a statement-level trigger.
The value recorded in the PL/SQL table cab be accessible by any row-level trigger, but they are
not accessible for any statement-level trigger defined upon the m_table.
By recording the values queried from the row-level trigger in a PL/SQL table within a nested
table, multiple values from the m_table can be saved per update.Ly. . ce
Which of the following headers demonstrate correct specification of compound triggers in Oracle?
A) CREATE OR REPLACE TRIGGER Tra_T. COMPOUND FOR INSERT ON T
B) CREATE OR REPLACE TRIGGER Tra_T FOR INSERT ON T
—E) CREATE OR REPLACE TRIGGER Tra_T COMPOUND TRIGGER FOR INSERT ON TWhich of the following statements correctly describe the validity of the PL/SQL code snippet below in
the DECLARE section?
\ number CONSTANT NUMBER NOT NULL:=7;
A) The statement will be valid if the NOT NULL keyword is removed.
B) The statement will be vafid the assignment operation is replaced with DEFAULT keyword.
C) The statement will be valid if the assignment operation is removed.
E} The statement will be valid if the NUMBER keyword is removed.- - 30-
Consider the PL/SQL code snippet below.
declare
x boolean;
y boolean;
z boolean;
begin
Z.:= not (x and y) and (not x or y);
ifz then dbms.output.put, line( TRUE’);
elsif not z then dbms_output.put_line('FALSE’);
else doms.output-put Jine(’NULL'};
endif;
end;
Under which of the following values of X and Y is Z equal to TRUE?B) X:= TRUE Y:= FALSE
q ks NULL Y:= TRUE
D) X:= TRUE Y:= TRUE— — 3oneenenn
[Which of the following statements correctly describe the benefits of PL/SQL?
B) PL/SQL supports transporting the programs from one operating system to another and tailors
‘them to the new environment.
D) Since PL/SQLis a procedural language, it facilitates specifying the execution plan to the Oracle
server in the form of SQL statements,1. f=open(‘filename.txt’).readiines()
a. Afilehandle
b. Asorted array
c. Anerror code
d. The content of the file ‘ filename.txt’
e. Apython list contacting all the lines in ‘filename.txt"
ANS: a,d,e
2. def test(x
if x%3==0:
return test(x/3)
if x%2==1:
return x
return test(2*x+1)
test(100)
Ans: 6710. Which of the following lines of python code correctly format the output:
Ans:
a. Print ("96.26 % 3.142) b
b. Print (“{:.2f}". format (3.142)
c. Print (*{n: .24)°. format(n=3.142))
11. What is the output of the following code?
z=5
X= “456”
While Z>-1:
Print(2)3. class vehicles:
count=0
def __init_{self, value):
self.value = value
vehicles.count += 1
def getval(selt):
return self.value
def getcount(cls):
return vehicles.count
counter = classmethod(getcount)
typest=vehicles("car")
types2-vehicles("Bus”)
types3=vehicles(“Bike”)
Ans. Car Bus 33
4. Which of the following staternents correctly describe Bidirectional Forwarding
Detection(BFD)
ANS:
a. BFD is enabled on the interfaces and at the router level to detect neighbor adjacency
failures
b. BFD must use object tracking to defect failures
c. Two modes are available: asynchronous and demand