OA Exams
Which SQL statement is used to create a new view based on a SELECT query?
a) CREATE VIEWb) NEW VIEWc) ADD VIEWd) DEFINE VIEW
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?
a) IS NULLb) NULL TESTc) IS EMPTYd) NOT NULL
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?
a) Combining data from two or more tablesb) Removing duplicates from a tablec) Sorting records in a tabled) Creating a new database
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?
a) LENGTH()b) SIZE()c) COUNT()d) CHAR_LENGTH()
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?
a) LIMITb) TOPc) RANKd) COUNT
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?
a) NEW DATABASEb) CREATE DATABASEc) ADD DATABASEd) DEFINE 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?
a) IFNULLb) COALESCEc) NULLIFd) DEFAULT
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?
a) The physical storage of datab) The overall structure of the databasec) The data types of columnsd) The user privileges
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?
a) GRANT SELECTb) GRANT READc) GRANT ALLd) GRANT WRITE
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?
a) TYPEb) DATA TYPEc) COLUMN TYPEd) DATA
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?
a) CREATE TABLEb) ADD TABLEc) NEW TABLEd) DEFINE TABLE
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?
a) UPDATEb) CHANGEc) MODIFYd) ALTER
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?
a) TRIM()b) CLEAN()c) STRIP()d) REMOVE()
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?
a) To filter records before groupingb) To sort the result setc) To filter records after groupingd) To join multiple tables
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?
a) DROPb) REMOVEc) DELETEd) TRUNCATE
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?
a) Converts a string to uppercaseb) Removes spaces from a stringc) Converts a string to lowercased) Counts characters in a string
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?
a) =b) <>c) !=d) IS
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?
a) DROP COLUMNb) REMOVE COLUMNc) DELETE COLUMNd) ALTER COLUMN
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?
a) To store user datab) To define user permissionsc) To describe database structure and objectsd) To keep track of transactions
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?
a) CREATE USERb) ADD USERc) NEW USERd) DEFINE USER
Correct Answer: a) CREATE USER
Explanation: The CREATE USER command establishes a new user account in the database management system.