Reader Level:
ARTICLE

How to Create Database Using Terminal in iPhone

Posted by Sachin Bhardwaj Articles | iOS November 21, 2012
This article provides a walkthrough of creating a database using a terminal window for iPhone or iPad application.
  • 0
  • 0
  • 3869

Introduction

In this article I will explain the step-by-step process of creating a database in iPhone.

Step 1

Open Finder from Dock by double-clicking on it.

Finder-in-iPhone.gif

Step 2

Go to the application and select utility and click on it.

application-utility-in-iPhone.jpg

Step 3

In utility is terminal; select it and click on it.

terminal-in-iPhone.jpg

Step 4

Now it shows in Dock, to open it double-click on it.

terminal-window-in-iPhone.jpg

Step 5

In the terminal window, to make a database, first assign it to the path where we want to make the database; for this we use these commands in terminal:

cd /Users/Sachin/Documents
mkdir Company
cd Company

set-path-in-iPhone.jpg

Step 6

Now you will see in documents, the Company name folder is automatically generated by terminal.

company-folder-in-iPhone.jpg

Step 7

To make the database using terminal we use this command in the terminal window:

sqlite3 EmployeeDatabase.sql

create-database-in-iPhone.jpg

Step 8

Now we will see the database file in the Company folder:

database-file-in-iPhone.jpg

Step 9

To create a table in this database we use the followinig in terminal:

CREATE TABLE Employees ( id INTEGER PRIMARY KEY, name VARCHAR(50), address VARCHAR(50), Position VARCHAR(20), image VARCHAR(255) );

create-table-in-iPhone.jpg

Step 10

To insert a record in the database we write in terminal:

INSERT INTO Employees (name, address, Position, image) VALUES ('Sachin', 'Jaipur', 'iPhone developer');
INSERT INTO Employees (name, address, Position, image) VALUES ('Kush', 'Delhi', 'iPhone developer');
INSERT INTO Employees (name, address, Position, image) VALUES ('Monish', 'Delhi', 'iPhone developer');

inset-record-in-iPhone.jpg

Step 11

To see the record we write in terminal:

SELECT * FROM Employees;

Step 12

To quit from the database we write in terminal:

.quit

how-to-quit-from-database-in-iPhone.jpg

after-quit-in-iPhone.jpg

Step 13

To clear the screen in terminal we use:

clear

clear-screen-in-iPhone.jpg

after-clear-screen-in-iPhone.jpg

COMMENT USING

Trending up