Font size
WorksheetsSQL QUIZ
Total questions: 25
Worksheet time: 15mins
Which clause filters rows in SQL?
SELECT
FROM
WHERE
GROUP BY
Which SQL command is used to retrieve data from a database?
SELECT
FROM
WHERE
GROUP BY
Which of the following is NOT a string data type in MySQL?
VARCHAR
TEXT
TIMESTAMP
CHAR
A floating point number can be defined using FLOAT or ______
INT
DOUBLE
REAL
NUMERIC
Data Type that has FIXED length string (can contain letters, numbers, and special characters). The size parameter specifies the column length in characters - can be from 0 to 255. Default is 1
BINARY(size)
VARBINARY(size)
CHAR(size)
VARCHAR(size)
Data Type considered as a medium integer. Signed range is from -2147483648 to 2147483647. Unsigned range is from 0 to 4294967295. The size parameter specifies the maximum display width (which is 255)
SMALLINT(size)
MEDIUMINT(size)
INT(size)
INTEGER(size)
What does the SQL LEFT JOIN keyword do?
Returns only matching records from both tables
Returns all records from the left table and matching records form the right table
Returns all records from the right table and matching records form the left table
Returns all records from both tables
With SQL, how do you select all the records from a table named "Persons" where the value of the column "FirstName" starts with an "a"?
SELECT * FROM Persons WHERE FirstName LIKE '%a'
SELECT * FROM Persons WHERE FirstName = '%a%'
SELECT * FROM Persons WHERE FirstName = 'a'
SELECT * FROM Persons WHERE FirstName LIKE 'a%'
How can you change "Hansen" into "Nilsen" in the "LastName" column in the Persons table?
UPDATE Persons SET LastName='Nilsen' WHERE LastName='Hansen'
UPDATE Persons SET LastName='Hansen' WHERE LastName='Nilsen'
UPDATE Persons SET LastName='Nilsen' WHERE LastName='Nilsen'
UPDATE Persons SET LastName='Nilsen' WHERE LastName<>'Hansen'
Which SQL statement uses the ANY operator correctly?
SELECT * FROM Products WHERE ProductID ANY (SELECT ProductID FROM OrderDetails);
SELECT * FROM Products WHERE ProductID = ANY (SELECT ProductID FROM OrderDetails);
SELECT ProductName ANY (SELECT ProductID FROM OrderDetails WHERE Quantity > 10);
SELECT * FROM Products WHERE ANY ProductID IN (SELECT ProductID FROM OrderDetails);
Fill the blank in a query to find employees with no department assigned.
SELECT * FROM employees WHERE department_id IS (a) ;
Fill the blank in a query to find employees with salary greater than 8752.
SELECT * FROM (a) WHERE salary > 8752;
Fill the blank in a query to join employees and departments on department_id.
SELECT e.employee_id, e.name, d.department_name
FROM employees e
_____ ____ departments d ON e.department_id = d.department_id;
(a)
______ _____ is used to create and retrieve data from the database very quickly
(a)
Fill in the The following SQL statement that adds an "Email" column to the "Customers" table:
(a) TABLE Customers
ADD Email varchar(255);
SQL Logical Operators that returns a value where operand matches a pattern
(a)
The SQL (a) clause is used to filter the results of a GROUP BY query based on the result of an aggregate function. It is similar to the WHERE clause but is specifically applied after grouping and aggregation, allowing you to filter on the results of aggregate functions like COUNT, SUM, AVG, and others.
Aggregate functions ignore null values (except for (a) (*)).
Write the correct SQL statement to create a new database called bookRef.
(a)
Write the correct SQL statement to drop a new database called bookArchive.
(a)
The NOT NULL constraint enforces a column to accept NULL values.
TRUE
FALSE
The OR operator displays a record if ANY conditions listed are true. The AND operator displays a record if ALL of the conditions listed are true
TRUE
FALSE
DATE data type correct format in SQL Server is YYYY-MM-DD
TRUE
FALSE
A differential back up only backs up the parts of the database that have changed since the last full database backup.
TRUE
FALSE
In MySQL, by default, the starting value for AUTO_INCREMENT is 1, and it will increment by 1 for each new record.
TRUE
FALSE
