IM QUIZ

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/20

encourage image

There's no tags or description

Looks like no tags are added yet.

21 Terms

1
New cards

4. A limitation on what can be entered in a data field within an entity/table.

NOT NULL

IDENTITY

UNIQUE

CONSTRAINT

CONSTRAINT

2
New cards

5. A university wants to assign students to courses and ensure that each student's ID exists in both the students and enrollments tables. Which SQL constraint should be applied?

CHECK

UNIQUE

INDEX

FOREIGN KEY

FOREIGN KEY

3
New cards

6. What is the main purpose of the ALTER TABLE command in SQL?

To delete data permanently from a table

To create a backup of an existing table

To retrieve specific records from a table

To modify the structure of an existing table, such as adding or changing columns

To modify the structure of an existing table, such as adding or changing columns

4
New cards

7. Which statements best define a syntax error?

Prevents a table from being created.

Prevents changes to a database from being completed.

Causes tables not to appear correctly within the database.

Causes a statement not to execute or run.

Causes a statement not to execute or run

5
New cards

8. A database administrator needs to retrieve all employees who joined the company before January 1, 2020. Which SQL query should be used?

FILTER employees WHERE hire_date < '2020‑01‑01';

SELECT * FROM employees WHERE hire_date < '2020‑01‑01';

SELECT employees FROM * WHERE hire_date = '2020‑01‑01';

SELECT * FROM employees WHERE hire_date > '2020‑01‑01';

SELECT * FROM employees WHERE hire_date < '2020‑01‑01';

6
New cards

9. Which SQL function returns the highest value in a specified column?

COUNT()

MIN()

MAX()

AVG()

MAX()

7
New cards

10. How does the PRIMARY KEY constraint differ from the UNIQUE constraint in SQL?

A PRIMARY KEY enforces uniqueness but allows NULL values, while UNIQUE does not.

A table can have multiple PRIMARY KEY constraints but only one UNIQUE constraint.

A PRIMARY KEY uniquely identifies each row and does not allow NULL values, while UNIQUE ensures distinct values but allows NULLs.

A UNIQUE constraint enforces foreign key relationships, while a PRIMARY KEY does not.

A PRIMARY KEY uniquely identifies each row and does not allow NULL values, while UNIQUE ensures distinct values but allows NULLs

8
New cards

11. Why is the FOREIGN KEY constraint important in database management?

It prevents the deletion of tables in a database

It enforces referential integrity by linking records between related tables

It speeds up the execution of queries by creating an index

It ensures that all values in a column are unique

It enforces referential integrity by linking records between related tables

9
New cards

12. Why does the AVG() function ignore NULL values in SQL calculations?

NULL values do not represent actual data, so they are excluded from calculations.

NULL values are automatically converted to zero before averaging.

SQL does not support NULL values in numeric columns.

The AVG() function replaces NULL values with the median value.

NULL values do not represent actual data, so they are excluded from calculations

10
New cards

13. A SQL keyword used to remove data or records from an entity/table.

UPDATE

ALTER TABLE

DELETE

DROP

DELETE

11
New cards

14. Why is it important to include a WHERE clause in a DELETE statement?

To allow new records to be inserted automatically

To speed up the deletion process

To prevent modifying the structure of the table

To ensure that only specific records are removed from the table

To ensure that only specific records are removed from the table

12
New cards

15. A setting that defines what kind of data can be entered in a field, such as a number, a date, or a text string.

UPDATE

DATA TYPE

CHECK

CONSTRAINT

DATA TYPE

13
New cards

16. What happens if an UPDATE statement is executed without a WHERE clause?

It generates an error

It updates only the first record

It prompts the user to specify a condition

It updates all records in the table

It updates all records in the table

14
New cards

17. Which of the following is NOT a valid SQL keyword?

MODIFY

WHERE

UPDATE

SELECT

MODIFY

15
New cards

18. What is the main purpose of the UPDATE statement in SQL?

To change the existing data in a specific column or row

To insert a new record into a table

To modify the structure of a table

To retrieve records from a database

To change the existing data in a specific column or row

16
New cards

19. Which SQL clause is used to filter records based on a specified condition?

GROUP BY

WHERE

ORDER BY

HAVING

WHERE

17
New cards

20. A company wants to give a 15 % salary increase to all employees in the IT department. Which SQL statement correctly updates the records?

CHANGE employees SET salary = salary * 1.15 WHERE department = 'IT';

UPDATE employees SET salary = salary * 1.15 WHERE department = 'IT';

ALTER employees SET salary = salary * 1.15 WHERE department = 'IT';

MODIFY employees SET salary = salary * 1.15 WHERE department = 'IT';

UPDATE employees SET salary = salary * 1.15 WHERE department = 'IT';

18
New cards

21. What does the SUM() function do in SQL?

Returns the total sum of a numeric column

Finds the highest value in a column

Combines text values from multiple rows

Counts the number of rows in a table

Returns the total sum of a numeric column

19
New cards

22. A developer wants to add a column Email to an existing Student table. Which command should be used?

ALTER TABLE Student ADD COLUMN Email VARCHAR(50);

ALTER TABLE Student INSERT COLUMN Email VARCHAR(50);

ALTER TABLE Student ADD Email VARCHAR(50);

ALTER TABLE Student ALTER COLUMN Email VARCHAR(50);

ALTER TABLE Student ADD Email VARCHAR(50);

20
New cards

23. What is the key difference between the DATENAME() and DATEPART() functions in SQL?

DATEPART() extracts only the year from a date, while DATENAME() extracts the entire date.

DATENAME() returns the numeric value of a date component, while DATEPART() returns the string name of a date component.

DATENAME() returns the textual representation of a date part (e.g. "January"), while DATEPART() returns a numeric value (e.g. 1 for January).

DATEPART() and DATENAME() function identically and can be used interchangeably.

DATENAME() returns the textual representation of a date part (e.g., "January"), while DATEPART() returns a numeric value (e.g., 1 for January)

21
New cards

24. Which category of SQL statements is responsible for defining database structures and constraints?

Transaction Control Language (TCL)

Data Definition Language (DDL)

Data Manipulation Language (DML)

Data Control Language (DCL)

Data Definition Language (DDL)