In SQL Server, we can use the sys.sequences
system catalog view to return a list of sequence objects in the current database.
Category: DBMS
Database Management Systems
Fix Error Msg 3625 “‘Inline XSD for FOR XML EXPLICIT’ is not yet implemented.” in SQL Server
If you’re getting error Msg 3625 in SQL Server that reads “‘Inline XSD for FOR XML EXPLICIT’ is not yet implemented“, it’s because you’re trying to add an inline schema to an XML document that you’re generating using EXPLICIT
mode with the FOR XML
clause.
As the message alludes to, SQL Server doesn’t yet support inline XSD schemas when using EXPLICIT
mode of the FOR XML
clause (at least, not at the time of this writing).
To fix this issue, either use a different mode to generate the XML with an inline schema (specifically, use either AUTO
or RAW
mode), or don’t generate an inline schema at all (i.e. remove XMLSCHEMA
from the query).
How to Convert Time Zones in MySQL using the Time Zone Name
When using a function like CONVERT_TZ()
to convert between time zones in MySQL, we provide the date/time value, along with the original time zone and the destination time zone (i.e. the time zone that we’re converting to).
One typical way to do this is to use the time zone offset, such as −05:00
to specify the time zone. Another method is to use the time zone name. However, this requires that we have configured named time zones in MySQL.
Fix “START value (…) cannot be greater than MAXVALUE (…)” When Creating a Sequence in PostgreSQL
If you’re getting an error that reads something like “START value (101) cannot be greater than MAXVALUE (100)” in PostgreSQL when you’re trying to create a sequence, it’s probably because your sequence’s maximum possible value is lower than the start value.
To fix this issue, change either the start value or maximum value so that the maximum value is greater than the start value.
Continue readingUnderstanding the ->> Operator in MySQL
In MySQL, we can use the ->>
operator to extract a value from a JSON document, and unquote that value.
We provide the column that contains the JSON document to the left of the operator, and the path to the value that we want to extract to the right.
The ->>
operator is equivalent to JSON_UNQUOTE(JSON_EXTRACT())
, and it provides the same results.
Understanding the -> Operator in MySQL
In MySQL, we can use the ->
operator to extract data from a JSON document.
We provide the column that contains the JSON document to the left of the operator, and the path to the value that we want to extract to the right.
The ->
operator is an alias for the two-argument form of the JSON_EXTRACT()
function.
How to Add an Inline Schema When Using FOR XML in SQL Server
When using the FOR XML
clause in a query in SQL Server, we can generate an XML document either with or without an inline schema.
To generate it with an inline XSD schema simply include the XMLSCHEMA
argument. We can alternatively include the namespace if we want to specify a particular namespace.
At the time of writing, the XMLSCHEMA
argument is only available when in either AUTO
or RAW
mode.
How the MEMBER OF() Operator Works in MySQL
In MySQL, the MEMBER OF()
operator tests whether or not a value is a member of a given JSON array.
It returns true (1
) if the array contains the value, and false (0
) if it doesn’t.
The MEMBER OF()
operator was added in MySQL 8.0.17.
Fix “cannot insert into column… Column is an identity column defined as GENERATED ALWAYS” in PostgreSQL
If you’re getting an error in PostgreSQL that reads something like “cannot insert into column” with detail that explains that the “…is an identity column defined as GENERATED ALWAYS“, it’s probably because you’re trying to insert your own value into an identity column that was created with the GENERATED ALWAYS
option, but you’re not explicitly overriding the column from auto generating its own value.
To fix this issue, use OVERRIDING SYSTEM VALUE
when inserting the value.
How JSON_OVERLAPS() Works in MySQL
In MySQL, JSON_OVERLAPS()
is a function that tests whether or not two JSON documents have any key-value pairs or array elements in common.
The function returns true (1
) if the documents have any key-value pairs or array elements in common, and false (0
) if they don’t.
The JSON_OVERLAPS()
function was added in MySQL 8.0.17.