How to create SQLite3 database using mac Terminal.?


1. Using spolight(press the cmd+space) search the terminal, Terminal its a default editor avilable in mac. or in the Menu go on Application -> Terminal.

2.First select the location where you want save your database file. i choose desktop. then type the command CD Desktop (semicoln ; not require).

3. type the command “SQlite3 database_name.sqlite” and press enter. for your understanding purpose i create database name as MyCircle.
ex – SQLite3 MyCircle.sql
*note: you can give extension of your database file as .sql,.sqlite,.db

4. after creating the database for using .databases command you can show the list of databases.
ex – .databases;

5. after if u create successful database then required to go for create the table for storing and manage the data.
ex. create table Table_Name(field_name1, type, field_name2 type,fild_n type_n); (After writing query must and should semicolon ; required otherwise execution time you get output like…>)
ex. create table Friends(ID integer primary key autoincrement, Name varchar(60), Age int);
*note :- this Friends table belong to MyCircle database.

6.After without any error creating table you need for feel the some data in that table then go for insert statement.
ex. insert inot table_name values(value1,value2,value_n);
*note :- fill the value as per datatype. if datatype is varchar then require data in single qoute ‘ ‘ where as integer type no required.
ex. insert into Friends values(1,’MyCodeTips’,21);
explanation:- ID is 1, Name type as a varchar then require ‘MyCodeTips’.


Passionate about coding and software development holding 10+ Years of experience including 6+ years of experience on Mobile application Development.

More Posts