Explore topic-wise InterviewSolutions in .

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.

What is a CTID of PostgreSQL?

Answer»

In POSTGRESQL, the CTID field is one that exists in each and EVERY PostgreSQL table, and it is unique for all RECORDS inside a table, which is USED to denote the LOCATION of the tuples.

2.

How to take the backup of PostgreSQL?

Answer»

Here are the steps to back up a SINGLE database in PostgreSQL. We shall be using the pg_dump tool as it dumps out the content of all the objects in the database to a single file.

Step 1: First of all, navigate to the PostgreSQL BIN FOLDER:

C:\>cd C:\Program Files\PostgreSQL\9.2\bin

Step 2: Now, we shall execute the pg_dump program and use the following method to back up the EXAMPLES database to the example.tar file to the c:\pgbackup\ folder.

pg_dump -U postgres -W -F t examples > c:\pgbackup\examples.tar

Step 3: Here is your backed up database

c:\pgbackup\dvdrental.tar

3.

How to enable debug mode in PostgreSQL?

Answer»

PgAdmin comes with built-in support to DEBUG your Pl/PgSQL codes. However, in order to enable this, you need to compile and INSTALL a SEPARATE plug-in for PostgreSQL

Now, once you have set up a proper environment for debugging, GO to EDIT /etc/postgresql/9.4/main/postgresql.conf and enable the debugger plugin.

4.

How to check status of PostgreSQL server running or not?

Answer»

The SIMPLEST way to CHECK whether your SERVER in PostgreSQL is running or not:

ps auxwww | grep postgres

In versions other than 8.3 you need to run this command

/Library/PostgreSQL/8.3/bin/postgres -D /Library/PostgreSQL/8.3/data

5.

What are the ODBC drivers that are available for PostgreSQL?

Answer»

plsqlODBC is the official POSTGRESQL DRIVER. Besides that, there are other third-party ODBC drivers such as Devart, which shall COST you some MONEY.

6.

What is the command that can be used to allocate memory in postgreSQL?

Answer»

The PostgreSQL FUNCTIONS palloc and MALLOC are USED for ALLOCATING memory.

7.

How many byte Unique integers does OIDs in PostgreSQL?

Answer»

In POSTGRESQL, there are 4 bytes of UNIQUE INTEGERS by DEFAULT.

8.

What is inverted file in PostgreSQL?

Answer»

In POSTGRESQL, an Inverted file is basically an index data STRUCTURE used for mapping content to its location to a database file, WITHIN a document, or in sets of documents.

It is usually composed of all the distinct words found in a text and a list containing the occurrences of a WORD in the text.

The inverted file is widely used in a data structure for document retrieval systems in supporting a full-text SEARCH.

9.

What is the operator that is used for case-insensitive regular expression searches in PostgreSQL?

Answer»

To MATCH a regular EXPRESSION that is CASE insensitive, you can use the POSIX regular expression (~*) from the pattern MATCHING operators.

Example

'umesh' ~* '.*Umesh.*'

10.

What is purpose of overlay function in PostgreSQL?

Answer»

In PostgreSQL, the Overlay function allows users to replace a SUBSTRING, which is starting at a specific position and having a specified length.

Here is the syntax for the Overlay Function:

Example

overlay(<main_string> placing <replaced_string> <br>
from <starting_position> [ for <number_of_characters>] )

28. How to calculate cube root in PostgreSQL?

To find the cube root of ant given NUMBER in PostgreSQL, you can USE the CBRT() function.

Example

SELECT cbrt(729) AS "Cube Root";
OUTPUT - 9

11.

What is sequence in PostgreSQL?

Answer»

A SEQUENCE in PostgreSQL is a special form of data that is created to GENERATE multiple numeric identifiers in the PostgreSQL database. It is most often USED to create sequences and artificial primary keys SIMILAR to Auto_Increment in MySQL. The basic role of sequences in PostgreSQL is to create UNIQUE identifiers between multiple rows inside a table.

12.

How to change user's password in PostgreSQL?

Answer»

Follow these steps to CAREFULLY change the user password Postgres in Laravel:

  • Step 1: Make yourself the “Postgres” system user (through the root user, sudo or VIA SSH public key verification)
  • Step 2: Connect to the LOCAL server USING “PSQL”
  • Step 3: Type this meta-command of PSQL \password

It should look something like this:

13.

What is reserved words in PostgreSQL?

Answer»

RESERVED WORDS in PostgreSQL are ACTUALLY SQL keywords and other SYMBOLS having some SORT of special meaning when being processed by the Relational Engine.

14.

What are tokens in PostgreSQL?

Answer»

A TOKEN can be a keyword, an identifier, a quoted identifier, a literal (or constant), or a distinctive personality symbol. TOKENS are generally separated with the AID of whitespace (SPACE, tab, newline), however, need not be if there is no ambiguity (which is usually only the case if an exceptional persona is adjoining to some other token type).

15.

How to create a database in PostgreSQL pgAdmin?

Answer»

Follow these steps to successfully create a DATABASE in PostgreSQL USING PgAdmin:

  • Log into PostgreSQL using pgAdmin
  • Now, go to the DATABASES section and right-click on it

  • Now, enter the database name, owner and configure parameters and press OK after it is done.

16.

What types of indexes are supported in PostgreSQL?

Answer»

PostgreSQL provides several INDEX types like HASH, B-tree, SP-GiST, BRIN, and GIN. All these types USES a separate ALGORITHM that is best suited to queries.

17.

What is indexes in PostgreSQL?

Answer»

In PostgreSQL, the index is a common way for DATABASE performance ENHANCEMENT. It allows the database server to FIND the retrieve specific rows faster compared to without index. It also adds overhead to the database system as a whole, so users have to IMPLEMENT them sensibly.

Indexes are special lookup tables that are used by the database search engine to SPEED up data retrieval. Simply defining, an index is a pointer to a specific data in a table.

18.

How to stats update in PostgreSQL?

Answer»

An EXPLICIT 'vacuum' call is made to update STATISTICS in POSTGRESQL. Users can ALSO use the ANALYZE to perform so.

19.

What is table partitioning in PostgreSQL?

Answer»

In PostgreSQL, table partitioning REFERS to splitting a large table into smaller SECTIONS. PostgreSQL supports LIST and range partitioning via table heritance. Users have to CREATE each partition as a child table of the master table.

20.

What is a child in PostgreSQL?

Answer»

The ctid field exists in every PostgreSQL table. It is UNIQUE for every record in a table and denotes the turple location. It can be used to delete records. The THING to REMEMBER, we should only use ctid if we have ABSOLUTELY no other unique IDENTIFIER to use.

21.

List data type in PostgreSQL?

Answer» POSTGRESQL SUPPORTS VARIOUS DATA types, which includes:
  • Boolean
  • Numeric types
  • Character types
  • Temporal types
  • Array
  • UUID
  • JSON
  • store
  • Special types such as geometric data and particular types
22.

How to install PostgreSQL on Ubuntu?

Answer»

As the DEFAULT repositories of Ubuntu contain Postgres packages, we can install it easily USING the apt packaging SYSTEM. Refresh the local PACKAGE index and then install the Postgres packages and a -contrib package which adds additional functionality and utilities. The PostgreSQL SOFTWARE installation process is finished now.

23.

How to install PostgreSQL on windows?

Answer»
  • Download Windows PostgreSQL one-click the installer and run it.
  • Choose to install PostgreSQL as a Windows Service.
  • If needed, change the installation DIRECTORY and click next
  • Choose the components you want to install & click next
  • If needed, change the data location
  • Enter the user PASSWORD and if necessary make a note of it.
  • Let the port number by the default
  • Once the installation is complete, uncheck the Stack Builder prompt and click finish
  • Now go to start menu, search and start pgAdmin 4
  • Click on servers present on the pgAdmin homepage and choose Postgre SQL 10
  • Enter the superuser password, and the DASHBOARD will begin for your USE
24.

What are the difference between PostgreSQL and Oracle?

Answer»
S.noOraclePostgreSQL
1.Mostly aid object-relational database MANAGEMENT systemopen source object-relational database management system
2.The implementation language is C.Implementation language is C and C++.
3.Server operating systems here are OS X, LINUX, Windows, z/OS, AIX, and HP-UX.Server operating systems here are HP-UX, NETBSD, Solaris, Windows, Unix, Linux, and FreeBSD.
4.More database productivityLess database productivity
5.Advance security optionsGood security support but less compared to Oracle
25.

Explain PostgreSQL vs. MongoDB?

Answer»
S.noPostgreSQLMongoDB
1.It’s an object-relational DATABASE management system.It uses JSON-like documents to STORE schema-free data.
2.uses tables, triggers, CONSTRAINTS, roles, stored procedures and views as the core componentsUses Key, Collection, DOCUMENT, and VALUE.
26.

What is Multi Version Concurrency Control in PostgreSQL?

Answer»

Multi-Version Concurrency Control (MVCC) is an advanced method used in PostgreSQL for improving the performance of a database in a multi-user environment. Unlike lock MODELS in other DATABASES, PostgreSQL uses a multi-version environment in which locks that are acquired for reading data don’t conflict with locks acquired for writing the data. HENCE, making the process more compartmentalized and a LOT faster.

27.

Which is better MySQL or PostgreSQL?

Answer»

In terms of learning DATABASES, MYSQL is perfect. It is the first choice for web-based projects merely requiring a database for transactions and nothing else. But, PostgreSQL is better in terms of FUNCTIONALITIES and performance. It is more used in the execution of COMPLEX queries, data WAREHOUSING, and data analysis.

28.

What is the Maximum size for a database in PostgreSQL?

Answer»

PostgreSQL has no maximum database size, so USERS can put unlimited data into it. But, the table, row, and field size are limited. The row and INDEXES are also universal for its users.

PostgreSQL usually stores its desk facts in CHUNKS of 8KB. The quantity of these blocks is confined to a 32-bit signed integer, GIVING the most desk dimension of 16TB.

29.

What does GEQO stands for in PostgreSQL?

Answer»

In PostgreSQL, GEQO stands for Genetic Query Optimization. It allows the PostgreSQL search QUERY optimizer to SUPPORT LARGE joined QUERIES in an effective manner using a non-exhaustive search technique.

30.

What is pgAdmin and how do you set up pgAdmin?

Answer»

PgAdmin is a free, open-source PostgreSQL database administration GUI that is used in Microsoft WINDOWS, MAC OS X, and Linux systems. PgAdmin is used for database server information retrieval, development process, Quality testing, and other ONGOING maintenance.

Follow these steps to install PgAdmin:
  • Launch pgAdmin 4.
  • Go to the “Dashboard” tab, click on the “Quick Link” section and then click on “Add new Server”
  • Now, select the “Connection” tab in the “Create-Server” window.
  • Now, configure the connection as follows:
  • Enter your server's IP address in the “Hostname/Address” field.
  • Specify the “PORT” as “5432”.
31.

What are the features of PostgreSQL?

Answer»

PostgreSQL has many exciting features added to it. Here are a few of them:

  • By protecting DATA integrity, USERS can build a fault-tolerant environment.
  • Easy COMPATIBILITY with significant platforms, languages, and middleware.
  • Multi-version concurrency control is supported.
  • The client-server network ARCHITECTURE is supported.
  • Trigger-based and log-based replication SSL
  • High AVAILABILITY and standby server
32.

What is the Maximum size for a table in PostgreSQL?

Answer»

EVEN though PostgreSQL has UNLIMITED DATABASE size for users, but it has a LIMIT for maximum table size. The maximum table size is set to 32 TB.

Note: This is very essential PostgreSQL interview questions.

33.

How to change the datatype of a column in PostgreSQL?

Answer»

To change the records TYPE of a column, you USE the ALTER TABLE ASSERTION as FOLLOWS:

Example

ALTER TABLE users
ALTER COLUMN username[SET DATA] TYPE new_data_type;

34.

What is base directory in PostgreSQL?

Answer»

The base directory in PostgreSQL (data_dir/base) is the folder is where PostgreSQL stores all the data you have INSERTED in your DATABASES. It contains all the sub-directories which are USED by a DATABASE in your CLUSTERS.

35.

How to select first 10 records in PostgreSQL?

Answer»

To get the first 10 records from a database in PostgreSQL, USE the LIMIT command.

Here is an example of PICKING the first 10 records from a database CALLED Example:

Example

select * from users ORDER by NAME desc LIMIT 0, 10

36.

What is PostgreSQL and why it is used for?

Answer»

It’s a GENERAL purposed and advance object-relational database MANAGEMENT system used to add custom functions developed using a various programming LANGUAGE such as C, C++, Java, etc. Designed to be extensible, PostgreSQL IMPLEMENTS MVCC or multi-version concurrency control.