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

  1. CREATE TABLE testtable (id integer primary key, name text);

2, Insert into table

  1. INSERT INTO "testtable" VALUES(1,'Joseph');

3, Create a view

  1. CREATE VIEW testview AS select * from testtable;

4, Add index

  1. CREATE INDEX testindex on testtable(name);

5, Select command

  1. SELECT * from testtable;

6, Removing tables, triggers, views, and indexes

  1. drop index indexname
  2. drop table tablename
  3. drop trigger triggername
  4. 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.

  1. user@host:~$ sqlite3 test.db '.dump' > dbbackup

You could also compress the output:

  1. 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:

  1. 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.

Comments

thanks for this good article
العاب سبونج بوب

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

i found some good site which provide nice tutorials this is one of them

http://androidtutorials60.blogspot.com/2011/04/sqlite-db-example-android...

this is also nice one

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

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 Pandora in a world of adults Pandora Bracelets

Thanks for the valuable information, I'm also getting the same error in exporting my db, any ideas?

Thank you

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 is an error when I execute the command.

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.