Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
9 views23 pages

Dbms 1

The document discusses various SQL queries and database operations, including creating tables with CHECK constraints, executing SELECT statements, and understanding the results of GROUP BY and JOIN operations. It presents multiple-choice questions regarding the correctness of SQL syntax and expected outputs from given queries. Additionally, it addresses integrity constraints and the implications of updates on related tables.

Uploaded by

shubham
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
0% found this document useful (0 votes)
9 views23 pages

Dbms 1

The document discusses various SQL queries and database operations, including creating tables with CHECK constraints, executing SELECT statements, and understanding the results of GROUP BY and JOIN operations. It presents multiple-choice questions regarding the correctness of SQL syntax and expected outputs from given queries. Additionally, it addresses integrity constraints and the implications of updates on related tables.

Uploaded by

shubham
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
You are on page 1/ 23
Owner Owner Q2 of 23 der the below table FlightDetails. Determine the number of rows displaved for ey eee ee Pree tae Co Q2 of 23 Consider the below table FlightDetails. Determine the number of rows displayed for the given query: SELECT DISTINCT flightid, capacity, basefare FROM FlightDetails; @5 O4 O3 Os D ants to create a ta al traint on cage column. He has come th two ways of mplementing the chec nie t e le Hi 01 i me up with two ways ofr ler ble with CHECK constraint on cag: umn. David wants to crea Q3 of 23 David wants to create a table with CHECK constraint on cage column. He has come up with two ways of implementing the check constraint a A). CREATE TABLE customer( cid NUMBER(S) PRIMARY KEY, cage NUMBER(S), cname VARCHAR2(20), CONSTRAINT cust_check CHECK(cage>=20 AND cage<=50)); 8). CREATE TABLE customer( cid NUMBER(5) PRIMARY KEY, cage NUMBER(5) CONSTRAINT cust_check CHECK(cage>=20 AND. cage<=50), cname VARCHAR2(20)); !dentify which of the above ways of creating table with CHECK constraint is/are CORRECT? O onya © onlys © Neither A nor B Both A and B l 1005} Tom_ What will be the output of the following query? SELECT * FROM employee WHERE empname LIKE 't%'; 1005|Tom Os Q5 of 23 Robert works 1 Nn oF acle and he has created the following table with di ata: |ENAMI 3 DESIGNATION) [ayaz Mohammad [TA Robert né it i eds to write a query to display the details in the following format ENAME DESIGNATION| MyRole James Potter PM. 6 Emily Rayner SE 3 Jack Abraham, ‘SSE 3 [eyez Mohammad TA 4 will result in the above output? IGNATION= PM THEN 6E* Which of the following query IATION=TA’ THEN 4 WHEN DE: gf! THEN 3 WHEN DESIGN) I, DESIGNATION, CASE WHEN DESIGNATION='SE OR DESIGNATION=" WHEN 'PM' THEN ‘MyRole=6 END 2 -MyRole” FRO! SELECT ENAM! "TA THEN MyRole=4 ) SELECT ENAME, DESIGNATION, CASE DESIGNATION WHEN ise! OR 'SSE’ THEN MyRole=3 WHEN NATION, CASE DESIGNATION WHEN ge! OR SSE’ THEN 3 WHEN TA’ THEN 4 WHEN “PMP THEN 6 END as “MYO FROM EMPLOYEE: WHEN DESIGNATION= TA ‘HEN Myole=t WHEN DESICN ATK ~) scLect ENAME, DESIG JON='SSE THEN MyRole= SELECT ENAME DESIGNATION. CASE WHEN DESIGNATION='SE OR DESIGNAT! EMPLOYEE: . rere Se 92 [aor Pee {az rane =e Destld is the PRIMARY KEY. Another table Travel holds the list of tour packages as follows '5005 | Southern Spice Destid in the Travel table references the Destid of the Destination table using a FOREIGN KEY. Given the above details which of the following queries will execute successfully Choose 2 CORRECT options. DELETE FROM Destination where destld = 102 0 n SET destid = 105 where destld = 103 UPDATE Destinatior = 104 Oo DELETE FROM Destination where destid = 102 UPDATE Destination SET gestid = 105 where destid = 10 Fazer Suppliers is a supply chain management solution. They have a table Employee in their database as follows: 3222 | Paul 3 Developers Tom, Dick and Harry are given the task of finding the number of those employees whose EmployeeNo starts with '3'in the company. The employees are not to be considered They write the following queries: Tom: SELECT COUNT(SALARY) FROM Employee WHERE SUBSTR(EmployeeNo, 1,2) '3' AND SALARY IS NOT NULL: Dick: SELECT COUNT(SALARY) FROM Employee WHERE SUBSTR(EmployeeNo,1,1 Harry: SELECT COUNT(*) FROM Employee WHERE SUBSTR(EmployeeNo,1,1) = '3! Which of them will get the correct output? Tom and Harry All of therr pie oh te) SarkariResui ae Say Consiaer the tonowing Employee tapie SELECT SUM(salary) FROM Employee GROUP BY deptno HAVING deptno = Predict the output of the above query: SUM(Salary) not used in HAVING clause egate f eB OUP BY expression Aa Tae tal )y] Q9 of 23 What will be the output of the query given below? Note: Consider the sysdate as ‘26Jul-2017 SELECT ADD_MONTHS(SYSDATE'S) "DATE1", ADD_MONTHS (SYSDATE, -4) "DATE2" FROM dual; A) 26-DEC-17_| 26-NOV-17 26-FEB-17_| 26-MAR-17 8) 26-DEC-17_| 26-MAR-17 Q D ei Sn a. Gmait © whatsApp ie} SarkariResutt.com ... Leen an a ae cs Lea AssessmentDB] Q10 of 23 Consider the table softwares Siven below: Table: softwares $1002 $1003 $1004 Real Player Program 28-Nov-20 $1005, Re-Volt Game 10-Aug-19 Maria Note: Assume sysdate as ‘24-Aug-17 Maria’s Query SELECT * FROM softwares WHERE ADD_MONTHS (sysdate, 30) > licenseexpirydate: Sophia's Query: SELECT * FROM softwares WHERE MONTHS_BETWEEN (licenseexpirydate, sysdate) < 30; Whose query will retrieve the required information? @) Maria Sophia » Both Maria and Sophia Database Manage... Ca What will be the third row when the following query is executed? SELECT companyname FROM company ORDER BY location DESC; A) Tcs » 8) SAP LABS. oO ud Deloitte 9 Ree hid oad L___Infosys__| D) = hehe re rv rae ae’ oar Q12 of 23 Consider the table orders given below: Table: orders 1__|18-Dec-16] 1200 A 2 300 7 3 570 c 4 1000 A 5 800 B How many rows will be fetched when the following query gets executed? SELECT customer, SUM(price) AS PRICE FROM Orders GROUP BY customer, price ‘Gmail © Whatspp fe] Soca atabase Manag Manage... & dome: Sa) eo ner SSS lant b=] Q13 of 23 | Consider the table demo given below: Table: demo Rex wants to extract only the numeric month from DOB column, Which of the following queries are CORRECT to achieve his requirement?” SELECT SUBSTR (TO_CHAR (dob, 'MM/DD/CCYY’),1,2) DOB FROM demo; (SELECT SUBSTR (TO_CHAR (dob, 'DD/MM/CCYY'),4,5) DOB FROM demo; (CO SELECT TO_CHAR (dob, 'MON') DOB FROM demo; SELECT TO_CHAR (dob, 'MM') DOB FROM demo; Q14 of 23 Consider the tables store 3 sales See al Q14 of 23 Consider the tables store and sales given below. CT oo ee $002 Chicago _| Centrat P205_|shampoo| S004 $003 Atlanta East P204 | biscuits | S002 $004 Los Angeles West P203 soap $003 $005 San Francisco West P206 rice $005 $006 Philadelphia East P201 wheat $001 Which is the best primary key for the sales table from the following? O productid desc store_id @ {prod Q15 of 23 Consider the table toys given below: Table: Toys Ti01 | ArmyMen | 240 | 2100 T102 | Finger Paint [150 | 1500 | T103 | Magic8bat| 240 | 2500 T104 Legos 150 | 3000 T105 | Weebles 174_| 1800 T106 | Glow Stick | 231 | 1100 T107 Barbie 174 | 3500 7108 |Magna Doodle] 129 | 2800 Query: select * from Toys where toyname between ‘A’ and 'F'; Oo Pa Pca Reeiehieee L o as are Coe ee Sad Son eS) SUC i ee Le, S Database Manage... abms2- vi ST TD) BT SSSR Constraint: allo cation table allocempid column references the employee table empid column, Tom and Dick executed the below SQL statements in their respective machines sequentially. Tom's UPDATE statements: UPDATE allocation SET allocempid=1067 WHERE allocationid=116;, UPDATE employee SET empid=1077 WHERE empid=1076; Dick's UPDATE statements: UPDATE allocation SET allocempid=NULL WHERE allocation UPDATE employee SET empid=1077 WHERE empid=1076; Choose the correct statement from below that reflects the state of the two tables after the UPDATE statement execution: Tom's update fails due to integrity constraint violation whereas Dick's also fails due to integrity constraint violation ©) Tom's update fails due to integrity constraint violation whereas Dick's update succeeds ipdate also succeeds eeds whereas Dic! Tom's update suc Tom's ubdate succeeds whereas Dick's update fails due to integrity constraint violation mammaire ori ls. k tlie has Cael ee ol < om toe ? " "Apps Gmail © WhatsApp [J sarkariRes a a ee ce eT ote " Ss l Pace) oa Lal T102_| BoardGame T103_| SportGame 7104 Others. T105_| _SoftTo) g) L-T106_|BoardGame. 7101 _[ActionFigure| 7102 _| BoardGame 1103 _| SportGame T104 | Others 1105 | SoftToy T106_[BoardGame @/>]o}o|>|1 o|>lo|>|>/o 9 = & CG A Ee a eas Soon ten : a 3 a Ps Pag. § Sah SP i Gmait WhatsApp (2) SarkariResutt.com Dy fb co 7 St) bee es Manage. & dbms2- Viewer Pag... & sot i ce [ ST Taleb) eH Q18 of 23 Consider the CREATE TABLE command given below: CREATE TABLE record ( recordid VARCHAR2(4) CONSTRAINT REC_ID_PK UNIQUE, filename VARCHAR2(20) CHECK(filename<>subfilename), subfilename VARCHAR2(20)): Which of the following statement will be TRUE wher the above CREATE statement gets executed? CO will result in ERROR as a TABLE should have one PRIMARY KEY Will result in ERROR as check constraints cannot be specified in table level k constraint is specified at column level result in ERROR as lly executed aa Lee cine omar Lc ae Apps Gmail © wnatsapp re] ae eet “ile a ae ce Q19 of 23 Consider the table engineer given below. E101 Ann Systems Engineer | £103 | 9087654321 E102 Maria Web Developer £104 | 9087342134 £103 Paul General Manager | NULL | 9087612345 E104 Kristina Design Engineer £101 | 9087698765 [£105 Ross Technical Lead E101 __ | 9087611223 Query JOIN engineer e2 ON e1.managerid=e2.managerid ngid; SELECT e1.engid FROM engineer e1 IN WHERE reername LIKE '%6a%#’ AND e1.engid< n the above query is executed? e's detai e fetched wh Which of the employee's details will be fe Ex cS ry Cartesian Product ang nn are na P| bo T)scteany og Ao maa O Wasim C Se rT oe) or SST Tem ved Se sae Table: dietpian ewe) ee target P101 C101 7 | p1o2 C102 | | P103 103 110 | 80 P104 C106 _' 24 pios | C105 90 70 Query SELECT planid, c.customerid FROM dietplan d FULL OUTER JOIN customer c ON c.customerid=d.customerid AND LENGTH(emailid)>14; Il be fetched when the above query gets executed? many row eRe) ali Sm Be ee ONC. A) Tablea (Orderid, Customerid) TableB (Orderid, ItemNumber, QuantityOrdered, itemPrice) Table (ItemNumber, ItemName) TableD (Customerid, CustomerName) ‘Tablet (Orderid, DateOrdered) 8) Tablea (Orderid, Customerid, DateOrdered, CustomerName) TableB (Orderid, itemNumber, QuantityOrdered) TableC (ItemNumber, ItemName) TableD (Customerid, CustomerName) Table€ (ItemNumber, itemPrice) ) Tabled (Orderld, DateOrdered) TableB (Orderld, ItemNumber, QuantityOrdered) TableC (ItemNumber, ItemName) TableD (Customerld, CustomerName) TableE (ItemNumber, ItemPrice) D) Tablea (Orderld, Customerld, DateOrdered) TableB (Orderid, ItemNumber, QuantityOrdered) TableC (ItemNumber, ItemName) TableD (Customerld, CustomerName) TableE (ItemNumber, ItemPrice) Choose the query which will generate the output given below: OUTPUT: PRDID PRDNAME | QUANTITY P1003 Tv 1 P1001 MOBILE 5 C SELECT p.prdid, p.prdname, MIN(o.quantityordered) quantity FROM product p INNER JOIN orders 0 ON p. prdid-o.prdid GROUP BY ppd. pra o,prdid GROUP BY p.prdid. perch CO) SELECT p.prdid, p.prdname, MIN(o quantityordered) quantity FROM product p INNER JOIN orders 0 ON P prdid= uct p INNER JOIN orders 0 ON p.prdid-o.prdid GROUP BY P. prdid, p.prd SELECT ppprdid, p-prdname suM(o.quantityordered) quanty FROM prot MIN(o.quantityordered) quantity FROM product p INNER JOIN orders ° ON piprdid=o.praid GROUP BY P prdid, p. ECT p.prdid, p.prdn [CUSTOMERID [NVL(BOOKING.BOOKINGID, 'Not Yet') [C003 [poo1 [coos [002 jcoo2 003 [cooa 004 py [ooo Not Yet OA @©s D

You might also like