This tutorial explains, how to create a database in SQLite. If you are going to work with SQLite database software, you must first create a database and then create tables in that database. If you don’t know how install and configure SQLite, use the link
After configuring SQLite, you can access it through command prompt. When using command prompt you must connect with SQLite database or else it will act as temporary database and if you close the window, it will erase all data you created. If you type sqlite3 in cmd it will create temporary database like below
Once you close this window, this will erase all data you created. So while connecting to SQLite database use the appropriate database name. Creating database is very easy in SQLite. Use the below syntax to create a database or you can connect with existing database
Here .db is the SQLite database extension. If database already exist, it will connect to the mentioned database or else it will create new database. Here we are creating a database, test.db, in E drive. sqlite3 test.db
Actually we do not have any database named test. So the above command will create a database in E drive. Once you close the editor, the data you created, will be stored in the test database. Again you can run the above command to connect with SQLite database.
The SELECT keyword is the most important keyword one must know while learning SQLite Database. Since creating a table and inserting data into that table is not tough as retrieving data. So if you want to practice SELECT you must have some sample table to work. Here we have collected some mobile phones' data from e-retailers and internet. We have the aforementioned database for you to practice.
The database contains 5 tables, which are mentioned below
1. Mobile_sales_details – this table contains mobile names and their price, discount, camera size, etc.
2. Mobile_rating – all mobiles rating from 5 star to 1 star
3. Brand_details - available brands in mobile and location of those brands and year of brand started, etc.
4. Company_location – it holds country names
5. Country_codes – it holds country names and their standard codes.
Download sample database
If you want to know the source code of the sample database use the below link