Q 41. Which of the following query finds the total rating of the sailors who have reserved boat “103”?
A. SELECT SUM(s.rating) FROM sailors s, reserves r AND r.bid = 103;
B. SELECT s.rating FROM sailors s, reserves r WHERE s.sid = r.sid AND r.bid = 103
C. SELECT COUNT(s.rating) FROM sailors s, reserves r WHERE s.sid = r.sid AND r.bid = 103
D. SELECT SUM(s.rating) FROM sailors s, reserves r WHERE s.sid = r.sid AND r.bid = 103
Show Answer
Answer:-D. SELECT SUM(s.rating) FROM sailors s, reserves r WHERE s.sid = r.sid AND r.bid = 103Explanation
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.Q 42. The SELECT statement SELECT ‘Hi’ FROM DUAL WHERE NULL = NULL; Outputs
A. Hi
B. FLASE
C. TRUE
D. Nothing
Show Answer
Answer:-D. NothingExplanation
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.Q 43. Which of the following is illegal?
A. SELECT SYSDATE – SYSDATE FROM DUAL;
B. SELECT SYSDATE – (SYSDATE – 2) FROM DUAL;
C. SELECT SYSDATE – (SYSDATE + 2) FROM DUAL;
D. None of these
Show Answer
Answer:-D. None of theseExplanation
SELECT SYSDATE – SYSDATE FROM DUAL; outputs 0 SELECT SYSDATE – (SYSDATE – 2) FROM DUAL; outputs 2 SELECT SYSDATE – (SYSDATE + 2) FROM DUAL; outputs -2Q 44. If a query involves NOT, AND, OR with no parenthesis
A. The order of occurrence determines the order of evaluation.
B. NOT will be evaluated first; OR will be evaluated second; AND will be evaluated last.
C. AND will be evaluated first; OR will be evaluated second; NOT will be evaluated last.
D. NOT will be evaluated first; AND will be evaluated second; OR will be evaluated last.
Show Answer
Answer:-D. NOT will be evaluated first; AND will be evaluated second; OR will be evaluated last.Explanation
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.Q 45. Let the statement SELECT column1 FROM myTable; return 10 rows. The statement SELECT ALL column1 FROM myTable; will return
A. less than 10 rows
B. more than 10 rows
C. exactly 10 rows
D. None of these
Show Answer
Answer:-C. exactly 10 rowsExplanation
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.Q 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
A. 0
B. 9
C. 15
D. 20
Show Answer
Answer:-A. 0Explanation
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.Q 47. Which of the following SQL commands can be used to add data to a database table?
A. ADD
B. UPDATE
C. APPEND
D. INSERT
Show Answer
Answer:-D. INSERTExplanation
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.Q 48. Which of the following join is also called as an ‘inner-join’?
A. Non-Equijoin
B. Self-Join
C. Equijoin
D. None of these
Show Answer
Answer:-C. EquijoinExplanation
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.Q 49. Which of the following is NOT a type of SQL constraint?
A. PRIMARY KEY
B. ALTERNATE KEY
C. FOREIGN KEY
D. UNIQUE
Show Answer
Answer:-B. ALTERNATE KEYExplanation
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.Q 50. What is an SQL virtual table that is constructed from other tables?
A. view
B. A relation
C. Just another table
D. Query results
Show Answer
Answer:-A. viewExplanation
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.Q 51. When using the SQL INSERT statement:
A. rows cannot be copied in mass from one table to another only.
B. rows can either be inserted into a table one at a time or in groups.
C. rows can be modified according to criteria only.
D. rows can be inserted into a table only one at a time only.
Show Answer
Answer:-B. rows can either be inserted into a table one at a time or in groups.Explanation
When using the SQL INSERT statement, rows can either be inserted into a table one at a time or in groups. This means that you can insert multiple rows into a table with a single INSERT statement, making it more efficient for mass data insertion. Option C is the correct choice, while Options A, B, and D do not accurately describe the capabilities of the INSERT statement.Q 52. The SQL ALTER statement can be used to:
A. change the table data.
B. change the table structure.
C. delete rows from the table.
D. add rows to the table.
Show Answer
Answer:-B. change the table structure.Explanation
The SQL ALTER statement is primarily used to change the table structure. It allows you to modify the structure of an existing table by adding, modifying, or deleting columns, as well as changing various constraints or properties of the table. Option B is the correct choice, while Options A, C, and D do not accurately describe the primary purpose of the ALTER statement.53. What SQL command can be used to delete columns from a table?
A. MODIFY TABLE TableName DROP ColumnName
B. MODIFY TABLE TableName DROP COLUMN ColumnName
C. ALTER TABLE TableName DROP ColumnName
D. ALTER TABLE TableName DROP COLUMN ColumnName
Show Answer
Answer:-D. ALTER TABLE TableName DROP COLUMN ColumnNameExplanation
To delete columns from a table in SQL, you can use the ALTER TABLE TableName DROP COLUMN ColumnName command. Option D is the correct choice for removing columns from a table. Options A, B, and C do not represent the standard SQL syntax for deleting columns.Q 54. What SQL command can be used to add columns to a table?
A. ALTER TABLE TableName ADD COLUMN ColumnName
B. ALTER TABLE TableName ADD ColumnName
C. MODIFY TABLE TableName ADD ColumnName
D. MODIFY TABLE TableName ADD COLUMN ColumnName
Show Answer
Answer:-B. ALTER TABLE TableName ADD ColumnNameExplanation
To add columns to a table in SQL, you can use the ALTER TABLE TableName ADD ColumnName command. Option A is the correct choice for adding new columns to an existing table. Options B, C, and D do not represent the standard SQL syntax for adding columns.Q 55. The command to remove rows from a table ‘CUSTOMER’ is:
A. DROP FROM CUSTOMER …
B. UPDATE FROM CUSTOMER …
C. REMOVE FROM CUSTOMER …
D. DELETE FROM CUSTOMER WHERE …
Show Answer
Answer:-D. DELETE FROM CUSTOMER WHERE …Explanation
The command to remove rows from a table in SQL is DELETE FROM CUSTOMER WHERE …. Option D is the correct choice for deleting rows from the ‘CUSTOMER’ table based on specific conditions specified in the WHERE clause. Options A, B, and C do not represent the standard SQL syntax for removing rows.Q 56. The SQL WHERE clause:
A. limits the row data are returned.
B. limits the column data that are returned.
C. Both A and B are correct.
D. Neither A nor B are correct.
Show Answer
Answer:-A. limits the row data are returned.Explanation
The SQL WHERE clause is used to limit the rows of data that are returned from a query. It specifies a condition that must be met for a row to be included in the query result. The WHERE clause does not control which columns are returned; it focuses on filtering rows based on specified conditions. Option A accurately describes the purpose of the WHERE clause, while Option B is incorrect. Option C and Option D are also inaccurate in their descriptions.Q 57. Which of the following is the original purpose of SQL?
A. To define the data structures
B. To specify the syntax and semantics of SQL data definition language
C. To specify the syntax and semantics of SQL manipulation language
D. All of the above.
Show Answer
Answer:-C. To specify the syntax and semantics of SQL manipulation languageExplanation
The original purpose of SQL (Structured Query Language) was to specify the syntax and semantics of SQL manipulation language. SQL was designed to interact with and manipulate data stored in relational database management systems. While SQL has evolved to include data definition language (DDL) for defining data structures and other functionalities, its primary purpose was to provide a standardized language for querying and manipulating data, making Option C the most accurate choice. Options A and B are not the primary original purposes of SQL, and Option D is not entirely accurate as it combines multiple purposes of SQL.Q 58. The wildcard in a WHERE clause is useful when?
A. An exact match is necessary in a CREATE statement.
B. An exact match is necessary in a SELECT statement.
C. An exact match is not possible in a CREATE statement.
D. An exact match is not possible in a SELECT statement.
Show Answer
Answer:-D. An exact match is not possible in a SELECT statement.Explanation
The wildcard in a WHERE clause, often represented by the ‘%’ symbol, is useful when an exact match is not possible in a SELECT statement. It allows for pattern matching and retrieval of rows that meet specific criteria, even when the exact values are not known. Options A and D are not correct because wildcards are not typically used in CREATE statements, and Option B does not accurately represent the primary use of wildcards in SQL, which is for pattern matching in SELECT statements.Q 59. The command to eliminate a table from a database is:
A. DROP TABLE CUSTOMER;
B. DELETE TABLE CUSTOMER;
C. REMOVE TABLE CUSTOMER;
D. UPDATE TABLE CUSTOMER;
Show Answer
Answer:-A. DROP TABLE CUSTOMER;Explanation
To eliminate or delete a table from a database in SQL, you use the command DROP TABLE followed by the table name, as shown in Option A. The DROP TABLE command is used to permanently remove a table and all of its associated data and structure from the database. Options B, C, and D do not represent the correct SQL syntax for removing a table.Q 60. The SQL keyword(s) ________ is used with wildcards.
A. LIKE only
B. IN only
C. NOT IN only
D. IN and NOT IN
Leave a Reply