Change the Separator to a Comma in SQLite Query Results

By default, the SQLite command line shell formats query output as a pipe-separated list, without column headers.

If you need to output the results using commas instead of the pipe-symbol, you can specify this with the .separator dot command.

If you need to format your results as string literals, see How to Enclose Strings in Single Quotes. Or if you need any strings to be enclosed in double quotes, see How to Format Results as CSV.

Continue reading

Format SQLite Query Results as Columns with Column Headers

By default, when you connect to the SQLite command line shell and run a query, the result is returned as a pipe separated list.

You might have noticed that the results don’t include the column names, which can make your results confusing if you’re trying to read them, especially if the query returned many columns.

Fortunately, there’s an easy way to format the output so that it’s displayed as a column with column headers.

Continue reading

Create a Temporary Table in SQLite

When you create a table in SQLite, you can create it as a permanent table or as a temporary table.

When you create a table in a database that you’ve created, that would be a permanent table. A temporary table is created in the temp database.

To create a temporary table, you use the same syntax as creating a regular table. The difference is that you use either the TEMP or TEMPORARY keyword. You can also (or alternatively) prefix the table name with temp, which indicates that it will be created in the temporary database.

Continue reading