MOTOSHARE 🚗🏍️

Rent Bikes & Cars Directly from Owners

Motoshare connects vehicle owners with people who need bikes and cars on rent. Owners earn from idle vehicles, and renters get flexible ride options.

Visit Motoshare

Top 50 Postgresql Interview Questions with Answers

Uncategorized
Postgresql Interview Questions with Answers
  1. What is PostgreSQL?
    a) A programming language
    b) A relational database management system
    c) A web framework

Answer: b) A relational database management system

  1. Which of the following is not a data type in PostgreSQL?
    a) VARCHAR
    b) INTEGER
    c) DECIMAL
    d) CHARACTER

Answer: d) CHARACTER

  1. Which command is used to create a database in PostgreSQL?
    a) CREATE DATABASE
    b) NEW DATABASE
    c) ADD DATABASE
    d) MAKE DATABASE

Answer: a) CREATE DATABASE

  1. Which command is used to connect to a database in PostgreSQL?
    a) CONNECT TO
    b) ATTACH TO
    c) USE
    d) \c

Answer: d) \c

  1. What is the default port for PostgreSQL?
    a) 80
    b) 3306
    c) 5432
    d) 8080

Answer: c) 5432

  1. Which of the following is not a valid indexing method in PostgreSQL?
    a) B-tree
    b) Hash
    c) Inverted
    d) GiST

Answer: c) Inverted

  1. Which operator is used for string concatenation in PostgreSQL?
    a) ||
    b) +
    c) &
    d) ~

Answer: a) ||

  1. Which command is used to backup a PostgreSQL database?
    a) COPY
    b) EXPORT
    c) DUMP
    d) BACKUP

Answer: c) DUMP

  1. Which of the following is not a valid join type in PostgreSQL?
    a) INNER JOIN
    b) LEFT JOIN
    c) RIGHT JOIN
    d) CROSS JOIN

Answer: d) CROSS JOIN

  1. Which command is used to modify existing data in a table in PostgreSQL?
    a) UPDATE
    b) INSERT
    c) ALTER
    d) DELETE

Answer: a) UPDATE

  1. Which function is used to return the current date and time in PostgreSQL?
    a) NOW()
    b) DATE()
    c) TIME()
    d) CURRENT_TIMESTAMP()

Answer: a) NOW()

  1. Which statement is used to grant privileges in PostgreSQL?
    a) ALLOW
    b) PERMIT
    c) GRANT
    d) AUTHENTICATE

Answer: c) GRANT

  1. Which statement is used to revoke privileges in PostgreSQL?
    a) REMOVE
    b) REVOKE
    c) DENY
    d) DISALLOW

Answer: b) REVOKE

  1. Which of the following is not a valid constraint type in PostgreSQL?
    a) PRIMARY KEY
    b) FOREIGN KEY
    c) UNIQUE
    d) CHECK

Answer: b) FOREIGN KEY

  1. Which statement is used to add a new column to an existing table in PostgreSQL?
    a) ALTER TABLE
    b) MODIFY TABLE
    c) ADD COLUMN
    d) CREATE COLUMN

Answer: c) ADD COLUMN

  1. Which of the following is not a valid data manipulation statement in PostgreSQL?
    a) SELECT
    b) INSERT
    c) UPDATE
    d) DELETE

Answer: d) DELETE

  1. Which of the following is not a valid built-in function in PostgreSQL?
    a) LENGTH
    b) MAXIMUM
    c) SUM
    d) COUNT

Answer: b) MAXIMUM

  1. Which statement is used to create a table in PostgreSQL?
    a) CREATE TABLE
    b) ADD TABLE
    c) NEW TABLE
    d) MAKE TABLE

Answer: a) CREATE TABLE

  1. Which of the following is not a valid transaction isolation level in PostgreSQL?
    a) READ COMMITTED
    b) REPEATABLE READ
    c) SERIALIZABLE
    d) READ UNCOMMITTED

Answer: d) READ UNCOMMITTED

  1. Which statement is used to remove a table from a database in PostgreSQL?
    a) DELETE TABLE
    b) DROP TABLE
    c) REMOVE TABLE
    d) ERASE TABLE

Answer: b) DROP TABLE

  1. Which of the following is not a valid way to specify a connection string in PostgreSQL?
    a) host=localhost port=5432 dbname=mydb user=myuser password=mypassword
    b) postgresql://myuser:mypassword@localhost:5432/mydb
    c) user=myuser password=mypassword host=localhost port=5432 dbname=mydb
    d) None of the above

Answer: d) None of the above

  1. Which statement is used to truncate a table in PostgreSQL?
    a) DELETE FROM
    b) TRUNCATE TABLE
    c) DROP TABLE
    d) REMOVE TABLE

Answer: b) TRUNCATE TABLE

  1. Which of the following is not a valid privilege in PostgreSQL?
    a) SELECT
    b) INSERT
    c) UPDATE
    d) READ

Answer: d) READ

  1. Which statement is used to create an index in PostgreSQL?
    a) CREATE INDEX
    b) ADD INDEX
    c) NEW INDEX
    d) MAKE INDEX

Answer: a) CREATE INDEX

  1. Which of the following is not a valid data type for a column in PostgreSQL?
    a) BOOLEAN
    b) FLOAT
    c) REAL
    d) DOUBLE PRECISION

Answer: b) FLOAT

  1. Which statement is used to insert data into a table in PostgreSQL?
    a) ADD INTO
    b) INSERT INTO
    c) PUT INTO
    d) CREATE INTO

Answer: b) INSERT INTO

  1. Which command is used to grant privileges to a role in PostgreSQL?
    a) ALTER ROLE
    b) GRANT
    c) ALTER PRIVILEGES
    d) ALLOW

Answer: b) GRANT

  1. Which statement is used to change the data type of a column in PostgreSQL?
    a) ALTER TYPE
    b) ALTER TABLE
    c) CHANGE COLUMN
    d) MODIFY COLUMN

Answer: d) MODIFY COLUMN

  1. Which command is used to create a sequence in PostgreSQL?
    a) CREATE SEQUENCE
    b) ADD SEQUENCE
    c) NEW SEQUENCE
    d) MAKE SEQUENCE

Answer: a) CREATE SEQUENCE

  1. Which function is used to calculate the length of a string in PostgreSQL?
    a) LENGTH()
    b) SIZE()
    c) CHAR_LENGTH()
    d) BYTE_LENGTH()

Answer: a) LENGTH()

  1. Which of the following is not a valid way to specify a schema name in PostgreSQL?
    a) public.mytable
    b) myschema.mytable
    c) table.mytable
    d) mytable.mytable

Answer: c) table.mytable

  1. Which statement is used to rename a table in PostgreSQL?
    a) ALTER TABLE
    b) RENAME TABLE
    c) MODIFY TABLE
    d) CHANGE TABLE

Answer: b) RENAME TABLE

  1. Which of the following is not a valid way to specify a foreign key in PostgreSQL?
    a) FOREIGN KEY (column_name) REFERENCES table_name (column_name)
    b) column_name REFERENCES table_name (column_name)
    c) column_name FOREIGN KEY REFERENCES table_name (column_name)
    d) CONSTRAINT constraint_name FOREIGN KEY (column_name) REFERENCES table_name (column_name)

Answer: b) column_name REFERENCES table_name (column_name)

  1. Which statement is used to delete a row from a table in PostgreSQL based on a condition?
    a) DELETE
    b) REMOVE
    c) ERASE
    d) DROP

Answer: a) DELETE

  1. Which of the following is not a valid aggregate function in PostgreSQL?
    a) SUM
    b) COUNT
    c) AVG
    d) PRODUCT

Answer: d) PRODUCT

  1. Which statement is used to create a view in PostgreSQL?
    a) CREATE VIEW
    b) ADD VIEW
    c) NEW VIEW
    d) MAKE VIEW

Answer: a) CREATE VIEW

  1. Which command is used to create a user in PostgreSQL?
    a) CREATE USER
    b) ADD USER
    c) NEW USER
    d) MAKE USER

Answer: a) CREATE USER

  1. Which of the following is not a valid way to specify a default value for a column in PostgreSQL?
    a) DEFAULT ‘value’
    b) DEFAULT (expression)
    c) DEFAULT NOW()
    d) DEFAULT 0.0

Answer: d) DEFAULT 0.0

  1. Which statement is used to add a new constraint to an existing table in PostgreSQL?
    a) ADD CONSTRAINT
    b) CREATE CONSTRAINT
    c) NEW CONSTRAINT
    d) MAKE CONSTRAINT

Answer: a) ADD CONSTRAINT

  1. Which of the following is not a valid data type for an index in PostgreSQL?
    a) B-tree
    b) Hash
    c) GIN
    d) SET

Answer: d) SET

  1. Which statement is used to create a trigger in PostgreSQL?
    a) CREATE TRIGGER
    b) ADD TRIGGER
    c) NEW TRIGGER
    d) MAKE TRIGGER

Answer: a) CREATE TRIGGER

  1. Which of the following is not a valid way to specify a column constraint in PostgreSQL?
    a) PRIMARY KEY
    b) FOREIGN KEY
    c) CHECK
    d) INDEX

Answer: d) INDEX

  1. Which statement is used to update multiple rows in a table in PostgreSQL based on a condition?
    a) UPDATE ALL
    b) UPDATE
    c) MODIFY
    d) CHANGE

Answer: b) UPDATE

  1. Which of the following is not a valid way to specify a column alias in PostgreSQL?
    a) column_name AS alias_name
    b) column_name alias_name
    c) “column_name” alias_name
    d) None of the above

Answer: b) column_name alias_name

  1. Which statement is used to create a temporary table in PostgreSQL?
    a) CREATE TABLE
    b) ADD TABLE
    c) NEW TABLE
    d) CREATE TEMPORARY TABLE

Answer: d) CREATE TEMPORARY TABLE

  1. Which function is used to return the substring of a string in PostgreSQL?
    a) SUBSTRING()
    b) MID()
    c) LEFT()
    d) RIGHT()

Answer: a) SUBSTRING()

  1. Which of the following is not a valid way to specify a table alias in PostgreSQL?
    a) table_name AS alias_name
    b) table_name alias_name
    c) “table_name” alias_name
    d) None of the above

Answer: b) table_name alias_name

  1. Which statement is used to commit a transaction in PostgreSQL?
    a) END TRANSACTION
    b) CLOSE TRANSACTION
    c) COMMIT
    d) FINISH TRANSACTION

Answer: c) COMMIT

  1. Which function is used to return the position of a substring in a string in PostgreSQL?
    a) POSITION()
    b) LOCATE()
    c) FIND()
    d) SEARCH()

Answer: a) POSITION()

  1. Which of the following is not a valid way to specify a column in PostgreSQL?
    a) table_name.column_name
    b) column_name
    c) column_name AS alias_name
    d) None of the above

Answer: c) column_name AS alias_name

Ashwani Kumar
Latest posts by Ashwani Kumar (see all)
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
0
Would love your thoughts, please comment.x
()
x