ExamVeda
Login
Home
41
Which of the following query finds the total rating of the sailors who have reserved boat "103"?
Discuss
Answer & Solution
Answer: Option D
Solution:
To find the total rating of the sailors who have reserved boat "103," you should use the SQL query SELECT SUM(s.rating) FROM sailors s, reserves r WHERE s.sid = r.sid AND r.bid = 103; (Option D). This query correctly joins the "sailors" and "reserves" tables on the sailor ID (s.sid) and specifies the boat ID (r.bid) to be "103." It then calculates the sum of the ratings (s.rating) of the sailors who have reserved this boat. Option D is the correct choice for achieving this result.
42
The SELECT statement SELECT 'Hi' FROM DUAL WHERE NULL = NULL; Outputs
Discuss
Answer & Solution
Answer: Option D
Solution:
The SELECT statement SELECT 'Hi' FROM DUAL WHERE NULL = NULL; outputs Nothing.

In SQL, NULL represents an unknown or missing value. When comparing NULL to NULL using the = operator, the result is neither TRUE nor FALSE; it's unknown. Therefore, the condition NULL = NULL doesn't evaluate to TRUE, and the row is not selected. Hence, the query returns no results, which can be represented as Nothing.
43
Which of the following is illegal?
Discuss
Answer & Solution
Answer: Option D
Solution:

SELECT SYSDATE - SYSDATE FROM DUAL; outputs 0
SELECT SYSDATE - (SYSDATE - 2) FROM DUAL; outputs 2
SELECT SYSDATE - (SYSDATE + 2) FROM DUAL; outputs -2

44
If a query involves NOT, AND, OR with no parenthesis
Discuss
Answer & Solution
Answer: Option A
Solution:
In SQL, when a query involves NOT, AND, and OR operators without parentheses, the NOT operator is evaluated first, followed by the AND operator, and then the OR operator. This order of evaluation is important for understanding the logic of the query. Therefore, Option A is the correct choice for the order of evaluation.
45
Let the statement
SELECT column1 FROM myTable;
return 10 rows. The statement
SELECT ALL column1 FROM myTable;
will return
Discuss
Answer & Solution
Answer: Option C
Solution:
In SQL, the "SELECT ALL" statement is used to select all rows, which is the default behavior of the "SELECT" statement. If the statement "SELECT column1 FROM myTable;" returns 10 rows, then the statement "SELECT ALL column1 FROM myTable;" will also return exactly 10 rows because it selects all rows from the specified column in the table. Option C is the correct choice.
46
Table employee has 10 records. It has a non-NULL SALARY column which is also UNIQUE.
The SQL statement
SELECT COUNT(*) FROM employee WHERE SALARY > ALL (SELECT SALARY FROM EMPLOYEE);
prints
Discuss
Answer & Solution
Answer: Option D
Solution:
In this statement, you are comparing the SALARY column of each employee with the result of the subquery that selects all SALARY values from the same table. Since the SALARY column is unique, there is no salary greater than ALL the salaries in the same table, including itself. Therefore, the condition SALARY > ALL (SELECT SALARY FROM EMPLOYEE) will always be false for all records, resulting in a count of 0.
47
Which of the following SQL commands can be used to add data to a database table?
Discuss
Answer & Solution
Answer: Option D
Solution:
The SQL command used to add data to a database table is INSERT. The INSERT statement is used to insert new rows or records into a table. Option D is the correct choice for adding data to a table in SQL. Options A, B, and C are not typically used for this purpose in SQL.
48
Which of the following join is also called as an 'inner-join'?
Discuss
Answer & Solution
Answer: Option C
Solution:
The join known as an 'inner-join' is also referred to as an Equijoin. An Equijoin is a type of join in SQL that combines rows from two or more tables based on a related column between them, using the equal (=) operator. It selects only the rows for which there is a match in both tables. Option C is the correct choice for the join also known as an 'inner-join.' Options A and B are different types of joins, and Option D states that none of these terms refer to an inner-join.
49
Which of the following is NOT a type of SQL constraint?
Discuss
Answer & Solution
Answer: Option B
Solution:
An ALTERNATE KEY is not a type of SQL constraint. The other options, PRIMARY KEY, FOREIGN KEY, and UNIQUE, are all types of constraints used in SQL:
PRIMARY KEY ensures that a column or set of columns uniquely identifies each row in a table.
FOREIGN KEY establishes a link between two tables, enforcing referential integrity between them.
UNIQUE constraint ensures that values in a column (or set of columns) are unique across the table, but it doesn't require that the column(s) be the primary means of identifying rows.
Option B, ALTERNATE KEY, is not a standard SQL constraint term.
50
What is an SQL virtual table that is constructed from other tables?
Discuss
Answer & Solution
Answer: Option A
Solution:
An SQL virtual table that is constructed from other tables is known as a view. A view is a saved SQL query that can be treated as a table, allowing users to retrieve and manipulate data as if it were from a regular table. Option A is the correct choice for this SQL concept. Options B, C, and D do not specifically refer to this type of virtual table.