In PostgreSQL, we can use the pg_client_encoding()
function to get the current client encoding name.
Category: DBMS
Database Management Systems
Time Travel in SQL Server: Using Temporal Tables for Historical Data Analysis
Temporal tables, introduced in SQL Server 2016, provide a powerful mechanism for tracking historical changes to data. This feature is particularly useful for auditing purposes, allowing organisations to maintain a complete history of data modifications without the need for complex triggers or custom logging solutions.
In this article, we’ll explore how to implement and use temporal tables for auditing in SQL Server, along with examples to demonstrate.
Continue readingUnderstanding the RIGHT() Function in PostgreSQL
In PostgreSQL the right()
function returns the specified number of rightmost characters in a given string.
We have the option of specifying the number of characters to return from the right or the number of characters to omit from the left. We do this by specifying a positive integer (to return n number of rightmost characters) or a negative integer (to return everything except n leftmost characters).
Continue readingA Quick Look at the LEFT() Function in PostgreSQL
In PostgreSQL we can use the left()
function to get the specified number of leftmost characters in a given string.
We have the option of specifying the number of characters to return from the left or the number of characters to omit from the right. We do this by specifying a positive integer (to return n number of leftmost characters) or a negative integer (to return everything except n rightmost characters).
Continue readingSQL Server WHILE Loop (with Examples)
The WHILE
loop in SQL Server is a control-flow statement that allows us to repeatedly execute a block of code as long as a specified condition is true. It’s useful for iterative tasks and processing data in batches.
A Quick Overview of the ERFC() Function in PostgreSQL
In PostgreSQL, erfc()
is a mathematical function that provides the mathematical complementary error function, without loss of precision for large inputs. It returns 1 - erf(x)
.
The erfc()
function was introduced in PostgreSQL 16, which was released on September 14th 2023.
How to Specify Sequence Options for IDENTITY Columns in PostgreSQL
When we create an IDENTITY
column in PostgreSQL, we have the option of specifying our own values for the sequence object that’s created.
This article provides an example of creating an IDENTITY
column with our own sequence options.
A Quick Intro to PostgreSQL’s ERF() Function
In PostgreSQL, erf()
is a mathematical function that provides the standard mathematical error function.
The erf()
function was introduced in PostgreSQL 16, which was released on September 14th 2023.
So PostgreSQL ARRAY_APPEND() Works but ARRAY_PREPEND() Doesn’t? Try this.
If you’re updating arrays in PostgreSQL and you’ve suddenly realised that some of the arrays aren’t being updated, it could be due to the following.
If you’ve been using the array_append()
function and the array_prepend()
function, you may have found that one function works but the other doesn’t. For example array_append()
works but array_prepend()
doesn’t, or vice-versa.
How REGEXP_REPLACE() Works in PostgreSQL
In PostgreSQL, we can use the regexp_replace()
function to replace a substring within a given string, based on a given POSIX regular expression. We can specify that all matches are replaced or just the first match.
We pass the string as the first argument, the pattern as the second, and the replacement text as the third argument. We also have the option of specifying the start position as the fourth argument, and we can specify a flag to determine how the function behaves.
Continue reading