SQLite

00. Basic

## ------------------| Open database
sqlite3 <db_file.sqlite3>

## ------------------| Config display output
.headers on
.mode table --wrap 200 --wordwrap off --noquote
.mode column    # Displays each row in a table-like format, with column headers separated from the data. 
.mode list      # Displays each row as a list of values, with columns separated by a pipe character.
.mode line      # Similar to list mode, but displays each row on a separate line
.mode csv       # Outputs query results in Comma-Separated Values format, which can be useful for exporting data.
.mode insert    # Formats query results as SQL INSERT statements, which can be used to insert the data back into another table.
.mode html      # Outputs query results in HTML table format, which can be useful for web applications or reporting.
.mode ascii     # Displays query results in a simple ASCII text format.
.mode box       # Formats query results into a box-like structure.
.mode json      # Outputs query results in JSON format.
.mode markdown  # Formats query results in Markdown syntax.
.mode qbox      # Variant of the box mode, providing a different style for box-like formatting.
.mode quote     # This mode quotes all values, including NULLs, to make them safe for use in other SQL statements.
.mode table     # This mode formats query results as a plain-text table, similar to the output of a spreadsheet.
.mode tabs      # This mode separates columns with tabs, suitable for importing into spreadsheet applications or text editors.
.mode tcl       # Formats query results as a TCL list, suitable for integration with TCL scripts or applications.

## ------------------| List all databaeses
.databases

## ------------------| Show Tables
.tables
SELECT name FROM sqlite_master WHERE type='table';

## ------------------| Show Columns
PRAGMA table_info(<TB_NAME>);

## ------------------| Show data
select * from <TB_NAME>;

## ------------------| Exit
.q

Last updated