Category: PostgreSQL

9 Nov by Faruk Erdem

Universal Unique İdentifier (UUID) Data Type In PostgreSQL

  Uuid is the abbreviation for “universal unique identifier”. It consists of 36 characters, a set of numbers and letters, and its most important feature is: Its extremely unique. To use this feature on PostgreSQL, we need to install uuid-ossp extension. We can install extension with the following command; [crayon-5bf18c805fec1149446620/]   After running the command […]
8 Nov by Faruk Erdem

How to Change the Schema Name in PostgreSQL

We may want to change the schema name because of some needs. For this we can use the following script. First, we list the schemes with the command \dn as follows.   We change the name of the faruk scheme with the help of the following command. [crayon-5bf18c806051c496062064/]   We changed the schema name to […]
7 Nov by Şahap Aşçı

PostgreSQL – List the connections from the IP block

One of the useful data types of PostgreSQL is the inet data type. inet is used to define IPv4 and IPv6 addresses. The ip address can also be stored with the subnet if desired. It supports a total of 17 operators, including basic operators “<,>, =” operators. In addition to this, with the help of […]
1 Nov by Faruk Erdem

How To Find and Kill Long Running Queries In PostgreSQL

You can use the following queries to monitor the performance of the database or to find and kill queries that cause lock. The following query returns queries that last longer than 5 minutes. [crayon-5bf18c8060a63497816235/]   You can find queries that have ExclusiveLock with the following query. [crayon-5bf18c8060a6b598692408/]   We have found your query with the […]
30 Oct by Engin Yilmaz

UPGRADE POSTGRESQL 10 To 11

Before I start the upgrade process, I want to make the following critical warning: You will need to re-configure your postgresql.conf and pg_hba.conf files. Because the files will be reset after upgrade.   We are installing Postgresql 11 with the following commands. [crayon-5bf18c8060d4e514293105/]   We are performing the initdb operation in the Postgresql 11 database. [crayon-5bf18c8060d56192961088/] […]
28 Oct by Faruk Erdem

How to Install Postgresql Sample Database

In Postgresql, sometimes we need a sample database when we test. We can use pagila in postgresql.org for this. You can follow the steps below to install Pagilla. We’re running the following command to load Pagila’s files. [crayon-5bf18c8061185015100993/]   As you can see above, pagila files were created. Let’s see where it is now. First, […]
27 Oct by Şahap Aşçı

PostgreSQL – Split The String With Regex Split

In PostgreSQL we have 2 functions to split a string according to a certain character; regexp_split_to_array and regexp_split_to_table.   regexp_split_to_array : It splits the string according to regular expression and returns its parts in an array. regexp_split_to_table :  It splits the string into pieces according to the regular expression and returns its parts in the rows of a table.   […]
26 Oct by Engin Yilmaz

COLUMN ENCRYPTION WITH POSTGRESQL TRIGGER

In Postgresql, we can capture the record with the trigger, encrypt and write to the table. Let’s create the table, [crayon-5bf18c80617b8914260384/]   Then we create our function, [crayon-5bf18c80617bf861595461/]   Finally, we create our trigger. [crayon-5bf18c80617c2624696571/]   Then, when we add records to the table, we can see that the data is encrypted. [crayon-5bf18c80617c5308303399/]   With […]
23 Oct by Faruk Erdem

Foreign Data Wrapper Between PostgreSQL and MSSQL

In the article “Postgresql Foreign Data Wrapper“, we created Foreign Data Wrapper to read data between two PostgreSQLs. In this article, we will create Foreign Data Wrapper by using tds_fdw extension between Mssql and Postgresql. Before we create Foreign Data Wrapper, there are a few packages that we need to install. We need to install […]
22 Oct by Faruk Erdem

Postgresql Foreign Data Wrapper

Postgresql is one of the RDMS databases presented in simple form. Therefore, we need to install the extension to use dblink, Foreign Data Wrapper, and so on. Foreign Data Wrapper allows you to connect to different remote systems and query and write over remote systems. The Foreign Data Wrapper feature is available in version 9.1 […]