once the command with file name if you want only the result of next query to be redirected. output and all subsequent query results will be written to that file. Just put the name of an output file as an argument to. You can change this using ".output" and ".once" commands. separator command to change separator.īy default, It sends query results to standard output. The Program is able to show the results of a query in eight different formats: "csv", "column","html","insert", "line", "list", "tabs", "tcl".mode command is use to switch between these output formats. You can show attribute name in query result by running. List the tables in the selected database. Let's understand some other important commands. We saw ".help" commands list all the dot commands. Special commands to sqlite3(dot -commands) mode columnĭelete, Alter, Drop etc have same syntax as sql. It will show the result in a column format. mode column to prompt and then perform select query. It shows the result in default mode (list). You can fetch data from table with select statement sqlite> select * from student > insert into student (reg_no, name, marks) values (103, 'Rakesh', 91) Fetching data > insert into student (reg_no, name, marks) values (102, 'Avinash', 86) schema studentĮnter the following command one by one sqlite> insert into student (reg_no, name, marks) values (101, 'Pradip', 87) You can also see the schema of the table using. There is only one table student in my case.
You can see the list of tables in the selected database by. It will create a student table with above attributes. Let's create a student table with attributes:Įnter the following commands in terminal sqlite> create table student ( The difference between "sqlite3" and "sqlite3 dbname.db" command is the first one will create a temporary database for the session and will expire when the session is closed. If exists then open the database contained in the file. It will create "example.db" (You can put your choice of name in place of "example.db") database file ( if not exists). timer ON|OFF Turn the CPU timer measurement on or offīefore explaining these dot commands, let's see some of the basic database operations.įirst run ".quit" command to end the session. vfsname ?AUX? Print the name of the VFS stack trace FILE|off Output each SQL statement as it is run timeout MS Try opening locked tables for MS milliseconds If TABLE specified, only list tables matching show Show the current values for various settings separator STRING Change separator used by output mode and. If TABLE specified, only show tables matching schema ?TABLE? Show the CREATE statements restore ?DB? FILE Restore content of DB (default "main") from FILE prompt MAIN CONTINUE Replace the standard prompts open ?FILENAME? Close existing database and reopen FILENAME nullvalue STRING Use STRING in place of NULL values mode MODE ?TABLE? Set output mode where MODE is one of:Ĭolumn Left-aligned columns. load FILE ?ENTRY? Load an extension library If TABLE specified, only show indices for tables
indices ?TABLE? Show names of all indices import FILE TABLE Import data from FILE into TABLE header(s) ON|OFF Turn display of headers on or off explain ?ON|OFF? Turn output mode suitable for EXPLAIN on or off. If TABLE specified, only dump tables matching databases List names and files of attached databases bail ON|OFF Stop after hitting an error. backup ?DB? FILE Backup DB (default "main") to FILE These meta commands are also called "dot" commands because they are preceded by a dot. help command list all the meta commands and their descriptions. The second line tells to enter ".help" for instructions. The very first line shows the version and release date and time of sqlite3. $ sqlite3Įnter SQL statements terminated with a " " Now Open a terminal and Execute "sqlite3", you will see the following lines with prompt. Sudo dnf install sqlite-devel sqlite-tcl sqlite-jdbc To access SQLite databases from various programming languages (C, Tcl, Java), the language bindings need to be installed