Which SQL statement is used to create a new index on a table?
Correct answer:
B) CREATE INDEX
Explanation: The CREATE INDEX statement is used to create an index on one or more columns of a table to improve query performance.
Which SQL statement is used to create a new index on a table?
Correct answer:
B) CREATE INDEX
Explanation: The CREATE INDEX statement is used to create an index on one or more columns of a table to improve query performance.
What is the purpose of the ALTER TABLE statement in SQL?
Correct answer:
C) To modify an existing table's structure
Explanation: The ALTER TABLE statement is used to change the structure of an existing table, such as adding or dropping columns.
Which SQL function is used to return the number of rows that meet a specified condition?
Correct answer:
B) COUNT()
Explanation: The COUNT() function counts the number of rows that satisfy a given condition in a SQL query.
Which SQL clause is used to sort the result set of a query in descending order?
Correct answer:
A) ORDER BY DESC
Explanation: The ORDER BY clause with DESC sorts the result set in descending order based on the specified column(s).
What does the acronym SQL stand for?
Correct answer:
A) Structured Query Language
Explanation: SQL stands for Structured Query Language, which is used for managing and manipulating relational databases.
Which SQL statement is used to remove all records from a table without removing the table structure?
Correct answer:
B) TRUNCATE
Explanation: The TRUNCATE command deletes all rows from a table while keeping the table structure intact for future use.
Which SQL keyword is used to specify conditions for a query?
Correct answer:
B) WHERE
Explanation: The WHERE clause is used to specify conditions that filter which rows are returned by a query.
Which SQL function is used to find the highest value in a column?
Correct answer:
B) MAX()
Explanation: The MAX() function returns the maximum value from a specified column in a table.
What does the DISTINCT keyword do in a SQL query?
Correct answer:
A) Removes duplicates from the result set
Explanation: The DISTINCT keyword is used to ensure that the result set contains only unique records, eliminating duplicates.
Which SQL command is used to delete a database?
Correct answer:
A) DROP DATABASE
Explanation: The DROP DATABASE command is used to permanently remove a database and all its tables from the database management system.
What is a foreign key in a relational database?
Correct answer:
B) A reference to a primary key in another table
Explanation: A foreign key is a column or group of columns that establishes a link between two tables, referencing the primary key of another table.
Which SQL function can be used to concatenate two strings?
Correct answer:
C) CONCAT()
Explanation: The CONCAT() function is used to join two or more strings together in SQL.
Which SQL clause is used to specify the table from which to retrieve data?
Correct answer:
A) FROM
Explanation: The FROM clause indicates the table(s) from which data will be retrieved in a SQL query.
Which SQL function returns the current date without the time portion?
Correct answer:
B) CURDATE()
Explanation: The CURDATE() function returns the current date, excluding the time portion.
Which SQL command is used to change the data type of an existing column?
Correct answer:
C) ALTER COLUMN
Explanation: The ALTER TABLE command is used with the ALTER COLUMN clause to change the data type of an existing column.
Which SQL statement is used to retrieve unique values from a column?
Correct answer:
B) SELECT DISTINCT
Explanation: The SELECT DISTINCT statement retrieves unique values from a specified column, removing duplicates.
Which SQL command is used to assign privileges to a user?
Correct answer:
A) GRANT
Explanation: The GRANT command is used to assign specific privileges to a user or role in the database.
What does the SQL command DELETE do?
Correct answer:
B) Removes specific rows from a table
Explanation: The DELETE command is used to remove specific rows from a table based on specified conditions.
In SQL, which function calculates the average of a numeric column?
Correct answer:
B) AVG()
Explanation: The AVG() function computes the average value of a specified numeric column in SQL.
Which clause is used in SQL to group rows that have the same values in specified columns?
Correct answer:
B) GROUP BY
Explanation: The GROUP BY clause groups rows that share the same values in specified columns, allowing for aggregate functions to be applied.
Which SQL statement is used to create a new view based on a SELECT query?
Correct answer:
A) CREATE VIEW
Explanation: The CREATE VIEW statement defines a new view based on a SELECT query, simplifying data retrieval.
Which SQL operator is used to test for a NULL value?
Correct answer:
A) IS NULL
Explanation: The IS NULL operator is used to test whether a value is NULL in SQL.
What does the term 'join' refer to in SQL?
Correct answer:
A) Combining data from two or more tables
Explanation: A join in SQL combines data from two or more tables based on a related column between them.
Which SQL function is used to return the length of a string?
Correct answer:
A) LENGTH()
Explanation: The LENGTH() function returns the number of characters in a string in SQL.
Which SQL clause is used to specify the number of rows to be returned?
Correct answer:
A) LIMIT
Explanation: The LIMIT clause is used to restrict the number of rows returned by a SQL query.
Which SQL statement is used to create a new database?
Correct answer:
B) CREATE DATABASE
Explanation: The CREATE DATABASE statement is used to define a new database within the database management system.
Which SQL keyword is used to specify an alternative value if a NULL value is encountered?
Correct answer:
B) COALESCE
Explanation: The COALESCE function returns the first non-NULL value in a list, allowing for default values in the presence of NULLs.
What does the term 'schema' refer to in a database?
Correct answer:
B) The overall structure of the database
Explanation: A schema defines the structure of a database, including tables, columns, data types, and relationships.
Which SQL command is used to grant a user read-only access to a table?
Correct answer:
A) GRANT SELECT
Explanation: The GRANT SELECT command is used to provide a user with permission to read data from a specific table without allowing modifications.
Which SQL keyword is used to specify the data type of a column in a table?
Correct answer:
B) DATA TYPE
Explanation: The DATA TYPE specifies the type of data that can be stored in a column, such as INTEGER, VARCHAR, DATE, etc.
Which SQL command is used to create a new table with specified columns and data types?
Correct answer:
A) CREATE TABLE
Explanation: The CREATE TABLE command is used to define a new table and its columns within the database.
Which SQL statement is used to modify the values of a specific column in existing records?
Correct answer:
A) UPDATE
Explanation: The UPDATE statement is used to change the values of one or more columns in existing records based on specified conditions.
Which SQL function is used to remove leading and trailing spaces from a string?
Correct answer:
A) TRIM()
Explanation: The TRIM() function removes leading and trailing whitespace from a string in SQL.
What is the purpose of the HAVING clause in SQL?
Correct answer:
C) To filter records after grouping
Explanation: The HAVING clause is used to filter results after aggregation has taken place, allowing conditions on grouped data.
Which SQL statement is used to remove a row from a table?
Correct answer:
C) DELETE
Explanation: The DELETE statement is used to remove specific rows from a table based on defined conditions.
What does the SQL function LCASE() do?
Correct answer:
C) Converts a string to lowercase
Explanation: The LCASE() function converts all uppercase characters in a string to lowercase.
Which SQL operator is used to compare two values for equality?
Correct answer:
A) =
Explanation: The equal sign (=) is the operator used to compare two values for equality in SQL.
Which SQL command is used to remove a column from a table?
Correct answer:
A) DROP COLUMN
Explanation: The DROP COLUMN statement is used to remove a specified column from an existing table.
What is the purpose of a data dictionary in a database?
Correct answer:
C) To describe database structure and objects
Explanation: A data dictionary contains metadata about the database structure, including details about tables, columns, indexes, and constraints.
Which SQL command is used to create a new user in the database?
Correct answer:
A) CREATE USER
Explanation: The CREATE USER command establishes a new user account in the database management system.
What does the term 'aggregate function' refer to in SQL?
Correct answer:
A) A function that performs calculations on a set of values
Explanation: Aggregate functions perform calculations on a set of values and return a single summary value, such as SUM(), AVG(), COUNT(), etc.
Which SQL keyword is used to specify the conditions for a query after grouping has occurred?
Correct answer:
B) HAVING
Explanation: The HAVING clause is used to filter groups of records after the aggregation has been performed.
Which SQL clause is used to limit the number of rows returned by a query?
Correct answer:
A) LIMIT
Explanation: The LIMIT clause restricts the number of rows returned in the result set of a SQL query.
Which SQL function would you use to get the current time?
Correct answer:
B) CURTIME()
Explanation: The CURTIME() function returns the current time from the system clock in SQL.
What does the SQL command ROLLBACK do?
Correct answer:
B) Undoes changes made in the current transaction
Explanation: The ROLLBACK command is used to undo any changes made during the current transaction, reverting the database to its previous state.
Which SQL statement is used to change a database's default character set?
Correct answer:
A) ALTER DATABASE
Explanation: The ALTER DATABASE statement is used to modify database properties, including changing the default character set.
What is the purpose of a schema in SQL?
Correct answer:
B) To structure the organization of data
Explanation: A schema defines the organization of data, including how tables and relationships are structured in the database.
Which SQL function would you use to find the total number of rows in a specific column?
Correct answer:
B) COUNT()
Explanation: The COUNT() function is used to determine the total number of rows in a specific column, including those that may contain NULL values.
Which SQL statement is used to modify an existing column's data type?
Correct answer:
A) ALTER TABLE MODIFY COLUMN
Explanation: The ALTER TABLE statement with MODIFY COLUMN is used to change the data type of an existing column in SQL.
Which SQL clause is used to combine results from two or more SELECT statements?
Correct answer:
B) UNION
Explanation: The UNION clause combines the result sets of two or more SELECT statements into a single result set, eliminating duplicates.
If this exam is giving you a hard time, let us be your helping hand. Contact us, and we'll provide the assistance you need to pass and move forward.