
- What is PostgreSQL?
a) A programming language
b) A relational database management system
c) A web framework
Answer: b) A relational database management system
- Which of the following is not a data type in PostgreSQL?
a) VARCHAR
b) INTEGER
c) DECIMAL
d) CHARACTER
Answer: d) CHARACTER
- 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
- Which command is used to connect to a database in PostgreSQL?
a) CONNECT TO
b) ATTACH TO
c) USE
d) \c
Answer: d) \c
- What is the default port for PostgreSQL?
a) 80
b) 3306
c) 5432
d) 8080
Answer: c) 5432
- Which of the following is not a valid indexing method in PostgreSQL?
a) B-tree
b) Hash
c) Inverted
d) GiST
Answer: c) Inverted
- Which operator is used for string concatenation in PostgreSQL?
a) ||
b) +
c) &
d) ~
Answer: a) ||
- Which command is used to backup a PostgreSQL database?
a) COPY
b) EXPORT
c) DUMP
d) BACKUP
Answer: c) DUMP
- 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
- Which command is used to modify existing data in a table in PostgreSQL?
a) UPDATE
b) INSERT
c) ALTER
d) DELETE
Answer: a) UPDATE
- 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()
- Which statement is used to grant privileges in PostgreSQL?
a) ALLOW
b) PERMIT
c) GRANT
d) AUTHENTICATE
Answer: c) GRANT
- Which statement is used to revoke privileges in PostgreSQL?
a) REMOVE
b) REVOKE
c) DENY
d) DISALLOW
Answer: b) REVOKE
- 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
- 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
- Which of the following is not a valid data manipulation statement in PostgreSQL?
a) SELECT
b) INSERT
c) UPDATE
d) DELETE
Answer: d) DELETE
- Which of the following is not a valid built-in function in PostgreSQL?
a) LENGTH
b) MAXIMUM
c) SUM
d) COUNT
Answer: b) MAXIMUM
- 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
- 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
- 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
- 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
- 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
- Which of the following is not a valid privilege in PostgreSQL?
a) SELECT
b) INSERT
c) UPDATE
d) READ
Answer: d) READ
- 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
- 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
- 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
- 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
- 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
- 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
- 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()
- 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
- 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
- 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)
- 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
- Which of the following is not a valid aggregate function in PostgreSQL?
a) SUM
b) COUNT
c) AVG
d) PRODUCT
Answer: d) PRODUCT
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- Which function is used to return the substring of a string in PostgreSQL?
a) SUBSTRING()
b) MID()
c) LEFT()
d) RIGHT()
Answer: a) SUBSTRING()
- 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
- Which statement is used to commit a transaction in PostgreSQL?
a) END TRANSACTION
b) CLOSE TRANSACTION
c) COMMIT
d) FINISH TRANSACTION
Answer: c) COMMIT
- 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()
- 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
Latest posts by Ashwani Kumar (see all)
- Top 10 DevOps Trainers in the world - October 7, 2023
- What is Cookies and Why it is Used? - May 24, 2023
- TOP trends of transitions in TikTok - May 10, 2023