SQLite3 cheatsheet

Commandline

  • open database sqlite3 file.db
  • show tables .tables
  • quit .quit
  • select: select * from book;
  • columns PRAGMA table_info(book);
  • create sytnax: .schema book;
  • show column headers: .headers ON

  • open a database

    sqlite3 my_stuff_database.db
  • print database structure

    .schema
  • print database structure and data

    .dump
  • turn on / off column names in results

    .explain on
    .explain off
  • show databases

    .databases
  • show tables

     .tables
  • show current settings

    .show
  • show headings

    .header on
  • show columns

    .mode column
  • show timer (how long query took)

    .mode timer
  • quit

    .quit
  • show index

    .indices [table]
  • rename a table

     alter table department rename to dept;