-Handling and Persisting Data
07-15
CREATE TABLE contacts (
first_name TEXT,
last_name TEXT,
phone_number TEXT,
height REAL);
DROP TABLE contacts;
CREATE TABLE employers (
_id INTEGER PRIMARY KEY,
company_name TEXT);
CREATE TABLE employees (
name TEXT,
salary REAL NOT NULL CHECK (salary > 0),
employer_id REFERENCES employers(_id));
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;
INSERT INTO contacts(first_name)
VALUES("Thomas");
INSERT INTO employers
VALUES(1, "Acme Balloons");
INSERT INTO employees
VALUES("Wile E. Coyote", 100000.000, 1);
UPDATE contacts
SET height_in_meters = 10, last_name = "Jones";
UPDATE employees
SET annual_salary = 200000.00
WHERE employer_id = (
SELECT _id
FROM employers
WHERE company_name = "Acme Balloons");
Cursor
SQLiteOpenHelper
SQLiteQueryBuilder
input: "Mark"
INSERT INTO student
VALUES( "Mark" );
input: "Mark"); DROP TABLE student;
CREATE TABLE haha(
hahaha TEXT
INSERT INTO student
VALUES( "Mark");
DROP TABLE student;
CREATE TABLE haha(
hahaha TEXT);