If you’re getting SQL Server error 3723 that reads “An explicit DROP INDEX is not allowed on index…” it’s probably because you’re trying to drop a PRIMARY KEY
or UNIQUE
constraint by dropping its index.
Category: DBMS
Database Management Systems
How to Extract Fields from Composite Values in PostgreSQL
In PostgreSQL, a composite value is stored as a comma separated list of values, surrounded by parentheses.
When we have a table that contains composite values, we can extract individual fields by using dot notation to refer to the specific field that we want to extract.
Continue readingUnderstanding the Boolean Type in PostgreSQL
In SQL (and computer science in general), a Boolean expression is a logical statement that evaluates to either true or false. Some RDBMSs provide a boolean
data type that can store values that are either true or false (or unknown). PostgreSQL is one such RDBMS.
In PostgreSQL, the Boolean type is called boolean
and it uses 1 byte.
Possible Reason for Error 1914 “object is not a user table or view” in SQL Server
If you’re getting an error that reads something like “Index cannot be created on object ‘Customers’ because the object is not a user table or view” it could be that you’re trying to create an index, but there’s also a synonym of the same name (but in a different schema). It would appear that SQL Server thinks that you’re trying to create the index on the synonym instead of the table or view of the same name.
Continue readingUnderstanding the BREAK Keyword in SQL Server WHILE Loops
WHILE
loops are a powerful feature in most programming languages that allow developers to execute a block of code repeatedly as long as a specified condition is true. However, there are times when we may need to exit a loop prematurely based on certain criteria. SQL Server caters for this possibility with the BREAK
keyword.
In this article, we’ll explore how to effectively use the BREAK
keyword within WHILE
loops in SQL Server.
Using the VARIADIC Keyword with the FORMAT() Function in PostgreSQL
When we use the format()
function in PostgreSQL, we can pass any number of strings to insert into the resulting formatted string in positions that are specified in the first argument. When we do this, we might typically pass the strings as separate arguments. But this isn’t the only way to do it.
We have the option of passing the strings as array elements. That is, we can pass an array to the function, and have it extract each array element as though it’s a separate argument to insert into the formatted string.
Continue readingFix Error 156 “Incorrect syntax near the keyword ‘OR'” in SQL Server When Creating a Filtered Index
If you’re getting an error that reads something like “Incorrect syntax near the keyword ‘OR’” when creating a filtered index in SQL Server, it’s probably because you’re using the OR
operator in your WHERE
clause.
Filtered indexes don’t support the OR
operator.
However, filtered indexes do support the IN
operator, and so it’s possible to change your query to use that.
So to fix this issue, try the IN
operator instead.
What is a Clustered Index in SQL Server?
There are around a dozen types of index in SQL Server, but the most commonly used index type would have to be the clustered index. By default, a clustered index is automatically created when we create a primary key, and so if your tables have primary keys, then there’s a pretty good chance you’ve got clustered indexes all over your database.
But what exactly is a clustered index?
Let’s delve into what a clustered index is, how it works, its relationship with primary keys, and why it’s so important for our database performance.
Continue readingWhat is a Nonclustered Index in SQL Server?
We’ll often hear SQL Server developers talk about adding indexes to a table to improve the performance of some of the more heavily run queries. Such queries could be quite complex, and/or search through large tables, perhaps with lots of joins, and generally take a long time to complete.
But it’s not just a matter of saying “add an index” and being done with it. We need to decide how to design the index, and even before that, what type of index to add.
Two of the most commonly used index types in SQL Server are the clustered index and the nonclustered index.
In this article, we’ll explore what a nonclustered index is, how it works, and when we should use it to enhance our database performance.
Continue readingHow to Select an Element from an Array in PostgreSQL
PostgreSQL provides us with the ability to create arrays, extract element values from them, and more. When it comes to selecting values, there’s a special syntax that we must use in order to get the exact element that we want to select.
Basically, the syntax involves the array or column name, followed by a pair of square brackets with the subscript of the element that we want to select.
Continue reading