Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Database & PostgreSQL Quiz

Total questions: 30

Worksheet time: 15mins

Name
Class
Date
1.

Which of the following is used to manage and interact with a database?

a)

Excel

b)

Browser

c)

DBMS

d)

HTTP

2.

Which of the following is an example of an RDBMS?

a)

MongoDB

b)

PostgreSQL

c)

Notepad

d)

JSON

3.

Which command is used to create a new database in PostgreSQL?

a)

NEW DATABASE test;

b)

MAKE DATABASE test;

c)

CREATE DATABASE test;

d)

ADD DATABASE test;

4.

What is the default port number for PostgreSQL?

a)

3306

b)

5432

c)

1521

d)

8080

5.

You cannot drop a database while:

a)

Connected to it

b)

It has no tables

c)

It is empty

d)

It is default

6.

Which data type is most suitable for storing Aadhar numbers?

a)

INT

b)

VARCHAR(10)

c)

BIGINT

d)

TEXT

7.

What does the NOT NULL constraint do?

a)

Prevents duplicate values

b)

Prevents null values

c)

Sets default values

d)

Creates a foreign key

8.

Which constraint ensures all values in a column are unique and not null?

a)

FOREIGN KEY

b)

DEFAULT

c)

PRIMARY KEY

d)

CHECK

9.

Which of the following defines a valid decimal type for storing values like 99.99?

a)

DECIMAL(5,2)

b)

DECIMAL(2,5)

c)

INTEGER

d)

VARCHAR(10)

10.

Which constraint automatically fills a column with a value when none is provided?

a)

PRIMARY KEY

b)

CHECK

c)

DEFAULT

d)

UNIQUE

11.

What does the CHECK constraint do?

a)

Makes the column unique

b)

Checks for nulls

c)

Restricts values based on a condition

d)

Prevents deletion

12.

Which of the following is a correct way to create a column with a default value?

a)

bloodgroup VARCHAR(5) DEFAULT 'O+'

b)

bloodgroup = DEFAULT O+

c)

bloodgroup TEXT PRIMARY 'O+'

d)

bloodgroup NOT NULL 'O+'

13.

Which SQL statement is used to insert data into a table?

a)

ADD INTO

b)

INSERT INTO

c)

PUT INTO

d)

APPEND

14.

Which of the following inserts 3 rows into a table correctly?

a)

One INSERT per row

b)

Use FOR loop

c)

INSERT INTO table VALUES (...), (...), (...);

d)

INSERT EACH INTO table;

15.

What does the UPDATE statement do?

a)

Deletes data

b)

Retrieves data

c)

Changes existing data

d)

Creates a table

16.

What will the following query do? DELETE FROM students;

a)

Delete selected rows

b)

Delete all rows

c)

Delete the table

d)

Nothing

17.

To change a student's marks where name is 'Ahmed', which query is correct?

a)

UPDATE student SET marks = 90 WHERE name = 'Ahmed';

b)

CHANGE marks TO 90 WHERE name = 'Ahmed';

c)

SET marks = 90 FROM student WHERE name = 'Ahmed';

d)

MODIFY student SET marks = 90;

18.

How do you switch to another database in psql?

a)

USE database_name;

b)

CONNECT database_name;

c)

\c database_name

d)

cd database_name

19.

Which operator retrieves values in a given range (inclusive)?

a)

IN

b)

BETWEEN

c)

LIKE

d)

ANY

20.

What does this query return? SELECT * FROM employee WHERE dept IN ('HR', 'IT');

a)

Employees from any department

b)

Only HR employees

c)

HR and IT employees

d)

Exclude HR and IT

21.

Which query finds names starting with 'A'?

a)

fname LIKE '%A'

b)

fname LIKE 'A%'

c)

fname = 'A%'

d)

fname IN 'A%'

22.

What does this do? SELECT * FROM students WHERE marks BETWEEN 70 AND 90;

a)

Returns students with marks above 90

b)

Returns students with marks exactly 70 or 90 only

c)

Returns students with marks 70 to 90

d)

Gives error

23.

To fetch all patients whose name ends with 'a', use:

a)

name LIKE 'a%'

b)

name LIKE '%a'

c)

name = 'a'

d)

name LIKE 'a'

24.

Which query filters rows with age not in 18, 21, 25?

a)

WHERE age NOT IN (18, 21, 25)

b)

WHERE age IN (18, 21, 25)

c)

WHERE NOT age = (18, 21, 25)

d)

WHERE age EXCEPT (18, 21, 25)

25.

Which function returns the total number of rows?

a)

SUM()

b)

MAX()

c)

COUNT()

d)

AVG()

26.

Which function calculates the average of a column?

a)

TOTAL()

b)

AVG()

c)

MEAN()

d)

MEDIAN()

27.

What does this query return? SELECT MIN(salary) FROM employee;

a)

Highest salary

b)

All salaries

c)

Minimum salary

d)

Total salaries

28.

Which query returns the total salary per department?

a)

SELECT dept, salary FROM employee;

b)

SELECT dept, SUM(salary) FROM employee GROUP BY dept;

c)

GROUP BY dept FROM employee;

d)

SELECT SUM(salary) GROUP dept FROM employee;

29.

GROUP BY clause is used to:

a)

Sort results

b)

Combine tables

c)

Group rows with same value

d)

Filter duplicate rows

30.

Which function returns the highest value in a column?

a)

MAX()

b)

MIN()

c)

COUNT()

d)

TOP()