Quick Intro to the event_scheduler System Variable in MySQL

In MySQL, the event_scheduler system variable is used to start and stop the Event Scheduler, as well as enable or disable it.

At runtime we can set the value to ON or OFF, and we can check the current value of the variable. We can also disable the Event Scheduler at server startup, but we can’t do this at runtime. However, we can still check the event_scheduler variable to see whether it’s enabled or disabled.

Continue reading

Understanding Composite Types in PostgreSQL

In PostgreSQL, a composite type is a kind of data type that consists of multiple data types. It consists of a list of field names and their respective data types.

We can use composite types to fit multiple fields into one column.

We can create our own custom composite types, and they can be used in many of the same scenarios that simple data types can be used.

Continue reading

Understanding PostgreSQL’s TRANSLATE() Function

PostgreSQL has a translate() function which replaces certain characters in a string with certain other characters.

We specify the characters in the string that we want to replace, as well as the characters that we want to replace them with. The function then performs the translation and returns the string with the replaced characters.

Continue reading

Using REGEXP_SPLIT_TO_ARRAY() in PostgreSQL

In PostgreSQL, the regexp_split_to_array() function splits a string using a POSIX regular expression as the delimiter, and returns the result in a text array.

So we use a POSIX regular expression to specify the delimiter/s, and split the string based on that.

We pass the string as the first argument and the pattern as the second. We can also specify a flag to determine how the function behaves.

Continue reading