When using SQLcl to run queries against Oracle Database, you can specify the output of the query results using the following two options:
- The
SET SQLFORMAT
command - Add a comment shortcut to your query
When using SQLcl to run queries against Oracle Database, you can specify the output of the query results using the following two options:
SET SQLFORMAT
commandIn PostgreSQL, the CONCAT()
function concatenates the text representations of its arguments.
By default, two pipe characters (||
) are treated as a logical OR
operator in MariaDB. However, you can change this behaviour if you like.
You can update your sql_mode
to include the PIPES_AS_CONCAT
option, in which case two pipes will be treated as a concatenation operator.
There are quite a few ways to add this option to your sql_mode
. You can add it explicitly. Or you can set your sql_mode
to an option that sets it implicitly.
I run through these options below.
Continue readingIn SQLite, we can use the strftime()
function to return datetime values in our chosen format.
Therefore, we can use it to extract the day, month, and year from a date.
Continue readingWhen using the TO_CHAR()
function to format a number in Oracle Database, you can use the S
format element to return its sign (i.e. a plus sign for positive values, and a minus sign for negative values).
You can also use the MI
format element to return negative values with a trailing negative sign, and positive values with a trailing blank.
MySQL supports the use of the pipe concatenation operator (||
) for concatenating its operands. However, you need to enable it first.
PostgreSQL provides us with several ways to get the day, month, and year from a date.
Three functions that immediately come to mind are; DATE_PART()
, EXTRACT()
, and TO_CHAR()
.
When using SQLcl with Oracle Database, you can export your query results to an XML file with the SPOOL
command.
MySQL has a bunch of different functions that enable us to get various date parts – such as the day, month, and year – from a date.
Continue readingIn MySQL, YEAR()
is a built-in date and time function that returns the year from a given date expression.
It returns the year as a number in the range 1000
to 9999
. For zero dates, it could return 0
or NULL
with a warning, depending on the values in your sql_mode
.