PostgreSQL Objective Questions & Answers for Beginners Set-1
1. What command is used to create a new PostgreSQL database?
Explanation: The correct command to create a new PostgreSQL database is "CREATE DATABASE mydatabase;". The "CREATE DB" option (A) is not the correct syntax. Options C and D are not valid PostgreSQL commands for creating databases.
2. Which PostgreSQL data type is used to store whole numbers?
Explanation: The "INT" data type is used to store whole numbers in PostgreSQL. Float (B) is used for floating-point numbers, Numeric (C) is used for arbitrary precision numbers, and Text (D) is used for text data.
3. In PostgreSQL, what does the term "primary key" refer to?
Explanation: A primary key is a column or set of columns in a table that uniquely identifies each row. It ensures that each row in the table has a unique value and enforces data integrity.
4. Which SQL command is used to retrieve data from a PostgreSQL table?
Explanation: The "SELECT" command is used to retrieve data from a PostgreSQL table. It allows you to specify which columns to retrieve and can also include conditions, joins, and sorting
5. What is the purpose of the "WHERE" clause in a SQL query?
Explanation: The "WHERE" clause is used to filter rows based on specified conditions. It allows you to retrieve only the rows that meet certain criteria.
6. What is the default port number for PostgreSQL?
Explanation: The default port number for PostgreSQL is 5432. This is the port that PostgreSQL listens on for incoming connections.
7. What does the acronym "SQL" stand for?
Explanation: SQL stands for "Structured Query Language." It is a domain-specific language used for managing and querying relational databases.
8. Which SQL command is used to insert data into a PostgreSQL table?
Explanation: The "INSERT INTO" command is used to insert data into a PostgreSQL table. It specifies the table name and values to be inserted into the columns.
9. What is a "foreign key" in a PostgreSQL table?
Explanation: A foreign key is a column or a set of columns in a table that refers to the primary key of another table. It establishes a link between two tables based on their data.
10. Which SQL command is used to update data in a PostgreSQL table?
Explanation: The "UPDATE" command is used to modify existing data in a PostgreSQL table. It allows you to change values in specific columns based on specified conditions.
11. What does "ACID" stand for in the context of database transactions?
Explanation: "ACID" is an acronym that represents the properties of a reliable database transaction: Atomicity, Consistency, Isolation, and Durability.
12. What is the purpose of the "GROUP BY" clause in a SQL query?
Explanation: The "GROUP BY" clause is used to group rows together based on the values in specified columns. It is often used in combination with aggregate functions like SUM, AVG, COUNT, etc.
13. What is the role of the "HAVING" clause in a SQL query?
Explanation: The "HAVING" clause is used to filter rows that have been grouped together using the "GROUP BY" clause. It operates on the aggregated values of the grouped data.
14. In PostgreSQL, what is the purpose of an index?
Explanation: An index in PostgreSQL is a database object that improves the speed of data retrieval operations on a table by providing a faster way to look up rows based on column values.
15. What is the purpose of the "ORDER BY" clause in a SQL query?
Explanation: The "ORDER BY" clause is used to sort the retrieved rows in either ascending (default) or descending order based on specified columns.
Related content
Rate Your Experience
: 89
: 1