1Which of the following categories of SQL commands is used to define the structure of the database, including creating, altering, and deleting tables?
A.DML (Data Manipulation Language)
B.DCL (Data Control Language)
C.TCL (Transaction Control Language)
D.DDL (Data Definition Language)
Correct Answer: DDL (Data Definition Language)
Explanation:DDL (Data Definition Language) includes commands like CREATE, ALTER, DROP, and TRUNCATE which deal with the schema and structure of the database.
Incorrect! Try again.
2Which SQL command is used to remove all records from a table, including all spaces allocated for the records are removed, but the table structure remains?
A.DELETE
B.DROP
C.TRUNCATE
D.REMOVE
Correct Answer: TRUNCATE
Explanation:TRUNCATE is a DDL command that removes all rows from a table. Unlike DELETE, it does not generate individual rollback data for each row and resets identity seeds.
Incorrect! Try again.
3Which of the following is not a DML (Data Manipulation Language) command?
A.INSERT
B.UPDATE
C.GRANT
D.DELETE
Correct Answer: GRANT
Explanation:GRANT is a DCL (Data Control Language) command used to provide access privileges. INSERT, UPDATE, and DELETE are DML commands.
Incorrect! Try again.
4The command to undo the changes made by the current transaction is:
A.COMMIT
B.ROLLBACK
C.SAVEPOINT
D.REVOKE
Correct Answer: ROLLBACK
Explanation:ROLLBACK is a TCL command used to undo transactions that have not yet been saved to the database.
Incorrect! Try again.
5Which command is used to modify the structure of an existing table, such as adding a new column?
A.UPDATE
B.MODIFY
C.ALTER
D.CHANGE
Correct Answer: ALTER
Explanation:ALTER is the DDL command used to add, delete, or modify columns in an existing table.
Incorrect! Try again.
6In the context of database keys, a Super Key is defined as:
A.A set of attributes that uniquely identifies a tuple within a relation
B.A minimal set of attributes that uniquely identifies a tuple
C.A key that links two tables together
D.A key that allows NULL values
Correct Answer: A set of attributes that uniquely identifies a tuple within a relation
Explanation:A Super Key is any set of attributes (one or more) that can uniquely identify a row. It does not necessarily have to be minimal.
Incorrect! Try again.
7If is a Candidate Key of relation , which of the following statements is true?
A. must be a Super Key and no proper subset of is a Super Key
B. can contain NULL values
C. must be a composite key
D. is a subset of the Foreign Key
Correct Answer: must be a Super Key and no proper subset of is a Super Key
Explanation:A Candidate Key is a minimal Super Key. This means if any attribute is removed from , it no longer uniquely identifies tuples.
Incorrect! Try again.
8Which integrity constraint ensures that no two rows of a table have duplicate values in a specified column or set of columns, but allows NULL values (usually one)?
A.PRIMARY KEY
B.CHECK
C.UNIQUE
D.FOREIGN KEY
Correct Answer: UNIQUE
Explanation:The UNIQUE constraint ensures all values in a column are distinct. Unlike the PRIMARY KEY, it typically allows one NULL value (depending on the specific DBMS implementation).
Incorrect! Try again.
9The Entity Integrity Rule states that:
A.Foreign key values must match a primary key in another table
B.Primary key attributes cannot be NULL
C.All attributes must have a domain
D.A transaction must be atomic
Correct Answer: Primary key attributes cannot be NULL
Explanation:Entity Integrity ensures that each row is uniquely identifiable, which requires the Primary Key to have a non-null value.
Incorrect! Try again.
10Which SQL clause is used to filter the results of a query based on a specified condition?
A.ORDER BY
B.GROUP BY
C.WHERE
D.HAVING
Correct Answer: WHERE
Explanation:The WHERE clause is used to extract only those records that fulfill a specified condition.
Incorrect! Try again.
11What is the purpose of the FOREIGN KEY constraint?
A.To ensure unique identification of a record
B.To speed up data retrieval
C.To enforce referential integrity between two tables
D.To ensure a column cannot be left empty
Correct Answer: To enforce referential integrity between two tables
Explanation:A Foreign Key is a field (or collection of fields) in one table that refers to the Primary Key in another table, ensuring the relationship between the data remains consistent.
Incorrect! Try again.
12Which operator is used to search for a specified pattern in a column?
A.IN
B.BETWEEN
C.LIKE
D.EXISTS
Correct Answer: LIKE
Explanation:The LIKE operator is used in a WHERE clause to search for a specified pattern in a column, often using wildcards like % and _.
Incorrect! Try again.
13In SQL, what does the wildcard character % represent?
A.Zero or more characters
B.Exactly one character
C.A numeric value only
D.A NULL value
Correct Answer: Zero or more characters
Explanation:The percent sign % represents zero, one, or multiple characters in a pattern match.
Incorrect! Try again.
14Which of the following is a TCL (Transaction Control Language) command used to define a point within a transaction to which you can roll back?
A.COMMIT
B.ROLLBACK
C.SAVEPOINT
D.SET TRANSACTION
Correct Answer: SAVEPOINT
Explanation:SAVEPOINT creates a point within a transaction. If an error occurs, you can roll back to the savepoint rather than rolling back the entire transaction.
Incorrect! Try again.
15Which SQL keyword is used to retrieve unique values only?
A.DIFFERENT
B.UNIQUE
C.DISTINCT
D.SINGLE
Correct Answer: DISTINCT
Explanation:The SELECT DISTINCT statement is used to return only distinct (different) values.
Incorrect! Try again.
16Given the relation , if the attribute set is a candidate key, then is:
A.A Primary Key
B.A Super Key
C.A Foreign Key
D.Not a key
Correct Answer: A Super Key
Explanation:Since uniquely identifies tuples, adding any attribute (like ) to it results in a superset which is also a Super Key, though not a minimal one (Candidate Key).
Incorrect! Try again.
17Which constraint ensures that the value in a column falls within a specific range or satisfies a logical expression?
A.DEFAULT
B.CHECK
C.UNIQUE
D.INDEX
Correct Answer: CHECK
Explanation:The CHECK constraint is used to limit the value range that can be placed in a column.
Incorrect! Try again.
18When using the ORDER BY clause, what is the default sorting order?
A.Descending (DESC)
B.Ascending (ASC)
C.Random
D.Insertion Order
Correct Answer: Ascending (ASC)
Explanation:If ASC or DESC is not specified, ORDER BY sorts the records in ascending order by default.
Incorrect! Try again.
19Which of the following statements regarding DELETE and DROP is true?
A.DELETE removes the table structure; DROP removes only rows.
B.DELETE is DDL; DROP is DML.
C.DELETE removes specific rows and can be rolled back; DROP removes the entire table and structure.
D.There is no difference.
Correct Answer: DELETE removes specific rows and can be rolled back; DROP removes the entire table and structure.
Explanation:DELETE is a DML command to remove rows (logging occurs). DROP is a DDL command that removes the table definition entirely from the database.
B.A Foreign Key value is inserted that does not exist in the referenced Primary Key column
C.Two rows have the same Primary Key
D.A column with a UNIQUE constraint receives a duplicate value
Correct Answer: A Foreign Key value is inserted that does not exist in the referenced Primary Key column
Explanation:Referential integrity requires that if a foreign key contains a value, that value must refer to an existing, valid record in the parent table.
Incorrect! Try again.
21Which SQL function is used to count the number of rows that contain numbers or non-NULL values in a specific column?
A.SUM()
B.TOTAL()
C.COUNT()
D.NUMBER()
Correct Answer: COUNT()
Explanation:COUNT(column_name) returns the number of values (excluding NULLs) of the specified column. COUNT(*) counts all rows.
Incorrect! Try again.
22The HAVING clause is used in combination with which other clause?
A.ORDER BY
B.GROUP BY
C.SELECT
D.UPDATE
Correct Answer: GROUP BY
Explanation:The HAVING clause was added to SQL because the WHERE keyword could not be used with aggregate functions. It filters records after the GROUP BY operation.
Incorrect! Try again.
23Which set operator returns only the rows that appear in both result sets of two SELECT statements?
A.UNION
B.UNION ALL
C.INTERSECT
D.MINUS
Correct Answer: INTERSECT
Explanation:INTERSECT returns the common rows found in both queries.
Incorrect! Try again.
24What is an Alternate Key?
A.A key used for encryption
B.A Candidate Key that is not selected as the Primary Key
C.A Foreign Key in a third normal form
D.A Primary Key consisting of two columns
Correct Answer: A Candidate Key that is not selected as the Primary Key
Explanation:A table may have multiple Candidate Keys. One is chosen as the Primary Key; the remaining Candidate Keys are called Alternate Keys.
Incorrect! Try again.
25Which data type is used to store variable-length character strings?
A.CHAR
B.VARCHAR
C.INT
D.FLOAT
Correct Answer: VARCHAR
Explanation:VARCHAR stands for Variable Character. It allocates storage based on the actual length of the string inserted, unlike CHAR which is fixed-length.
Incorrect! Try again.
26Which SQL statement is used to update data in a database?
A.SAVE
B.MODIFY
C.UPDATE
D.CHANGE
Correct Answer: UPDATE
Explanation:The UPDATE statement is used to modify the existing records in a table.
Incorrect! Try again.
27Which operator is used to select values within a given range?
A.WITHIN
B.RANGE
C.BETWEEN
D.LIMIT
Correct Answer: BETWEEN
Explanation:The BETWEEN operator selects values within a given range (inclusive of the boundaries).
Incorrect! Try again.
28What is the result of the following SQL operation: SELECT 5 + NULL;?
A.5
B.
C.NULL
D.Error
Correct Answer: NULL
Explanation:In SQL, any arithmetic operation performed with NULL results in NULL.
Incorrect! Try again.
29Which command is used to take away a privilege granted to a user?
A.DELETE
B.REMOVE
C.REVOKE
D.DENY
Correct Answer: REVOKE
Explanation:REVOKE is a DCL command used to remove user access rights or privileges to the database objects.
Incorrect! Try again.
30A Composite Key is:
A.A key that contains alphanumeric characters
B.A Foreign Key that references two tables
C.A Primary Key that consists of two or more attributes
D.A key that is calculated from other columns
Correct Answer: A Primary Key that consists of two or more attributes
Explanation:When a single attribute is not sufficient to uniquely identify a row, a combination of two or more attributes is used, known as a Composite Key.
Incorrect! Try again.
31The IN operator in SQL is shorthand for:
A.Multiple AND conditions
B.Multiple OR conditions
C.A BETWEEN condition
D.A LIKE condition
Correct Answer: Multiple OR conditions
Explanation:col IN (A, B, C) is equivalent to col = A OR col = B OR col = C.
Incorrect! Try again.
32Which of the following is an example of a Domain Constraint?
A.A student ID must be unique
B.A course ID in the enrollment table must exist in the course table
C.The 'Age' column must contain an integer greater than 0
D.The Primary Key cannot be NULL
Correct Answer: The 'Age' column must contain an integer greater than 0
Explanation:Domain constraints define the valid set of values for an attribute (e.g., data type, range, format).
Incorrect! Try again.
33Which DDL command is used to remove a table's definition and all its data, indexes, triggers, constraints, and permission specifications?
A.DELETE TABLE
B.TRUNCATE TABLE
C.DROP TABLE
D.ALTER TABLE
Correct Answer: DROP TABLE
Explanation:DROP TABLE removes the table definition and all data/associated objects. TRUNCATE keeps the structure; DELETE removes rows but keeps structure.
Incorrect! Try again.
34What does the following statement do? GRANT SELECT ON Employees TO User1;
A.Allows User1 to delete rows in Employees
B.Allows User1 to read data from the Employees table
C.Allows User1 to modify the Employees table structure
D.Allows User1 to update data in Employees
Correct Answer: Allows User1 to read data from the Employees table
Explanation:GRANT SELECT provides read-only access to the specified table.
Incorrect! Try again.
35The wildcard _ (underscore) in SQL LIKE operator matches:
A.Zero or more characters
B.Exactly one character
C.Exactly two characters
D.Any numeric character
Correct Answer: Exactly one character
Explanation:The underscore wildcard represents a single character.
Incorrect! Try again.
36Which clause is used to give a temporary name to a table or a column in a query?
A.ALIAS
B.AS
C.NAME
D.RENAME
Correct Answer: AS
Explanation:The AS keyword is used to assign an alias to a column or table for the duration of the query.
Incorrect! Try again.
37The Cross Join (Cartesian Product) of a table with 5 rows and a table with 3 rows will result in a table with how many rows?
A.8
B.15
C.2
D.5
Correct Answer: 15
Explanation:A Cartesian product () combines every row of table A with every row of table B. The result size is .
Incorrect! Try again.
38Which aggregate function ignores NULL values by default?
39If you want to filter groups based on an aggregate property (e.g., departments with more than 5 employees), you must use:
A.WHERE clause
B.HAVING clause
C.ORDER BY clause
D.SELECT clause
Correct Answer: HAVING clause
Explanation:The WHERE clause filters individual rows before grouping. The HAVING clause filters groups after aggregation.
Incorrect! Try again.
40Which of the following is correct syntax to insert a new row?
A.INSERT INTO table_name VALUES (value1, value2);
B.INSERT table_name (value1, value2);
C.ADD INTO table_name VALUES (value1, value2);
D.CREATE ROW table_name VALUES (value1, value2);
Correct Answer: INSERT INTO table_name VALUES (value1, value2);
Explanation:The standard SQL syntax is INSERT INTO table_name (columns...) VALUES (values...);.
Incorrect! Try again.
41What is the effect of the ON DELETE CASCADE option in a Foreign Key constraint?
A.It prevents the deletion of a parent row if children exist.
B.It sets the foreign key to NULL if the parent is deleted.
C.It automatically deletes child rows when the corresponding parent row is deleted.
D.It throws an error when deleting the parent row.
Correct Answer: It automatically deletes child rows when the corresponding parent row is deleted.
Explanation:ON DELETE CASCADE ensures that if a record in the parent table is deleted, the corresponding records in the child table are also automatically deleted to maintain integrity.
Incorrect! Try again.
42Which keyword is used to combine the result-set of two or more SELECT statements, excluding duplicates?
A.UNION ALL
B.UNION
C.JOIN
D.MERGE
Correct Answer: UNION
Explanation:UNION combines results and removes duplicates. UNION ALL combines results including duplicates.
Incorrect! Try again.
43To change the default value of a column in an existing table, which command is generally used?
A.ALTER TABLE
B.UPDATE TABLE
C.MODIFY TABLE
D.CREATE DEFAULT
Correct Answer: ALTER TABLE
Explanation:Standard SQL uses ALTER TABLE table_name ALTER COLUMN column_name SET DEFAULT value (syntax varies slightly by DBMS, but ALTER TABLE is the command).
Incorrect! Try again.
44A Foreign Key in a table must refer to which key in the parent table?
A.Any attribute
B.Primary Key or Unique Key
C.Only the Primary Key
D.Only a Composite Key
Correct Answer: Primary Key or Unique Key
Explanation:A Foreign Key must reference a candidate key (Primary Key or Unique Key) in the parent table to ensure unambiguous identification.
Incorrect! Try again.
45Which logical operator has the highest precedence in SQL?
A.OR
B.AND
C.NOT
D.All have equal precedence
Correct Answer: NOT
Explanation:The order of precedence is usually NOT, then AND, then OR.
Incorrect! Try again.
46Which statement matches the definition: 'A query nested inside another query'?
A.Join
B.View
C.Subquery
D.Index
Correct Answer: Subquery
Explanation:A Subquery (or inner query) is a query nested inside a SELECT, INSERT, UPDATE, or DELETE statement, or inside another subquery.
Incorrect! Try again.
47Which clause is strictly necessary in a SELECT statement to retrieve data from a table?
A.WHERE
B.FROM
C.ORDER BY
D.GROUP BY
Correct Answer: FROM
Explanation:The SELECT clause specifies the columns, and the FROM clause specifies the table source. WHERE, ORDER BY, etc., are optional.
Incorrect! Try again.
48If a transaction is committed using the COMMIT command:
A.The changes are temporary.
B.The changes are saved permanently in the database.
C.The changes can be rolled back using ROLLBACK immediately after.
D.The transaction is paused.
Correct Answer: The changes are saved permanently in the database.
Explanation:COMMIT saves all changes made during the current transaction permanently. They cannot be rolled back afterwards.
Incorrect! Try again.
49Which of the following is valid syntax to remove a column named age from table Student?
A.DELETE COLUMN age FROM Student;
B.ALTER TABLE Student DROP COLUMN age;
C.DROP COLUMN age FROM Student;
D.REMOVE age FROM Student;
Correct Answer: ALTER TABLE Student DROP COLUMN age;
Explanation:Removing a column is a structural change, handled by ALTER TABLE ... DROP COLUMN ....
Incorrect! Try again.
50The set of allowed values for each attribute is called the:
A.Tuple
B.Relation
C.Domain
D.Schema
Correct Answer: Domain
Explanation:The domain defines the valid data types and range of values an attribute can hold.
Incorrect! Try again.
Give Feedback
Help us improve by sharing your thoughts or reporting issues.