SlideShare a Scribd company logo
sqlite3 Command
Reference
The sqlite3 program is a command-line interface, or shell, that allows the user to
interactively issue SQL commands and display the results.
Command-Line Options
The sqlite3 tool understands the following command-line format:
sqlite3 [options...] [database [SQL_string]]
Options are given first, followed by an optional database filename. This database will
be opened as the main database
If a database filename is given, an optional SQL string can be provided. This string may
consist of one or more SQL statements separated by semicolons.
The interactive startup sequence will attempt to locate and open the .sqliterc init file
in the current user’s home directory. If the file exists, lines will be read and executed
before any other processing (including the command-line SQL string).
Interactive Dot-Commands
This section covers the sqlite3 dot-commands. Dot-commands control the mode and
configuration of the sqlite3 utility and, in some cases, the underlying SQLite library.
Normally, any input to the sqlite3 utility is assumed to be an SQL statement and is
passed to the SQLite library for processing. To distinguish these commands from SQL
statements, all of the dot-commands start with a period, or “dot.” Hence, the name.
.backup Perform a low-level copy of a database to file
Common Usage
.backup [database_name] filename
.bail Stop if an error is encountered
Common Usage
.bail switch
.databases List all of the currently attached databases
Common Usage
.databases
Description
The .databases command generates a table of all the currently attached databases. The format
of the table is:
.dump Produce an SQL dump file
Common Usage
.dump [table-pattern ...]
.echo Turn command echoing on or off
Common Usage
.echo switch
.exit Quit and exit the sqlite3 application
Common Usage
.exit
explain Format output for EXPLAIN SQL command
Common Usage
.explain [switch]
.headers Control display of column names and headers
Common Usage
.headers switch
.help Display help
Common Usage
.help
.import Import an external data file into a table
Common Usage
.import filename table-name
.indices Display all of the indexes associated with one or more tables
Common Usage
.indices [table-pattern]
.iotrace Direct I/O trace information to a file
Common Usage
.iotrace [filename|-]
.iotrace Direct I/O trace information to a file
Common Usage
.iotrace [filename|-]
.load Load a dynamic extension
Common Usage
.load filename [entry-point]
.log Turn logging on or off
Common Usage
.log (filename|stdout|stderr|off)
.mode Set the output mode
Common Usage
.mode (column[s]|csv|html|insert|line[s]|list|tabs|tcl) [table-name]
.nullvalue Set the string used to represent a NULL output
Common Usage
.nullvalue string
.output Set the output destination
Common Usage
.output (filename|stdout)
.prompt Set the command prompt
Common Usage
.prompt main [continue]
.quit Quit and exit the sqlite3 application
Common Usage
.quit
.read Execute SQL commands from a file
Common Usage
.read filename
.restore Perform a low-level copy of a database file to a database
Common Usage
.restore [database_name] filename
.schema Display SQL creation commands for schema
Common Usage
.schema [table-pattern]
.separator Define the string used as a column separator
Common Usage
.separator string
.tables Display the list of table and view names
Common Usage
.tables [table-pattern]
Description
The .tables command displays the list of names for all of the table and view objects that are
found in the main and temp databases.
.timeout Set a lock retry timer
Common Usage
.timeout milliseconds
.timer Enable or disable CPU time measurements
Common Usage
.timer switch
.width Set the display width for each column
Common Usage
.width numb [numb ...]
SQLite SQL Command Reference
This appendix lists the SQL commands and syntax that are supported by SQLite. SQL
statements consist of a single command and any required parameters. Command statements
are separated by a semicolon. Technically, standalone statements do not need
to be terminated with a semicolon, but most interactive environments require the use
of a semicolon to indicate that the current command statement is complete and should
be executed. For example, the C API sqlite3_exec() does not require that command
statements end with a semicolon, but interactive use of sqlite3 requires ending each
statement with a semicolon.
SQLite SQL Commands
The following SQL commands and syntax are supported by SQLite
Common Usage
ALTER TABLE database_name.table_name RENAME TO new_table_name;
ALTER TABLE database_name.table_name ADD COLUMN column_def...
ANALYZE Compute index meta-data
Syntax
Common Usage
ANALYZE;
ANALYZE database_name;
ANALYZE database_name.table_name;
ATTACH DATABASE Attach a database file
Syntax
Common Usage
ATTACH DATABASE 'filename' AS database_name;
BEGIN TRANSACTION Open an explicit transaction
Syntax
Common Usage
BEGIN;
BEGIN EXCLUSIVE TRANSACTION;
COMMIT TRANSACTION Finish and commit a transaction
Syntax
Common Usage
COMMIT;
CREATE INDEX Define and create a new table index
Syntax
Common Usage
CREATE INDEX index_name ON table_name ( column_name COLLATE NOCASE );
CREATE UNIQUE INDEX database_name.index_name ON table_name ( col1, col2 ,... );
CREATE TABLE Define and create a new table
Syntax

More Related Content

What's hot (15)

DOC
Oracle sql material
prathap kumar
 
PPT
mySQL and Relational Databases
webhostingguy
 
PPT
Oracle training in hyderabad
Kelly Technologies
 
PPTX
Oracle: DML
DataminingTools Inc
 
PPTX
8. sql
khoahuy82
 
PPTX
Commands of DML in SQL
Ashish Gaurkhede
 
PPTX
Ado.net by Awais Majeed
Awais Majeed
 
PPT
Sql dml & tcl 2
Dr. C.V. Suresh Babu
 
PPT
SQL DDL
Vikas Gupta
 
PPTX
Union based sql injection by Urdu Tutorials Point
Al Zarqali
 
ODP
Babitha2.mysql
banubabitha
 
DOCX
2
gbBehere
 
ODP
Mysqlppt
poornima sugumaran
 
Oracle sql material
prathap kumar
 
mySQL and Relational Databases
webhostingguy
 
Oracle training in hyderabad
Kelly Technologies
 
Oracle: DML
DataminingTools Inc
 
8. sql
khoahuy82
 
Commands of DML in SQL
Ashish Gaurkhede
 
Ado.net by Awais Majeed
Awais Majeed
 
Sql dml & tcl 2
Dr. C.V. Suresh Babu
 
SQL DDL
Vikas Gupta
 
Union based sql injection by Urdu Tutorials Point
Al Zarqali
 
Babitha2.mysql
banubabitha
 

Viewers also liked (20)

PDF
Python sqlite3
Alexey Bovanenko
 
PDF
Python sqlite3 - flask
Eueung Mulyana
 
PDF
Виктор Ашик — «Командная строка Unix»
Yandex
 
PDF
Виктор Ашик - Python, part 1
Yandex
 
PDF
Python. Строки
Alexey Bovanenko
 
PPT
Обработка символов в языке C
Alexey Bovanenko
 
PDF
Виктор Ашик - Профессии в мире информационных технологий
Yandex
 
PPTX
Advance sqlite3
Raghu nath
 
PDF
(140625) #fitalk sq lite 소개와 구조 분석
INSIGHT FORENSIC
 
PDF
SQLite3
cltru
 
KEY
SQLite Techniques
joaopmaia
 
PDF
Aula 06 - TEP - Introdução SQLite
Anderson Fabiano Dums
 
PPTX
Sqlite
Raghu nath
 
PPT
SQLite
Fabio Colan Wong
 
PDF
Fun with Python
Narong Intiruk
 
PDF
SQLite 3
Scott MacVicar
 
PPTX
SQLite: Light, Open Source Relational Database Management System
Tanner Jessel
 
PPTX
SQLite - Overview
Emanuele Bartolesi
 
PDF
Begin with Python
Narong Intiruk
 
Python sqlite3
Alexey Bovanenko
 
Python sqlite3 - flask
Eueung Mulyana
 
Виктор Ашик — «Командная строка Unix»
Yandex
 
Виктор Ашик - Python, part 1
Yandex
 
Python. Строки
Alexey Bovanenko
 
Обработка символов в языке C
Alexey Bovanenko
 
Виктор Ашик - Профессии в мире информационных технологий
Yandex
 
Advance sqlite3
Raghu nath
 
(140625) #fitalk sq lite 소개와 구조 분석
INSIGHT FORENSIC
 
SQLite3
cltru
 
SQLite Techniques
joaopmaia
 
Aula 06 - TEP - Introdução SQLite
Anderson Fabiano Dums
 
Sqlite
Raghu nath
 
Fun with Python
Narong Intiruk
 
SQLite 3
Scott MacVicar
 
SQLite: Light, Open Source Relational Database Management System
Tanner Jessel
 
SQLite - Overview
Emanuele Bartolesi
 
Begin with Python
Narong Intiruk
 
Ad

Similar to Sqlite3 command reference (20)

ODP
Introduction4 SQLite
Stanley Huang
 
PDF
The sqlite3 commnad line tool
punu_82
 
PDF
Sq lite module5
Highervista
 
PDF
IR SQLite Session #1
InfoRepos Technologies
 
PPT
MySql slides (ppt)
webhostingguy
 
PPTX
3-Chapter-Edit.pptx debre tabour university
alemunuruhak9
 
PDF
Complete SQL in one video by shradha.pdf
rahulashu699
 
PPTX
Sq lite
vinoth raj
 
PPT
Os Owens
oscon2007
 
PPTX
Introduction To MySQL Lecture 1
Ajay Khatri
 
PPTX
Python SQLite3...
VikasTuwar1
 
PDF
DEF CON 27 -OMER GULL - select code execution from using sq lite
Felipe Prado
 
PPT
MySQL Database System Hiep Dinh
webhostingguy
 
PPT
mysqlHiep.ppt
webhostingguy
 
PPT
Mysql
Rathan Raj
 
DOCX
SQLiteWrittenExplanation
Christopher Wimble
 
PPT
Geek Austin PHP Class - Session 4
jimbojsb
 
PDF
MySQL for beginners
Saeid Zebardast
 
PDF
•Design (create) 3 questions for a quiz show game and design regular.pdf
jyothimuppasani1
 
PDF
Chapter – 6 SQL Lab Tutorial.pdf
TamiratDejene1
 
Introduction4 SQLite
Stanley Huang
 
The sqlite3 commnad line tool
punu_82
 
Sq lite module5
Highervista
 
IR SQLite Session #1
InfoRepos Technologies
 
MySql slides (ppt)
webhostingguy
 
3-Chapter-Edit.pptx debre tabour university
alemunuruhak9
 
Complete SQL in one video by shradha.pdf
rahulashu699
 
Sq lite
vinoth raj
 
Os Owens
oscon2007
 
Introduction To MySQL Lecture 1
Ajay Khatri
 
Python SQLite3...
VikasTuwar1
 
DEF CON 27 -OMER GULL - select code execution from using sq lite
Felipe Prado
 
MySQL Database System Hiep Dinh
webhostingguy
 
mysqlHiep.ppt
webhostingguy
 
Mysql
Rathan Raj
 
SQLiteWrittenExplanation
Christopher Wimble
 
Geek Austin PHP Class - Session 4
jimbojsb
 
MySQL for beginners
Saeid Zebardast
 
•Design (create) 3 questions for a quiz show game and design regular.pdf
jyothimuppasani1
 
Chapter – 6 SQL Lab Tutorial.pdf
TamiratDejene1
 
Ad

More from Raghu nath (20)

PPTX
Mongo db
Raghu nath
 
PDF
Ftp (file transfer protocol)
Raghu nath
 
PDF
MS WORD 2013
Raghu nath
 
PDF
Msword
Raghu nath
 
PDF
Ms word
Raghu nath
 
PDF
Javascript part1
Raghu nath
 
PDF
Regular expressions
Raghu nath
 
PDF
Selection sort
Raghu nath
 
PPTX
Binary search
Raghu nath
 
PPTX
JSON(JavaScript Object Notation)
Raghu nath
 
PDF
Stemming algorithms
Raghu nath
 
PPTX
Step by step guide to install dhcp role
Raghu nath
 
PPTX
Network essentials chapter 4
Raghu nath
 
PPTX
Network essentials chapter 3
Raghu nath
 
PPTX
Network essentials chapter 2
Raghu nath
 
PPTX
Network essentials - chapter 1
Raghu nath
 
PPTX
Python chapter 2
Raghu nath
 
PPTX
python chapter 1
Raghu nath
 
PPTX
Linux Shell Scripting
Raghu nath
 
PPTX
Perl
Raghu nath
 
Mongo db
Raghu nath
 
Ftp (file transfer protocol)
Raghu nath
 
MS WORD 2013
Raghu nath
 
Msword
Raghu nath
 
Ms word
Raghu nath
 
Javascript part1
Raghu nath
 
Regular expressions
Raghu nath
 
Selection sort
Raghu nath
 
Binary search
Raghu nath
 
JSON(JavaScript Object Notation)
Raghu nath
 
Stemming algorithms
Raghu nath
 
Step by step guide to install dhcp role
Raghu nath
 
Network essentials chapter 4
Raghu nath
 
Network essentials chapter 3
Raghu nath
 
Network essentials chapter 2
Raghu nath
 
Network essentials - chapter 1
Raghu nath
 
Python chapter 2
Raghu nath
 
python chapter 1
Raghu nath
 
Linux Shell Scripting
Raghu nath
 

Recently uploaded (20)

PPTX
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
PDF
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
PDF
SSHS-2025-PKLP_Quarter-1-Dr.-Kerby-Alvarez.pdf
AishahSangcopan1
 
PDF
community health nursing question paper 2.pdf
Prince kumar
 
PDF
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
PPSX
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
PDF
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
PPTX
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
PDF
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PPTX
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
PPTX
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
PPTX
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
PPTX
Soil and agriculture microbiology .pptx
Keerthana Ramesh
 
PPTX
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PDF
The Different Types of Non-Experimental Research
Thelma Villaflores
 
PPTX
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PPTX
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
SSHS-2025-PKLP_Quarter-1-Dr.-Kerby-Alvarez.pdf
AishahSangcopan1
 
community health nursing question paper 2.pdf
Prince kumar
 
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
Soil and agriculture microbiology .pptx
Keerthana Ramesh
 
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
The Different Types of Non-Experimental Research
Thelma Villaflores
 
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 

Sqlite3 command reference

  • 2. The sqlite3 program is a command-line interface, or shell, that allows the user to interactively issue SQL commands and display the results.
  • 3. Command-Line Options The sqlite3 tool understands the following command-line format: sqlite3 [options...] [database [SQL_string]] Options are given first, followed by an optional database filename. This database will be opened as the main database
  • 4. If a database filename is given, an optional SQL string can be provided. This string may consist of one or more SQL statements separated by semicolons.
  • 5. The interactive startup sequence will attempt to locate and open the .sqliterc init file in the current user’s home directory. If the file exists, lines will be read and executed before any other processing (including the command-line SQL string).
  • 6. Interactive Dot-Commands This section covers the sqlite3 dot-commands. Dot-commands control the mode and configuration of the sqlite3 utility and, in some cases, the underlying SQLite library. Normally, any input to the sqlite3 utility is assumed to be an SQL statement and is passed to the SQLite library for processing. To distinguish these commands from SQL statements, all of the dot-commands start with a period, or “dot.” Hence, the name.
  • 7. .backup Perform a low-level copy of a database to file Common Usage .backup [database_name] filename
  • 8. .bail Stop if an error is encountered Common Usage .bail switch .databases List all of the currently attached databases Common Usage .databases Description The .databases command generates a table of all the currently attached databases. The format of the table is:
  • 9. .dump Produce an SQL dump file Common Usage .dump [table-pattern ...] .echo Turn command echoing on or off Common Usage .echo switch
  • 10. .exit Quit and exit the sqlite3 application Common Usage .exit explain Format output for EXPLAIN SQL command Common Usage .explain [switch]
  • 11. .headers Control display of column names and headers Common Usage .headers switch .help Display help Common Usage .help
  • 12. .import Import an external data file into a table Common Usage .import filename table-name
  • 13. .indices Display all of the indexes associated with one or more tables Common Usage .indices [table-pattern]
  • 14. .iotrace Direct I/O trace information to a file Common Usage .iotrace [filename|-]
  • 15. .iotrace Direct I/O trace information to a file Common Usage .iotrace [filename|-]
  • 16. .load Load a dynamic extension Common Usage .load filename [entry-point]
  • 17. .log Turn logging on or off Common Usage .log (filename|stdout|stderr|off)
  • 18. .mode Set the output mode Common Usage .mode (column[s]|csv|html|insert|line[s]|list|tabs|tcl) [table-name]
  • 19. .nullvalue Set the string used to represent a NULL output Common Usage .nullvalue string
  • 20. .output Set the output destination Common Usage .output (filename|stdout)
  • 21. .prompt Set the command prompt Common Usage .prompt main [continue]
  • 22. .quit Quit and exit the sqlite3 application Common Usage .quit
  • 23. .read Execute SQL commands from a file Common Usage .read filename
  • 24. .restore Perform a low-level copy of a database file to a database Common Usage .restore [database_name] filename
  • 25. .schema Display SQL creation commands for schema Common Usage .schema [table-pattern]
  • 26. .separator Define the string used as a column separator Common Usage .separator string
  • 27. .tables Display the list of table and view names Common Usage .tables [table-pattern] Description The .tables command displays the list of names for all of the table and view objects that are found in the main and temp databases.
  • 28. .timeout Set a lock retry timer Common Usage .timeout milliseconds
  • 29. .timer Enable or disable CPU time measurements Common Usage .timer switch
  • 30. .width Set the display width for each column Common Usage .width numb [numb ...]
  • 31. SQLite SQL Command Reference This appendix lists the SQL commands and syntax that are supported by SQLite. SQL statements consist of a single command and any required parameters. Command statements are separated by a semicolon. Technically, standalone statements do not need to be terminated with a semicolon, but most interactive environments require the use of a semicolon to indicate that the current command statement is complete and should be executed. For example, the C API sqlite3_exec() does not require that command statements end with a semicolon, but interactive use of sqlite3 requires ending each statement with a semicolon.
  • 32. SQLite SQL Commands The following SQL commands and syntax are supported by SQLite
  • 33. Common Usage ALTER TABLE database_name.table_name RENAME TO new_table_name; ALTER TABLE database_name.table_name ADD COLUMN column_def...
  • 34. ANALYZE Compute index meta-data Syntax
  • 36. ATTACH DATABASE Attach a database file Syntax
  • 37. Common Usage ATTACH DATABASE 'filename' AS database_name;
  • 38. BEGIN TRANSACTION Open an explicit transaction Syntax
  • 40. COMMIT TRANSACTION Finish and commit a transaction Syntax
  • 42. CREATE INDEX Define and create a new table index Syntax
  • 43. Common Usage CREATE INDEX index_name ON table_name ( column_name COLLATE NOCASE ); CREATE UNIQUE INDEX database_name.index_name ON table_name ( col1, col2 ,... );
  • 44. CREATE TABLE Define and create a new table Syntax