1 / 9

SQLite

SQLite. What is SQLite?. Open Source Database embedded in Android SQL syntax Requires small memory at runtime (250 Kbytes) Lightweight More info at: http ://www.sqlite.org. Types in SQLite. TEXT (similar to String in Java) INTEGER  (similar to long in Java)

maxima
Download Presentation

SQLite

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SQLite CS440

  2. What is SQLite? • Open Source Database embedded in Android • SQL syntax • Requires small memory at runtime (250 Kbytes) • Lightweight • More info at: http://www.sqlite.org CS440

  3. Types in SQLite • TEXT (similar to String in Java) • INTEGER (similar to long in Java) • REAL (similar to double in Java) CS440

  4. Getting started • Download SQLite: http://www.sqlite.org/download.html • Open a command prompt • Create your first db: • sqlite3 myDB.db • create table tbl1(one varchar(10), two smallint); • insert into tbl1 values('hello!',10); • insert into tbl1 values('goodbye', 20); • select * from tbl1; CS440

  5. CREATE • Create a new table to add your data • Tables in databases are like excel spreadsheets CREATE TABLE employers ( _id INTEGER PRIMARY KEY, company_name TEXT); CREATE TABLE employees ( name TEXT, annual_salary REAL NOT NULL CHECK, employer_id REFERENCES employers(_id)); CS440

  6. SQLite Types • TEXT • REAL • BLOB • INTEGER CS440

  7. INSERT • Adds a new data row INSERT INTO contacts(first_name) VALUES(“Thomas”); INSERT INTO employers VALUES(1, “Acme Balloons”); INSERT INTO employees VALUES(“Wile E. Coyote”, 1000000.000, 1); CS440

  8. SELECT • Querying a database • Returns one or multiple rows of results SELECT * FROM contacts; SELECT first_name, height_in_meters FROM contacts WHERE last_name = “Smith”; SELECT employees.name, employers.name FROM employees, employers WHERE employee.employer_id = employer._id ORDER BY employer.company_name ASC; CS440

  9. References • http://www.vogella.de/articles/AndroidSQLite/article.html#overview CS440

More Related