This article is for beginners of SQLite.
What is SQLite?
SQLite is ACID compliant relational database management system. It is relatively small in comparison to other database libraries; its size is around 250kb. As it uses simple function calls than inter-process communication, it solves lot of problems & it becomes integral part of program.
Features of SQLite
– No installation/configuration needed
– Cross platform
– Compact Size of library (250kb)
– Support for many language bindings like C/C++/Java/Ruby and more
– SQL92 standard compliant
– Single executable for writing database & connecting to applications.
Getting Started
You can download the binary from the SQLite website here. Other than binary, it’s good to download the documentation as it covers much more.After downloading the Sqlite, you can extract the Sqlite anywhere but it is good practice that you create folder in drive as c”/sqlite or d:/sqlite “ to remember where you extracted it. After extracting it in folder you can see it is single executable file “sqlite”. You can click on that executable to start writing commands on that CLI.
Exiting SQLite CLI
You can exit the SQLite prompt by using CTR+C.
Creating database
– To create a database, you can type the following command:
sqlite3 demo.db
this demo.db is your database name, you can change it to any name of your choice.
Create Table
– To create table you can enter the following command:
create table population(no INTEGER PRIMARY KEY, city TEXT);
This will create simple table which holds information about population with no as primary key.
Inserting data
– To insert data in your table, type the following commands:
insert into population(city, no) values(‘Sydney’,1);
-This will insert the information in first row. Please note that you enter quotes for your text/char data while inserting in table.
Display table
To show the information inserted into the table, use the following command:
Select *from population;
Deleting data from table
To delete any row or column from the database, you can use the following command:
DELETE FROM population where 1;
These are some of the basic operations that you can do with SQLite. There are plenty of other statements like DROP, Update etc. You can use any good SQL book or SQLite documentation for syntax usage.
If you’re java developer and looking for JDBC driver for SQLite then you can access that here. I’ll update this page in future to add more information related to SQLite.Hope the information above helps. If you’ve any questions then please let me know. If you’ve more information related to SQLite and would like to add here, then feel free to provide it in comments.