InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
Differentiate between commit and checkpoint. |
|
Answer» The commit action ensures that the DATA CONSISTENCY of the transaction is maintained and it ends the current transaction in the section. Commit adds a new record in the log that describes the COMMIT to the memory. Whereas, a checkpoint is used for writing all changes that were committed to disk up to SCN which would be kept in datafile headers and control files. Conclusion:SQL is a language for the database. It has a vast scope and robust capability of creating and manipulating a variety of database objects using commands like CREATE, ALTER, DROP, ETC, and also in loading the database objects using commands like INSERT. It also provides options for Data Manipulation using commands like DELETE, TRUNCATE and also does effective retrieval of data using cursor commands like FETCH, SELECT, etc. There are many such commands which provide a large amount of control to the PROGRAMMER to interact with the database in an efficient way without wasting many resources. The popularity of SQL has grown so much that almost every programmer relies on this to implement their application's storage functionalities thereby making it an exciting language to learn. Learning this provides the developer a benefit of understanding the data structures used for storing the organization's data and giving an additional level of control and in-depth understanding of the application. PostgreSQL being an open-source database system having extremely robust and sophisticated ACID, Indexing, and Transaction supports has found widespread popularity among the developer community. References and Resources: SQL Server Interview Questions MySQL Interview Questions DBMS Interview Questions PL SQL Interview Questions MongoDB Interview Questions SQL Vs MySQL PostgreSQL vs MySQL Difference Between SQL and PLSQL SQL Vs NoSQL SQL IDE SQL Projects |
|
| 2. |
What are parallel queries in PostgreSQL? |
|
Answer» PARALLEL Queries support is a FEATURE provided in PostgreSQL for devising query plans CAPABLE of exploiting MULTIPLE CPU processors to execute the queries faster. |
|
| 3. |
Does PostgreSQL support full text search? |
|
Answer» Full-Text Search is the METHOD of searching single or collection of documents stored on a computer in a full-text based database. This is mostly supported in advanced database systems like SOLR or ELASTICSEARCH. However, the FEATURE is PRESENT but is PRETTY basic in PostgreSQL. |
|
| 4. |
How will you take backup of the database in PostgreSQL? |
|
Answer» We can ACHIEVE this by using the pg_dump tool for DUMPING all object CONTENTS in the database into a single file. The steps are as follows: Step 1: Navigate to the bin folder of the PostgreSQL installation path. C:\>cd C:\Program Files\PostgreSQL\10.0\binStep 2: EXECUTE pg_dump program to TAKE the dump of data to a .tar folder as shown below: pg_dump -U postgres -W -F t sample_data > C:\Users\admin\pgbackup\sample_data.tarThe database dump will be stored in the sample_data.tar file on the location specified. |
|
| 5. |
How do you perform case-insensitive searches using regular expressions in PostgreSQL? |
|
Answer» To PERFORM CASE INSENSITIVE matches using a regular expression, we can use POSIX (~*) expression from pattern matching OPERATORS. For EXAMPLE: 'interviewbit' ~* '.*INTervIewBit.*' |
|
| 6. |
What is the main disadvantage of deleting data from an existing table using the DROP TABLE command? |
|
Answer» DROP TABLE command deletes complete data from the table along with removing the complete table structure too. In CASE our requirement entails just remove the data, then we would NEED to RECREATE the table to store data in it. In such CASES, it is advised to use the TRUNCATE command. |
|
| 7. |
What can you tell about WAL (Write Ahead Logging)? |
|
Answer» Write Ahead Logging is a feature that increases the database reliability by logging changes before any changes are DONE to the database. This ensures that we have ENOUGH INFORMATION when a database crash OCCURS by helping to pinpoint to what point the work has been complete and gives a starting point from the point where it was discontinued. |
|
| 8. |
How do you check the rows affected as part of previous transactions? |
||||||||||||||||||||
|
Answer» SQL standards state that the following three phenomena should be prevented whilst concurrent transactions. SQL standards define 4 levels of TRANSACTION isolations to deal with these phenomena.
To tackle these, there are 4 standard isolation levels defined by SQL standards. They are as follows:
The following table clearly explains which type of unwanted reads the levels avoid:
|
|||||||||||||||||||||
| 9. |
What do you understand by command enable-debug? |
|
Answer» The COMMAND enable-debug is used for enabling the COMPILATION of all LIBRARIES and applications. When this is enabled, the system processes get hindered and generally also increases the size of the binary file. Hence, it is not recommended to switch this on in the production environment. This is most commonly used by DEVELOPERS to debug the bugs in their scripts and help them spot the issues. For more information regarding how to debug, you can REFER here. |
|
| 10. |
What do you understand by multi-version concurrency control? |
|
Answer» MVCC or Multi-version concurrency control is USED for avoiding unnecessary database LOCKS when 2 or more requests tries to access or modify the data at the same TIME. This ENSURES that the time lag for a user to log in to the database is avoided. The transactions are RECORDED when anyone tries to access the content. For more information regarding this, you can refer here. |
|
| 11. |
Can you explain the architecture of PostgreSQL? |
Answer»
|
|
| 12. |
What are ACID properties? Is PostgreSQL compliant with ACID? |
|
Answer» ACID stands for Atomicity, Consistency, Isolation, DURABILITY. They are database transaction properties which are used for GUARANTEEING data validity in case of errors and failures.
PostgreSQL is compliant with ACID properties. |
|
| 13. |
How can you delete a database in PostgreSQL? |
|
Answer» This can be done by using the DROP DATABASE command as shown in the SYNTAX below: DROP DATABASE database_name;If the database has been deleted successfully, then the following message would be shown: DROP DATABASE |
|
| 14. |
How can you get a list of all databases in PostgreSQL? |
|
Answer» This can be done by USING the COMMAND \l -> backslash FOLLOWED by the lower-case LETTER L. |
|
| 15. |
What are string constants in PostgreSQL? |
|
Answer» They are character SEQUENCES bound within single quotes. These are using during data insertion or updation to characters in the database. |
|
| 16. |
Define sequence. |
|
Answer» A sequence is a schema-bound, user-defined object which aids to generate a sequence of integers. This is most commonly used to generate values to IDENTITY columns in a table. We can create a sequence by USING the CREATE SEQUENCE statement as shown below: CREATE SEQUENCE serial_num START 100;To get the NEXT number 101 from the sequence, we use the nextval() method as shown below: SELECT nextval('serial_num');We can also use this sequence while inserting new records using the INSERT command: INSERT INTO ib_table_name VALUES (nextval('serial_num'), 'interviewbit'); |
|
| 17. |
What is the capacity of a table in PostgreSQL? |
|
Answer» The MAXIMUM SIZE of POSTGRESQL is 32TB. |
|
| 18. |
What is the importance of the TRUNCATE statement? |
|
Answer» TRUNCATE TABLE name_of_table statement REMOVES the data efficiently and quickly from the table. We can also USE the statement for removing data from multiple tables all at once by mentioning the table names separated by comma as shown below: TRUNCATE TABLE table_1, table_2, table_3; |
|
| 19. |
Define tokens in PostgreSQL? |
|
Answer» A token in POSTGRESQL is either a keyword, identifier, literal, CONSTANT, quotes identifier, or any symbol that has a distinctive personality. They may or may not be SEPARATED USING a space, NEWLINE or a tab. If the tokens are keywords, they are usually commands with useful meanings. Tokens are known as building blocks of any PostgreSQL code. |
|
| 20. |
What are partitioned tables called in PostgreSQL? |
|
Answer» Partitioned tables are LOGICAL structures that are used for dividing large tables into smaller structures that are called partitions. This approach is used for effectively increasing the query performance while dealing with large database tables. To create a partition, a key called partition key which is usually a table column or an expression, and a partitioning method needs to be defined. There are three types of inbuilt partitioning methods provided by Postgres:
The type of partition key and the type of method used for partitioning determines how positive the performance and the level of manageability of the partitioned table are. |
|
| 21. |
How can we start, restart and stop the PostgreSQL server? |
Answer» service postgresql start
Once the server is successfully restarted, we get the message: RESTARTING PostgreSQL: server stoppedok
Once stopped successfully, we get the message: STOPPING PostgreSQL: server stoppedok |
|
| 22. |
What is the command used for creating a database in PostgreSQL? |
|
Answer» The first STEP of using POSTGRESQL is to create a database. This is done by using the createdb command as SHOWN below: createdb db_name |
|
| 23. |
How will you change the datatype of a column? |
|
Answer» This can be DONE by using the ALTER TABLE statement as shown below: ALTER TABLE tnameALTER COLUMN col_name [SET DATA] TYPE new_data_type; |
|
| 24. |
How do you define Indexes in PostgreSQL? |
|
Answer» Indexes are the INBUILT FUNCTIONS in PostgreSQL which are USED by the queries to perform search more efficiently on a table in the database. Consider that you have a table with thousands of records and you have the below QUERY that only a few records can satisfy the condition, then it will take a lot of time to search and return those rows that abide by this condition as the engine has to perform the search operation on every SINGLE to check this condition. This is undoubtedly inefficient for a system dealing with huge data. Now if this system had an index on the column where we are applying search, it can use an efficient method for identifying matching rows by walking through only a few levels. This is called indexing. Select * from some_table where table_col=120 |
|
| 25. |
What is PostgreSQL? |
|
Answer» PostgreSQL was first called Postgres and was developed by a team led by Computer Science Professor Michael Stonebraker in 1986. It was developed to help developers build enterprise-level applications by upholding data integrity by making systems fault-tolerant. PostgreSQL is therefore an enterprise-level, flexible, ROBUST, open-source, and object-relational DBMS that supports flexible workloads along with handling concurrent USERS. It has been CONSISTENTLY supported by the GLOBAL developer community. Due to its fault-tolerant nature, PostgreSQL has gained widespread popularity among developers. |
|