The Enum (enumeration) data type in SQL is a specialised string object that allows us to define a list of predefined values for a column. This data type can be particularly useful when we want to restrict the possible values that can be stored in a specific column to a fixed set of options.
Ian
How to TRUNCATE a Temporal Table in SQL Server
Temporal tables in SQL Server provide a powerful way to track historical data changes. However, when it comes to clearing out data from these tables, the standard TRUNCATE statement doesn’t work the same as it does on normal (non-temporal) tables.
This article will guide you through the process of truncating a temporal table while maintaining its integrity.
How to Specify your own Subscript Range when Creating an Array in PostgreSQL
By default, PostgreSQL arrays are one-based. This means that we need to use 1 if we want to reference the first element in the array, 2 for the second, and so on.
But we also have the option of specifying our own subscript range for an an array. For example we could create a zero-based array, a ten-based array, or even a negative value such as a negative ten-based array.
We can do this by using subscripted assignment to specify the actual subscript range for the array. Basically, we prefix the array with the subscript range, enclosed in square brackets, and an equals sign (=) between it and the array.
A Quick Look at the ASCII() Function in PostgreSQL
In PostgreSQL, we can use the ascii() function to get the numeric code of the first character of the argument.
When using UTF8, the function returns the Unicode code point of the character. Other multibyte encodings require an ASCII character.
Understanding the SQL Subquery
One of the things I love about SQL is just how easy it is to write a simple query that returns a meaningful result set, without having to a whole bunch of complex code. And I imagine most beginners are relieved when they discover this too.
However, while basic queries can go a long way, there’s a whole world of advanced techniques that can take our SQL development to another level. Somewhere in that world, would be the SQL subquery.
In this article, we look at the SQL subquery. We’ll explore what subqueries are, how they work, and when to use them. We’ll also look at some simple examples to demonstrate their use.
10 Essential Database Concepts that All Beginners MUST Learn
When I first started building websites 25 years ago, everything was static. Our primary building block was HTML, with a bit of CSS and JavaScript sprinkled in for good measure. Our content would be incorporated into the HTML documents, and so there was no separation of functionality and content.
Regardless, I was just happy to be able to build these amazing things that I could publish for the world to see.
But within a few years I had quickly learned about the power of databases and how they could completely transform the websites we were building at the time.
SQL Truncate Explained
In SQL databases, the TRUNCATE statement can be used to quickly remove all data from a table. Unlike the DELETE statement, TRUNCATE is typically faster and uses fewer system resources, especially for large tables.
In this article, we’ll explore the TRUNCATE statement, its usage, and provide some examples.
Understanding PostgreSQL’s SPLIT_PART() Function
The PostgreSQL split_part() function splits a string based on a specified delimiter and then returns the specified part from the split string.
The function accepts three arguments; the string, the delimiter, and the part that we want to return.
A Quick Look at PostgreSQL’s PG_CLIENT_ENCODING() Function
In PostgreSQL, we can use the pg_client_encoding() function to get the current client encoding name.
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.