DuckDB’s command-line interface (CLI) provides a way to suppress query results using the .mode trash
command. This feature is particularly useful in scenarios where you need to execute queries but don’t want their results to be displayed.
Tag: how to
Working with Intervals in DuckDB
Time-based operations are a fundamental aspect of data analysis and manipulation. DuckDB, the in-process analytical database management system, provides robust support for handling time-based operations through its INTERVAL
data type.
This article explores the capabilities, syntax, and practical applications of intervals in DuckDB.
Continue reading2 Ways to Return the Number of Rows Changed by a SQL Statement in SQLite
SQLite provides several ways to determine how many rows are affected by SQL statements such as INSERT
, UPDATE
or DELETE
.
One way of achieving this is with the changes()
function. This function returns the number of rows modified by the most recent SQL statement executed in the current session.
Another way is with the .changes
dot command.
In this article, we’ll look at an example that uses these options to get the number of rows changed by various SQL statements.
Continue readingFix “Out of Range Error” When Using GENERATE_SUBSCRIPTS() in DuckDB
If you’re getting an “Out of Range Error” when using the generate_subscripts()
function in DuckDB, it could be that you’re specifying a non-existent dimension for the array.
DuckDB’s generate_subscripts()
function accepts the array as the first argument, and the dimension as the second argument. The second argument must correspond to an actual dimension present in the array.
To fix this issue, be sure to specify a dimension that actually exists in the array.
Continue readingRemoving Duplicates from a List in DuckDB with the LIST_DISTINCT() Function
DuckDB has a function called list_distinct()
that enables us to remove duplicate values from a list. Any value that appears more than once is “deduped” and is returned once in the resulting list.
The function also removes any NULL values.
Continue readingHow to Output Query Results as HTML Tables in the DuckDB CLI
The DuckDB command line interface (CLI) provides us with the ability to output query results in various formats. One of these formatting options is HTML.
This article shows you how to output your DuckDB query results as HTML tables, which can be useful when you need to include the results in web pages or documentation.
Continue reading4 Functions That Check Whether a List Contains a Given Value in DuckDB
When working with DuckDB, we may need to determine whether a specific value exists within a list or array. Fortunately, DuckDB offers four synonymous functions that enable us to accomplish this.
Continue readingUnnesting Lists & Structs with DuckDB’s UNNEST() Function
DuckDB has an unnest()
function that we can use to unnest lists and structs. Well, it can also be applied to NULL
, but that’ll return an empty result.
By “unnest” I mean it takes the list or struct, and it returns its contents as rows in a table. You might say that it converts lists and structs into tables, where each item in the list or struct becomes a row in the table.
Below are examples of using DuckDB’s unnest()
function to unnest lists and structs.
Fix ‘Binder Error: ‘list_has_all’ cannot compare lists of different types’ in DuckDB
If you’re getting an error that reads “Binder Error: ‘list_has_all’ cannot compare lists of different types” in DuckDB, it appears that you’re passing two different types of lists to the list_has_all()
function.
DuckDB’s list_has_all()
function accepts two lists as arguments. These need to be of the same type.
To fix this issue, make sure that both lists are of the same type.
Continue readingAdd Months to a Date in DuckDB
DuckDB provides us with an easy way to add one or more months to date values, as well as subtract from them. This applies to the various date related data types, such as DATE
and TIMESTAMP
.
Actually, DuckDB provides us with a choice; We can use the +
operator or the date_add()
function.