WorksheetsMastering SQL Basics
Total questions: 20
Worksheet time: 7hrs 40mins
What SQL command is used to create a new table?
INSERT TABLE
MODIFY TABLE
CREATE TABLE
ADD TABLE
How do you delete a record from a table in SQL?
DELETE FROM table_name WHERE condition;
REMOVE FROM table_name WHERE condition;
DELETE table_name WHERE condition;
DROP table_name WHERE condition;
Which SQL statement is used to insert new data into a table?
ADD TO
REPLACE INTO
UPDATE SET
INSERT INTO
What is the purpose of the UPDATE statement in SQL?
To delete records from a table.
To create new tables in a database.
To retrieve data from a table.
To modify existing records in a table.
Which function would you use to count the number of rows in a table?
COUNT(*)
TOTAL(*)
ROWS(*)
SUM(*)
How do you retrieve all columns from a table named 'employees'?
FETCH * FROM employees;
GET * FROM employees;
SELECT * FROM employees;
SELECT all FROM employees;
What SQL command is used to remove a table from a database?
DROP TABLE
CLEAR TABLE
REMOVE TABLE
DELETE TABLE
How can you change the value of a specific column in a table?
Apply the command: INSERT INTO table_name (column_name) VALUES (new_value);
Use the SQL command: UPDATE table_name SET column_name = new_value WHERE condition;
Execute the command: DELETE FROM table_name WHERE condition;
Use the SQL command: SELECT column_name FROM table_name WHERE condition;
What is the syntax for using the AVG function in SQL?
SELECT SUM(column_name) FROM table_name;
SELECT COUNT(column_name) FROM table_name;
SELECT MAX(column_name) FROM table_name;
SELECT AVG(column_name) FROM table_name;
How do you select unique values from a column in SQL?
SELECT DIFFERENT column_name FROM table_name;
SELECT DISTINCT column_name FROM table_name;
SELECT UNIQUE column_name FROM table_name;
SELECT ONLY column_name FROM table_name;
What SQL clause is used to filter records?
SELECT
GROUP BY
HAVING
WHERE
Which SQL function would you use to find the maximum value in a column?
COUNT()
MAX()
SUM()
AVG()
How do you add a new column to an existing table?
DROP COLUMN new_column_name FROM table_name;
CREATE TABLE new_table_name AS SELECT * FROM table_name;
UPDATE table_name SET new_column_name = value;
ALTER TABLE table_name ADD COLUMN new_column_name data_type;
What is the purpose of the GROUP BY clause in SQL?
To sort rows based on specified column values.
To filter rows that meet certain criteria.
To join multiple tables into a single result set.
To group rows that have the same values in specified columns and perform aggregate calculations on them.
How can you sort the results of a query in SQL?
Apply the FILTER BY clause in your SQL statement.
Use the GROUP BY clause in your SQL query.
Use the ORDER BY clause in your SQL query.
Sort results using the SELECT clause in SQL.
What is the primary purpose of a key in a database?
To improve the performance of queries.
To create relationships between tables.
To uniquely identify records in a table.
To store large amounts of data.
Which type of key is used to enforce uniqueness for a column in a database?
Foreign Key
Composite Key
Primary Key
Candidate Key
How do you define a foreign key in SQL?
By using the INDEX command on a column.
By using the FOREIGN KEY constraint referencing another table.
By using the UNIQUE constraint on a column.
By using the PRIMARY KEY constraint on a column.
Which of the following statements is true about primary keys?
A primary key can contain NULL values.
A primary key is optional for every table.
A primary key must be unique for each record in a table.
A primary key can be duplicated across different tables.
How do you define a unique key in SQL?
By using the PRIMARY KEY constraint on a column.
By using the FOREIGN KEY constraint referencing another table.
By using the INDEX command on a column.
By using the UNIQUE constraint on a column.
