SQLite Basics
| SQLite is an embedded SQL database engine. Unlike most other SQL databases, SQLite does not have a separate server process. SQLite reads and writes directly to ordinary disk files. A complete SQL database with multiple tables, indices, triggers, and views, is contained in a single disk file. |
|
Basic SQLite commands:
1, Create table
- CREATE TABLE testtable (id integer primary key, name text);
2, Insert into table
- INSERT INTO "testtable" VALUES(1,'Joseph');
3, Create a view
- CREATE VIEW testview AS select * from testtable;
4, Add index
- CREATE INDEX testindex on testtable(name);
5, Select command
- SELECT * from testtable;
6, Removing tables, triggers, views, and indexes
- drop index indexname
- drop table tablename
- drop trigger triggername
- drop view viewname
Export a database
You can export (backup) your database using the command-line program and .dump. It works the same way it does from the SQLite shell. But we are going to want the output to go to a file and not the screen so we will redirect it to a file called dbbackup.
- user@host:~$ sqlite3 test.db '.dump' > dbbackup
You could also compress the output:
- user@host:~$ sqlite3 test.db '.dump' | gzip -c > dbbackup.gz
The following example will use a file called statements.sql and import them into our test.db file:
- user@host:~$ sqlite3 test.db < statements.sql
Data types in SQLite v3
- NULL - The value is a NULL value.
- INTEGER - The value is a signed integer, stored in 1, 2, 3, 4, 6, or 8 bytes depending on the magnitude of the value.
- REAL - The value is a floating point value, stored as an 8-byte IEEE floating point number.
- TEXT - The value is a text string, stored using the database encoding (UTF-8, UTF-16BE or UTF-16LE).
- BLOB - The value is a blob of data, stored exactly as it was input.
New tutorials from Helloandroid
Recent Apps
Android on Twitter
-
@619Apps (iPhone App Developer)'Xperia Sola' trademark hints at another possible Sony handset for the U.S. - http://t.co/atxhdfFz #iPhone #android #apps
2 hours 35 min ago -
@ayakaarchdia233 (Love)I've just received an achievement: Discriminating Shopper https://t.co/LDVOSV6I #Android #Androidgames
2 hours 35 min ago -
@DevrynBluelagon (Devryn Bluelagon)I've just received an achievement: Novice Photographer https://t.co/NpjOoveN #Android #Androidgames
2 hours 35 min ago -
@games_lma (leila marie ashley)I've just received an achievement: Persistent Shopper https://t.co/vTs6DSor #Android #Androidgames
2 hours 35 min ago -
@hawkhugh (hawkhugh)Apple's iPad3 http://t.co/T9dSUJA9 #apple #ipad3 #iphone #android
2 hours 35 min ago
Poll
Useful resources
Android Development Projects
- Android App: GPS: Form: Database: Website by danishayubb
- Jquery Mobile Project 01 by menfirst
- Simple Android App to load our Mobile Site - Hiring NOW! by steadysystems
- mobile app by ultimaterrrr
- android apps by vaneet08
- Online food shopping app (anroid) by akshaynawale
- Android eBook / reader Application by bamohriz
- Android app 50k downloads by nhcteam
- Beautiful Android Live Wallpaper by wahid2o11
- App downloads by nhcteam



Comments
thanks for this good
thanks for this good article
العاب سبونج بوب
Hi, i think that i saw you
Hi, i think that i saw you visited my web site so i came to “return the favor”.I’m attempting to find things to improve my site!I suppose its ok to use a few of your ideas!Simply desire to say your article is as amazing. The clearness in your post is just spectacular and i can assume you are an expert on this subject. Well with your permission allow me to grab your RSS feed to keep updated with forthcoming post
العاب ودردشة منتديات بناتى
منتدى بناتى
منتدى تصميم
العاب بنات لها
nice tutorial
nice tutorial
i found some good site which provide nice tutorials this is one of them
http://androidtutorials60.blog spot.com/2011/04/sqlite-db-exa mple-android...
this is also nice one
I definitely love your post.
I definitely love your post. This kind of piece can really help readers to widen their knowledge regarding this important matter. Keep up the great job!
Las vegas seo firm
Thomas Sabo jewellery
I totally like the useful
Thomas Sabo Charms
info shared in the
article.I like your ideas about
Thomas Sabo Bracelet
online and
I hope
Thomas Sabo Charms sale
in the
future there can be more bright articles like this from you.and hope there can be more great
resources like this. why jewellery lines cant cater a good offer more toward individual sides of
men. Thomas Sabo has achieved that with his actually developing collection of
Thomas sabo UK
sterling silver
Thomas sabo
and necklaces.
it is sometimes hard to
it is sometimes hard to Pandora in a world of adults Pandora Bracelets
SQL
Thanks for the valuable information, I'm also getting the same error in exporting my db, any ideas?
Thank you
Boolean values
Please make a note that sqlite doesn't not support Boolean values.
Don't make the same mistakes I did...
:)
I can't export my db. There
I can't export my db. There is an error when I execute the command.
SQL
Again you have provided us with simple, yet concise, instructions for exporting and importing sql dbs. Thank you.
casinò online
Gamble at this casinò today and you will never want to gamble at any other casino again.