Here are two options we can use to add an option to our sql_mode without wiping all existing options.
how to
How to Prettify JSON Formatted Query Results in SQLcl (Oracle)
If you use SQLcl to query Oracle Database, you might be aware of the SET SQLFORMAT json option, that makes query results come back as JSON documents.
But there’s also a json-formatted option, which returns the results in a more human readable format.
How to List All Stored Procedures in Oracle Database
There are several data dictionary views that we can use to return a list of stored procedures in Oracle Database.
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.
4 Ways to List the Views in an SQLite Database
Here are four options for showing all views within an SQLite database.
PostgreSQL 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.
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.
Format a Number as Currency in SQL
Some DBMSs have functions that allow us to format numbers as currency just by passing the appropriate format string. This converts the number to a string with the applicable currency symbol, group separator, and decimal point (if relevant).
Other DBMSs don’t make it that easy, and you need to do a bit of work first.
Below are examples of using SQL to format numbers as currency in some of the most popular DBMSs.