Вы находитесь на странице: 1из 8

1) A database that has been used in production is in need of analysis to attempt

to make performance improvements. Which of the following is likely to


improve performance?(Multiple answer)
Table partitioning
Covering indexes
Triggers
Rapid 5
C2 security
2) Table T

Id Ch Na Fla
g
2 A Jack Y
5 B Amy N
1 $ Adams N
3 * Anna Y
7 @ Rose N
4 & Smith Y
6 ! Sue Y

Create non cluster index nc_T on T(id,ch,na)


Which of the below select statements dose not perform an index seek?
a) Select na from T where ch=!
b) Select na from T where id=6 and ch=!
c) Select na from T where ch=! and id=6
d) Select na from T where na=sue and id=6 and ch=!

3) What will happen in a scenario where there NO match between two tables
that are queried using a Right outer join? ?(Multiple answer)
The right table will return ALL rows
The right table will return NULL
Both tables will return NULL
The left table will return ALL rows
The left table will return NULL

4) PRODUCT
------------------
Product ID (Primary key)
Product Description
Manufacture ID

MANUFACTURE
-------------------------
Manufacture ID (Primary key)

Manufacture name
Referring to the above table, what type of relationship exists between the
product table and the Manufacture table?
a) Product-many Manufacture-many
b) Product-one or many Manufacture-one or many
c) Product-many Manufacture-one
d) Product-one Manufacture-one
e) Product-one Manufacture-many

5) How many records will be returned by the following query ?


#Table1

Col
1
1
#Table2

Col
1
1
-1
%1
[-]1
[%]
1

The data type for col1 in both the tables is varchar


Select * from #table1 t1 inner join #table2 t2 on t1.col like t2.col
a) 1
b) 2
c) 3
d) 4
e) Syntax error, you cannot join using a like operator

6) Which of the following are true about DELETE statements? ?(Multiple answer)
DELETE removes rows one at a time and records an entry in the
transaction log for each deleted row
DELETE cannot be find on a table referenced by a FOREGION KEY
constraint
DELETE activates triggers
DELETE cannot be rolled back
DELETE resets identity of the table
DELETE can be used with or without a WHERE clause

7) Create table #T( i int identity(1,1) not null, c varchar(5) not null)

Insert into #T(c) select one


Truncate table #T
Insert into #T(c) select two
Delete #T
Insert into #T(c) select three

Select * from #T
What will be the result of the select query?
a) 2, two
b) 2, two
3, three
c) 1, two
2, three
d) 2, three
e) 1, three

8) Declare @a int, @b int, @c bit, @d int


Select @a=120
Select @b=30
Select @d=40
Select @c= (@a & @b) | @d
Select @c

The output of the above is?


a) 150
b) 40
c) 110
d) 56
e) None of the above

9) You are creating a procedure that will update two tables within a transaction.
The code looks similar to the following (line numbers are included for
reference only )

1 BEGIN TRANSACTION
2
3 BEGIN TRY
4 UPDATE..
5
6 END TRY
7
8 BEGIN CATCH
9 IF
10
11 END CATCH
12
In most common situations, where would you put the rollback statement?
a) Line 2
b) Line 5
c) Line 7
d) Line 10
e) Line 12

10) WEAPON

AMMUNITION

COUNTRY
SELECT W.NAME
FROM WEAPON W
INNER JOIN COUNTRY C ON C.C_ID=W.C_ID AND C.ORG=1
INNER JOIN AMMUNITION A ON A.A_ID=W.A_ID
UNION
SELECT W.NAME
FROM WEAPON W
INNER JOIN COUNTRY C ON C.C_ID=W.C_ID AND C.ORG=2
INNER JOIN AMMUNITION A ON A.A_ID=W.A_ID

How many rows does the SQL query above return?


a) 0 rows
b) 1 rows
c) 2 rows
d) 8 rows
e) 9 rows

11) DELETE FROM doctors d, physicians p


WHERE d.doc_id=p.phys_id
AND d.house_calls = N
AND p.fee >
(SELECT MAX (gnp) FROM countries
WHERE world=3 )

What happens to the tables doctors and physicians when the sample code
above is executed?
a) All rows from both tables are deleted because of an improper join between
doctors and physicians
b) Nothing happen to either table because an error is caused by the use of a
subquery in the WHERE clause of the DELETE statement
c) Nothing happen to either table because an error is caused by the inclusion
of more than one table in the DELETE table
d) The corresponding rows are deleted from the doctors table because it is
listed first, but the physicians table remains unaffected.
e) The corresponding rows are deleted from both the doctors and
physicians tables

12) Create table dept(deptid number(4) primary key, deptname char(10));


Create index dept_deptname_idx on dept(deptname)
/* the dept table contains 10,000 rows and the deptname column 10 unique
values that are evenly distributed? */

Based on the scenario above, which query needs to use the


dept_deptname_idx index
a) Select deptid from dept where deptid <> 1234
b) Select deptid from dept where deptname = sales
c) Select distinct deptid from dept
d) Select deptid from dept where deptname <> sales
e) Select deptid from dept where deptid < 1234

13) Select v.loc_id, v.part_id, p.stock_id, p.cost_id


From INVENTORY V
Inner join LOCATION L on V.loc_id= L.loc_id
Inner join PART P on V.part_id= P.part_id
Inner join STOCK S on S.stock_id=P.stock_id
Inner join COST C on C.cost_id= P.cost_id
Where V.item_id=:bind_var
Order by V.loc_id ASC

A developer reports the sample query always returns only one row, but takes
about an hour to execute against the database. What is the most likely
explanation for the poor performance?
a) Inventory.item_id is not an indexed column
b) The order by clause must sort millions of records before selecting which
one to run
c) The query should not return table _id column in the return set: the
developer should modify the query to return human related data values
d) The database is over-normalized and must be radically restructured
e) The inner join should be converted to outer joins to speed performance

14) T1
Delete from t1 where cnt < (select MAX (T.cnt) from T1 T where
T1.cno=T.cno);
Based on the scenario above, how many rows remain in table T1 after the
DELETE statement is
a) 2 rows
b) 3 rows
c) 4 rows
d) 5 rows
e) 6 rows

15) Select the BEST scenario(s) for the backup strategy: FULL database
backup+ Transaction log backup
The database has few data modifications
The database is considerably large or predicted to grow large in the
near future.
There are substantial updates/data modifications taken place on the
database
In case of a disaster, the need is to recover the database to as recent a
state as possible thus not to lose any transactions taken place on it.
You cannot afford to lose changes since the most recent database
backup
The database is small. The amount of time required to backup a small
database is reasonable.

16) You have a table called Employees with following columns


EmployeeID int
EmployeeName varchar (256)
Salary money
DeptID smallint

The table has following indexes created on it


1) Clustered index on EmployeeID
2) NonClustered index on EmployeeName
3) NonClustered index on DeptID

The Employees table has over 10 million rows.


You want to get the count of Employees, for which you write the following
query

SELECT COUNT (*) FROM Employees

What will be the likely query plan for above query? Which index will SQL
SERVER use in above query? Please give an explanation for your answer.

17) You have following two tables

Write a query to return the customer details and the details of the most
recent order placed by the customer.
If this was the only query to be executed at all times, what indexes would you
create on the two tables?

SELECT *
FROM #SORDER JOIN #CUST
ON #SORDER.CID=#CUST.CID
WHERE SDATE=(SELECT MAX(SDATE)
FROM #SORDER)

Clustered index on customerid in customermaster and

Nonclustered index on customerid in salesordermaster