In: Computer Science
QUESTION 26
For more efficient SQL, replace a series of OR clauses with
IN |
||
AND |
||
NULL |
||
DISTINCT |
2.5 points
QUESTION 27
SELECT ADD_MONTHS('01-FEB_2016', 3) from dual; results in
04-FEB-2016 |
||
01-MAY-2016 |
||
31-MAY-2016 |
||
04-MAY-2016 |
2.5 points
QUESTION 28
joining a table to itself is refered to as
an equijoin |
||
a self join |
||
an outer join |
||
a non equi-join |
2.5 points
QUESTION 29
SELECT MIN(NAME) from Customer; will return which of the following rows
ALICE |
||
WILLIAM |
||
BLAKE |
||
JAMAL |
2.5 points
QUESTION 30
To obtain all the rows from two tables regardless of matches which join should be used
RIGHT OUTER |
||
LEFT OUTER |
||
EQUIJOIN |
||
FULL OUTER |
2.5 points
QUESTION 31
To sort data returned from a SQL statement, which clause should be used
ORDER BY |
||
WHERE |
||
GROUP BY |
||
HAVING |
Its a multiple question answer.I donot have any more database
Question 26:
For more efficient SQL, replace a series of OR clauses with IN
The correct option is a) IN
Explanation:
OR can be replaced with IN considering MySQL as your RDBMS.
For e.g. given a query
Version1
SELECT * FROM table1 WHERE item_desc = 'item 1' OR item_desc = 'item 2'
can be replaced with
Version2
SELECT * FROM table1 WHERE item_desc IN ('item 1','item 2')
The queries given in Version1 and Version2 will give the same result.
Question 27:
SELECT ADD_MONTHS (01-FEB-2016’,3) FROM DUAL; results in 01-MAY-2016.
The correct option is b) 01-MAY-2016
Explanation: The function ADD_MONTHS () is used to add the required number of months to the date and result the output. The first argument of the function ADD_MONTHS () is the date and the second argument is the required number of months which should be added to the date.
Question 28:
Joining a table to itself is referred to as a self-join.
The correct option is b) self-join
Explanation: In self-join, the table is joined with itself. The table is joined with itself such that it appears that they are two tables. At least one table is temporarily renamed.
Question 29:
The given query will give that name as output which has the minimum length. Here, the length of the names is as follows:
ALICE – 5
WILLIAM-7
BLAKE – 5
JAMAL – 5
Here, the length of ALICE, BLAKE and JAMAL is the same and it is the minimum
So, the correct options will be a), c), d)
Question 30:
To obtain all the rows from two tables regardless of matches, FULL JOIN should be used.
The correct option is d) FULL OUTER
Explanation: The FULL OUTER join is the type of join which returns all the records which means all the rows from both the tables. In case the join condition is not met, for any rows on either side of the join, the columns for the other table have NULL values for that row.
Question 31:
To sort data returned from a SQL statement, ORDER BY clause should be used.
The correct option is a) ORDER BY
Explanation: The ORDER BY clause is used to sort in ascending or descending order based on single or multiple columns.