In SQLite, we can use the DATE()
function to add one or more months to a date.
When we’re dealing with datetime values, we can use the DATETIME()
function.
In SQLite, we can use the DATE()
function to add one or more months to a date.
When we’re dealing with datetime values, we can use the DATETIME()
function.
Below are six examples that delete duplicate rows from a table in SQLite when those rows have a primary key or unique identifier column.
In these instances, the primary key must be ignored when comparing duplicates (due to the fact that primary keys prevent duplicate rows by definition).
Continue readingWhen using one of SQLite’s tabular output modes, you can enable the --wrap
option in order to limit the width of each column. This can be handy when the data contains long lines of text.
When we do this, we have the option of specifying “word wrap”, so that words don’t get cut off halfway through.
There are two ways to specify word wrap: use --wordwrap on
or its shortcut -ww
.
The ->
and ->>
operators were introduced in SQLite version 3.38.0, which was released on 22 February 2022. Both operators are used for extracting subcomponents of JSON. But there’s a subtle difference between them.
If you’re getting “Error: in prepare, SELECTs to the left and right of UNION do not have the same number of result columns…” in when trying to use the UNION
operator in SQLite, it’s because one of the SELECT
statements is returning more columns than the other.
If you need to calculate the number of seconds that have passed since a given date and time, you can use the UNIXEPOCH()
function.
Note that this function was introduced in SQLite 3.38.0, so it will only work if you’re using SQLite 3.38.0 or later.
Continue readingIn SQLite, we can use the DATE()
function to add a given number of days to a date.
If we’re dealing with datetime values, we can use the DATETIME()
function.
When using the SQLite command line interface (CLI), by default, whenever a query returns a null value, the output is the empty string (''
).
We can change this by using the -nullvalue
command line option when launching SQLite.
We can also use the .nullvalue
dot command if we’re already in the SQLite CLI.
Below is a full list of JSON functions and JSON operators available in SQLite.
Continue readingIn SQLite we can use the upper()
function to convert lowercase characters to uppercase.