How to get a list column names and data-type of a table in PostgreSQL?
If you are a DBA and you are working on a data-dictionary for a project so that you can keep track of schema changes and so on, then this article will help you achieve your right things. Using schema...
View ArticleCommon Issue "Can't find module 'bcrypt'" in node.js
This issue comes much time when we are using PostgreSQL with Node.js, Error: Cannot find module 'bcrypt' in nodejs application, and we try again and again to install to bcrypt using 'npm install...
View ArticleDoes PostgreSQL automatically generate an id for every row?
When I was started work on the PostgreSQL, crating first time a table, I become stuck on the Identity column because I was familiar with the MS SQL Server. So, first of all, I search the question,...
View ArticlePostgreSQL query for Character Varying data type column with an integer value
It is difficult to change the column data-type character varying to integer in running database, but need to query the string. Suppose we have a table which column Cal_1 has integer value as string, in...
View ArticlePostgreSQL- Select first row in each GROUP BY group
I want to select the first row of each group grouped by the PostgreSQL keyword GROUP BY. Suppose I am working on purchase reporting and I want to select the customer who has a max value of the price.I...
View ArticlePostgreSQL - CrossTab Queries using tablefunc contrib
PostgreSQL statement uses the function crosstab to pivot the table records, pivot means I want to convert the rows to the column of particular column's value and want to the others column value...
View ArticlePostgreSQL - Upsert query using ON CONFLICT clause
I want to insert data from a source that can contain duplicate data or data that may exist into the table, so simple I want to add data that do not exist in the table and update the table if data...
View ArticlePostgreSQL: Function and its uses
The function is the set of PostgreSQL statements that stored on the database server and can be invoked using the SQL interface. PostgreSQL function is also known as Stored Procedure (If you are...
View ArticlePostgreSQL: VIEW
In this article, we will learn about VIEW and how it can be managed in PostgreSQL. Firstly, we should know why we need a VIEW, while it just a group of SQL statements like function and procedure.View...
View ArticlePostgreSQL: Materialized View
In this article we will learn about Materialized View, its need, and advantage. Also, we will learn how we can manage it in PostgreSQL? Before start Materialized View, you should take a look at the...
View ArticlePostgreSQL: Stored Procedure
The stored procedure is introduced in PostgreSQL 11 that supports the transaction. Postgres user-defined function has a drawback, it can not execute transactions. It means, in the function, we can not...
View ArticlePostgreSQL: Generated Column
PostgreSQL 12 introduced a new feature called generated columns. Other popular databases already support to generated columns as the Computed column and virtual column.What is a generated column?A...
View ArticleHow to concatenate the string values of a column/field in a PostgreSQL query?
This is a very popular interview question of the database, many times I faced this the question in SQL Server interview. Problem:Suppose we have the following table...
View ArticlePostgreSQL: How to create a read only user?
Suppose you are Super Admin, sometimes you need to give the read-only permission to particular user for a safety purpose, because, it may be possible a specific user don’t have sufficient knowledge...
View ArticlePostgreSQL: how to select all records from one table that do not exist in...
Problem: I have two tables one is Employee, and another is Address, and I want to fetch all those records from Employee, which doesn't exist in the Address table.--EmployeeCREATETABLEemployee(...
View ArticlePostgreSQL: How to select last record of each user
Before writing a PostgreSQL query, we will create a scenario, suppose we have two tables first are Customer, and Second is its Orders. First, we will create tables through the following query then we...
View ArticleInsert text with single quotes in PostgreSQL
I faced an issue when tried to insert apostrophe word into the table, seeing the issue I become panic, how would I resolve this issue, so I did google surfing and found a lot of solutions, and I want...
View ArticlePostgreSQL: How to reset primary key sequence if it falls out of sync?
Once I was working with PostgreSQL 9.4, I got an error of primary key constraint while I was using the sequence that generates the next serial number. But the sequence implied in the serial data type...
View ArticlePostgreSQL: Generated column computed from jsonb column
Problem: I am using PostgreSQL 12 new feature Generated Column, but computing column is jsonb type that containing json as "active":true or "active":false. I have tried to create the table using the...
View ArticlePostgreSQL: Sort result by DateTime, but the null value should be first or last
I want to sort my result by date time column in ascending order but null values should come first or vice versa. Suppose I have a table employee and it has the column appraisal_date if I sorted the...
View Article