sqlite

Command line dot-commands

Introduction#

The sqlite3 command-line shell implements an additional set of commands (which are not available in programs that use the SQLite library).

Official documentation: Special commands to sqlite3

Exporting and importing a table as an SQL script

Exporting a database is a simple two step process:

sqlite> .output mydatabase_dump.sql
sqlite> .dump

Exporting a table is pretty similar:

sqlite> .output mytable_dump.sql
sqlite> .dump mytable

The output file needs to be defined with .output prior to using .dump; otherwise, the text is just output to the screen.

Importing is even simpler:

sqlite> .read mytable_dump.sql

This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow