Unit 5 - Practice Quiz

INT222 50 Questions
0 Correct 0 Wrong 50 Left
0/50

1 What type of database management system is PostgreSQL classified as?

A. Object-Relational Database Management System (ORDBMS)
B. Network Database
C. Flat File Database
D. Hierarchical Database

2 Which mechanism does PostgreSQL use to handle concurrency without read locks blocking write locks?

A. Optimistic Locking
B. Two-Phase Locking
C. Table Locking
D. MVCC (Multi-Version Concurrency Control)

3 What is the default TCP port that PostgreSQL listens on?

A. 1521
B. 3306
C. 5432
D. 8080

4 What is the name of the interactive terminal-based command-line tool for PostgreSQL?

A. pg_terminal
B. psql
C. sqlcmd
D. pgAdmin

5 Which configuration file is primarily responsible for controlling client authentication in PostgreSQL?

A. config.json
B. postgresql.conf
C. pg_hba.conf
D. pg_ident.conf

6 What is the default superuser account created during PostgreSQL installation?

A. postgres
B. sa
C. admin
D. root

7 Which command inside the psql interface is used to list all databases?

A. \l
B. SHOW DATABASES;
C. Both A and B
D. \list

8 Which data type in PostgreSQL is best suited for storing JSON data with indexing capabilities?

A. TEXT
B. JSON
C. JSONB
D. VARCHAR

9 Which SQL statement is used to create a new database in PostgreSQL?

A. INIT DATABASE name;
B. NEW DATABASE name;
C. MAKE DATABASE name;
D. CREATE DATABASE name;

10 What does the acronym WAL stand for in the context of PostgreSQL architecture?

A. Wide-Area Latency
B. Write-Ahead Logging
C. Write-After Log
D. Web Application Layer

11 Which command allows you to connect to a specific database from within the psql prompt?

A. \connect dbname
B. \c dbname
C. Both A and B
D. \use dbname

12 To remove a table and all its data from the database, which command is used?

A. ERASE TABLE
B. REMOVE TABLE
C. DROP TABLE
D. DELETE TABLE

13 Which PostgreSQL data type is an auto-incrementing integer typically used for primary keys?

A. SERIAL
B. AUTO_INT
C. INT
D. NUMERIC

14 What is the purpose of the 'TRUNCATE' command?

A. To drop the table structure
B. To delete all rows quickly without logging individual row deletions
C. To delete specific rows based on a condition
D. To minify the database size

15 Which constraint ensures that a column cannot contain NULL values?

A. UNIQUE
B. NOT NULL
C. CHECK
D. PRIMARY KEY

16 How do you rename an existing table 'users' to 'customers' in PostgreSQL?

A. RENAME TABLE users TO customers;
B. MODIFY TABLE users RENAME customers;
C. ALTER TABLE users RENAME TO customers;
D. UPDATE TABLE users SET NAME = customers;

17 Which operator is used for pattern matching with wildcards in a WHERE clause?

A. =
B. LIKE
C. SAME
D. MATCH

18 In the context of the LIKE operator, what does the '%' wildcard represent?

A. A NULL value
B. A numeric digit
C. Exactly one character
D. Zero or more characters

19 Which SQL clause is used to filter records that meet a specified condition?

A. HAVING
B. GROUP BY
C. WHERE
D. ORDER BY

20 What is the correct syntax to insert a new record into the 'students' table?

A. INSERT students SET id=1, name='John';
B. UPDATE students ADD (1, 'John');
C. ADD TO students VALUES (1, 'John');
D. INSERT INTO students (id, name) VALUES (1, 'John');

21 How can you retrieve all columns from the 'employees' table?

A. SELECT * FROM employees;
B. GET * FROM employees;
C. SELECT ALL FROM employees;
D. FETCH employees;

22 Which clause allows you to limit the number of rows returned by a query?

A. TOP
B. LIMIT
C. STOP
D. ROWNUM

23 Which command allows you to skip a specific number of rows before returning the result set?

A. JUMP
B. NEXT
C. SKIP
D. OFFSET

24 What is the correct syntax to update the email of a user with id 5?

A. MODIFY users SET email = 'new@test.com' WHERE id = 5;
B. SET users.email = 'new@test.com' WHERE id = 5;
C. CHANGE users email = 'new@test.com' WHERE id = 5;
D. UPDATE users SET email = 'new@test.com' WHERE id = 5;

25 What happens if you run a DELETE FROM table_name command without a WHERE clause?

A. It deletes the table structure.
B. It throws a syntax error.
C. It deletes the first row.
D. It deletes all rows in the table.

26 Which keyword is used to return data immediately after an INSERT, UPDATE, or DELETE operation in PostgreSQL?

A. RETURN
B. RETURNING
C. OUTPUT
D. BACK

27 Which PostgreSQL data type stores both date and time?

A. DATETIME
B. DATE
C. TIME
D. TIMESTAMP

28 Which command is used to modify the structure of an existing table, such as adding a column?

A. MODIFY TABLE
B. ALTER TABLE
C. UPDATE TABLE
D. CHANGE TABLE

29 To ensure a column's value is unique across the entire table, which constraint should be used?

A. DISTINCT
B. PRIMARY
C. UNIQUE
D. SINGLE

30 Which operator is used to combine string values in PostgreSQL?

A. ||
B. CONCAT()
C. &
D. +

31 How do you sort the result set in descending order?

A. SORT BY column_name DESC
B. ORDER BY column_name ASC
C. ORDER BY column_name DESC
D. GROUP BY column_name DESC

32 Which function is used to count the number of rows in a selection?

A. ADD()
B. TOTAL()
C. COUNT()
D. SUM()

33 What is the purpose of the DISTINCT keyword in a SELECT statement?

A. To sort results
B. To filter null values
C. To limit results
D. To remove duplicate values from the result set

34 Which of the following is a correct command to add a new column 'age' of type integer to table 'people'?

A. UPDATE TABLE people ADD age INTEGER;
B. ALTER TABLE people ADD COLUMN age INTEGER;
C. ALTER people ADD age INTEGER;
D. INSERT COLUMN age INTEGER INTO people;

35 What does the psql command '\d table_name' do?

A. Describes the table structure
B. Duplicates the table
C. Downloads the table
D. Deletes the table

36 Which logical operator is used to display a record if any of the conditions separated by it are true?

A. NOT
B. XOR
C. OR
D. AND

37 How do you check for a NULL value in a WHERE clause?

A. EQUALS NULL
B. = NULL
C. == NULL
D. IS NULL

38 Which PostgreSQL tool is a popular open-source GUI for database management?

A. phpMyAdmin
B. Workbench
C. Compass
D. pgAdmin

39 What does the PRIMARY KEY constraint imply?

A. Both UNIQUE and NOT NULL
B. UNIQUE only
C. NOT NULL only
D. Just an index

40 Which command allows you to quit the psql terminal?

A. exit
B. \q
C. quit
D. logout

41 Which clause is used to filter groups of rows created by GROUP BY?

A. HAVING
B. FILTER
C. WHERE
D. LIMIT

42 Which statement is used to delete an entire database?

A. REMOVE DATABASE name;
B. DROP DATABASE name;
C. TRUNCATE DATABASE name;
D. DELETE DATABASE name;

43 What is the purpose of the 'IN' operator?

A. To specify multiple possible values for a column
B. To check for NULL
C. To specify a range
D. To search text patterns

44 Which data type would be most appropriate for a True/False value?

A. INT
B. BOOLEAN
C. BINARY
D. VARCHAR(1)

45 What does the BETWEEN operator select?

A. Values that match a list
B. Values that are distinct
C. Values within a given range
D. Values that are null

46 To create a foreign key, which table is modified?

A. Both tables
B. The system table
C. The child table
D. The parent table

47 Which command is used to remove a specific column from a table?

A. ALTER TABLE ... DELETE COLUMN ...
B. ALTER TABLE ... DROP COLUMN ...
C. DROP COLUMN ... FROM ...
D. ALTER TABLE ... REMOVE COLUMN ...

48 Which basic SQL command is NOT part of CRUD operations?

A. UPDATE
B. CREATE
C. INSERT
D. SELECT

49 What is the default sort order if ASC or DESC is not specified in ORDER BY?

A. Descending
B. Random
C. Insertion Order
D. Ascending

50 Which character is used to denote a parameter/variable placeholder in a prepared statement in psql (e.g., $1, $2)?

A. $
B. ?
C. :
D. @