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. Flat File Database
B. Hierarchical Database
C. Network Database
D. Object-Relational Database Management System (ORDBMS)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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. CHANGE users email = 'new@test.com' WHERE id = 5;
C. SET 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 first row.
B. It deletes all rows in the table.
C. It deletes the table structure.
D. It throws a syntax error.

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

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

27 Which PostgreSQL data type stores both date and time?

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

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

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

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

A. PRIMARY
B. UNIQUE
C. DISTINCT
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. ORDER BY column_name ASC
B. GROUP BY column_name DESC
C. SORT BY column_name DESC
D. ORDER BY column_name DESC

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

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

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. INSERT COLUMN age INTEGER INTO people;
C. ALTER people ADD age INTEGER;
D. ALTER TABLE people ADD COLUMN age INTEGER;

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

A. Describes the table structure
B. Duplicates the table
C. Deletes the table
D. Downloads 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. AND
C. OR
D. XOR

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

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

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

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

39 What does the PRIMARY KEY constraint imply?

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

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. LIMIT
B. HAVING
C. WHERE
D. FILTER

42 Which statement is used to delete an entire database?

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

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

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

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

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

45 What does the BETWEEN operator select?

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

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 ... REMOVE COLUMN ...
B. DROP COLUMN ... FROM ...
C. ALTER TABLE ... DELETE COLUMN ...
D. ALTER TABLE ... DROP COLUMN ...

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

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

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

A. Random
B. Insertion Order
C. Descending
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. @