ExamVeda
Login
Home
21
Which of the following do you need to consider when you make a table in SQL?
Discuss
Answer & Solution
Answer: Option D
Solution:
Option A: Data types - When creating a table in SQL, you need to specify the data types for each column to define what type of data can be stored in that column (e.g., VARCHAR, INTEGER, DATE).
Option B: Primary keys - Primary keys uniquely identify each record in a table and are used to enforce entity integrity in SQL. They ensure each row is uniquely identifiable.
Option C: Default values - Default values are optional constraints that can be set for columns in SQL tables. They specify a value that is used when an explicit value is not specified during an INSERT operation.
Option D: All of the above - This option is correct. When creating a table in SQL, you need to consider data types to define the nature of each column, primary keys to uniquely identify rows, and default values to provide fallback values when necessary.
Conclusion:
When creating a table in SQL, you need to consider Option D: All of the above: Data types, Primary keys, and Default values. These elements are essential for defining the structure and constraints of the table.
22
SQL query and modification commands make up a(n) ________ .
Discuss
Answer & Solution
Answer: Option A
Solution:
Option A: DDL - DDL stands for Data Definition Language in SQL. It consists of commands used to define, modify, and remove database objects such as tables and indexes. Examples include CREATE, ALTER, and DROP commands.
Option B: DML - DML stands for Data Manipulation Language. It consists of commands used to manipulate data within database objects. Examples include INSERT, UPDATE, and DELETE commands.
Option C: HTML - HTML (Hypertext Markup Language) is not related to SQL query and modification commands. This option is incorrect.
Option D: XML - XML (eXtensible Markup Language) is not related to SQL query and modification commands. This option is incorrect.
Conclusion:
SQL query and modification commands that define and manipulate database objects are categorized under Option A: DDL (Data Definition Language). These commands are used to manage the structure and schema of the database.
23
When three or more AND and OR conditions are combined, it is easier to use the SQL keyword(s):
Discuss
Answer & Solution
Answer: Option E
Solution:
Option A: LIKE only. - The LIKE keyword is used for pattern matching with wildcard characters in SQL, not for combining multiple conditions with AND and OR.
Option B: IN only. - The IN keyword is used to specify multiple values in a WHERE clause, but it is not specifically used for combining multiple conditions with AND and OR.
Option C: NOT IN only. - The NOT IN keyword is used to specify exclusion of multiple values in a WHERE clause, but it is not specifically used for combining multiple conditions with AND and OR.
Option D: Both IN and NOT IN. - This option is incorrect as it does not relate to combining multiple conditions with AND and OR.
Conclusion:
When combining three or more AND and OR conditions in SQL, it is easier to use parentheses to group the conditions logically. There is no specific keyword like IN or NOT IN that simplifies this process. Therefore, the correct answer is None of the above.
24
The Microsoft Access wildcards are ____ and ____ .
Discuss
Answer & Solution
Answer: Option B
Solution:
Option A: asterisk (); percent sign (%) - This option is incorrect. While the asterisk () is a wildcard character in Microsoft Access (and SQL generally for SELECT statements), the percent sign (%) is used in SQL for pattern matching, not specifically as a wildcard in Microsoft Access.
Option B: percent sign (%); underscore () - This option is correct. In Microsoft Access, the percent sign (%) is used as a wildcard for matching zero or more characters, and the underscore () is used as a wildcard for matching a single character.
Option C: underscore (); question mark (?) - The underscore () and question mark (?) are not commonly used as wildcards in Microsoft Access. This option is incorrect.
Option D: question mark (?); asterisk () - The question mark (?) and asterisk () are not typically used as wildcards in Microsoft Access. This option is incorrect.
Conclusion:
In Microsoft Access, the wildcards are Option B: percent sign (%) and underscore (_). These characters are used for pattern matching in queries to match specific text patterns within data fields. Therefore, the correct answer is Option B.
25
Find the SQL statement below that is equal to the following: SELECT NAME FROM CUSTOMER WHERE STATE = 'VA';
Discuss
Answer & Solution
Answer: Option D
Solution:
Option A: SELECT NAME IN CUSTOMER WHERE STATE IN ('VA'); - This statement is incorrect because it uses "IN" incorrectly. The "IN" keyword is used to specify multiple possible values for a column, not for filtering by a single value.
Option B: SELECT NAME IN CUSTOMER WHERE STATE = 'VA'; - This statement is incorrect because it uses "IN" incorrectly. Similar to Option A, "IN" is not used for single value comparisons.
Option C: SELECT NAME IN CUSTOMER WHERE STATE = 'V'; - This statement is incorrect because it does not match the specified condition 'VA'.
Option D: SELECT NAME FROM CUSTOMER WHERE STATE IN ('VA'); - This statement is correct. It retrieves the NAME column from the CUSTOMER table where the STATE column has the value 'VA'.
Conclusion:
To achieve the SQL statement "SELECT NAME FROM CUSTOMER WHERE STATE = 'VA';", the correct SQL statement is Option D: SELECT NAME FROM CUSTOMER WHERE STATE IN ('VA');. This option correctly filters rows where the STATE column equals 'VA'.
26
Which one of the following sorts rows in SQL?
Discuss
Answer & Solution
Answer: Option C
Solution:
Option A: SORT BY - This is not a standard SQL keyword for sorting rows. The correct keyword for sorting rows in SQL is "ORDER BY".
Option B: ALIGN BY - This is not a valid SQL keyword for any operation, including sorting.
Option C: ORDER BY - This is the correct answer. The "ORDER BY" clause in SQL is used to sort the result set by one or more columns in ascending or descending order.
Option D: GROUP BY - The "GROUP BY" clause is used to group rows that have the same values into summary rows, typically for aggregate functions like SUM or COUNT, not for sorting.
Conclusion:
The SQL keyword that sorts rows in a query result set is Option C: ORDER BY. This clause allows you to specify the column(s) by which you want to sort the results and the order (ascending or descending). Therefore, the correct answer is ORDER BY.
27
To sort the results of a query use:
Discuss
Answer & Solution
Answer: Option C
Solution:
Option A: SORT BY. - This is not a standard SQL keyword for sorting rows. The correct keyword for sorting rows in SQL is "ORDER BY".
Option B: GROUP BY. - The "GROUP BY" clause is used to group rows that have the same values into summary rows, typically for aggregate functions like SUM or COUNT, not for sorting.
Option C: ORDER BY. - This is the correct answer. The "ORDER BY" clause in SQL is used to sort the result set by one or more columns in ascending or descending order.
Option D: None of the above is correct. - This option is incorrect because Option C ("ORDER BY") is the correct answer for sorting query results in SQL.
Conclusion:
To sort the results of a query in SQL, you use the Option C: ORDER BY clause. This allows you to specify the column(s) by which you want to sort the results and the order (ascending or descending). Therefore, the correct answer is ORDER BY.
28
To define what columns should be displayed in an SQL SELECT statement:
Discuss
Answer & Solution
Answer: Option A
Solution:
Option A: use FROM to name the source table(s) and list the columns to be shown after SELECT. - This option is incorrect. The "FROM" clause is used to specify the table(s) from which data is retrieved, not to define columns to be displayed.
Option B: use USING to name the source table(s) and list the columns to be shown after SELECT. - This option is incorrect. The "USING" clause in SQL is used for specifying columns for join conditions, not for selecting columns to display.
Option C: use SELECT to name the source table(s) and list the columns to be shown after USING. - This option is incorrect. The "SELECT" keyword is used at the beginning of a query to specify the columns or expressions to be retrieved, not to name tables or specify columns after "USING".
Option D: use USING to name the source table(s) and list the columns to be shown after WHERE. - This option is incorrect. The "USING" keyword in SQL is not used to list columns to be displayed in a SELECT statement.
Conclusion:
To define what columns should be displayed in an SQL SELECT statement, you use the Option A: use FROM to name the source table(s) and list the columns to be shown after SELECT. This means you specify the columns to display immediately after the "SELECT" keyword, not after "FROM" or "USING". Therefore, the correct answer is Option A.
29
SQL can be used to:
Discuss
Answer & Solution
Answer: Option D
Solution:
Option A: create database structures only. - This option is incorrect. SQL (Structured Query Language) can do more than just create database structures. It can also query data and modify data.
Option B: query database data only. - This option is incorrect. SQL is not limited to querying data only. It can also create database structures and modify data.
Option C: modify database data only. - This option is incorrect. SQL is not limited to modifying data only. It can also create database structures and query data.
Option D: All of the above can be done by SQL. - This is the correct answer. SQL is a comprehensive language that can perform various tasks including creating database structures (DDL - Data Definition Language), querying database data (DML - Data Manipulation Language), and modifying database data.
Conclusion:
SQL can be used for Option D: All of the above can be done by SQL. This includes creating database structures, querying database data, and modifying database data. Therefore, the correct answer is All of the above can be done by SQL.
30
The SQL statement that queries or reads data from a table is ________ .
Discuss
Answer & Solution
Answer: Option A
Solution:
Option A: SELECT - This is the correct answer. The "SELECT" statement in SQL is used to query or read data from a table. It allows you to specify which columns to retrieve and from which table.
Option B: READ - This option is incorrect. "READ" is not a standard SQL keyword used for querying data from a table.
Option C: QUERY - While "QUERY" can be used informally to describe retrieving data, it is not a specific SQL keyword for reading data from a table.
Option D: None of the above is correct - This option is incorrect because Option A ("SELECT") is indeed the correct SQL keyword for querying or reading data from a table.
Conclusion:
The SQL statement that queries or reads data from a table is Option A: SELECT. This keyword is fundamental in SQL for retrieving data from one or more tables. Therefore, the correct answer is SELECT.