In MariaDB, MIN()
is an aggregate function that returns the minimum value in a given expression.
Category: DBMS
Database Management Systems
MAX() Function in MariaDB
In MariaDB, MAX()
is an aggregate function that returns the maximum value in a given expression.
How to Remove Leading Zeros From Dates in Oracle
In Oracle Database, you can use the fm
(fill mode) format modifier to suppress any leading zeroes that might be applied to a date. This format modifier suppresses padding, which includes leading zeros and trailing blanks.
To use the fm
format modifier, include it in your format model when specifying how dates should be formatted. For example when using the TO_CHAR()
function to format dates, or in NLS parameters such as the NLS_DATE_FORMAT
parameter when setting the date format for your current session.
2 Ways to List all Functions in MariaDB
Below are two options for returning a list of functions in MariaDB.
Continue reading4 Ways to List the Views in an SQLite Database
Here are four options for showing all views within an SQLite database.
Continue readingPostgreSQL GROUP_CONCAT() Equivalent
Some RDBMSs like MySQL and MariaDB have a GROUP_CONCAT()
function that allows you to return a query column as a delimited list (for example, a comma separated list).
PostgreSQL has a similar function called STRING_AGG()
. This function works in pretty much the same way that GROUP_CONCAT()
works in MySQL and MariaDB.
SQL LPAD()
In SQL, LPAD()
is a commonly used function that pads the left part of a string with a specified character. The function can be used on strings and numbers, although depending on the DBMS, numbers may have to be passed as a string before they can be padded.
DBMSs that have an LPAD()
function include MySQL, MariaDB, PostgreSQL, and Oracle.
DBMSs that don’t have an LPAD()
function include SQL Server and SQLite (although there are other ways to apply left padding in these DBMSs).
SQL RPAD()
In SQL, RPAD()
is used to pad the right part of a string with a specified character. The function can be used on strings and numbers, although depending on the DBMS, numbers may have to be passed as a string before they can be padded.
DBMSs that have an RPAD()
function include MySQL, MariaDB, PostgreSQL, and Oracle.
DBMSs that don’t have an RPAD()
function include SQL Server and SQLite.
DROP TABLE IF EXISTS in MySQL
In MySQL, we can use the IF EXISTS
clause of the DROP TABLE
statement to check whether the table exists or not before dropping it.
Fix “Conversion failed when converting the varchar value” When Trying to Concatenate in SQL Server
If you get error Msg 245 that reads “Conversion failed when converting the varchar value…” when trying to perform a concatenation operation in SQL Server, it’s likely that you’re attempting to concatenate a string and a number.
Doing this will result in an error, due to SQL Server trying to add the string and number instead of concatenate them.
To fix this, either convert the number to a string, or use a function like CONCAT()
or CONCAT_WS()
to perform the concatenation.