Commit 4c945dd0 authored by O'Reilly Media, Inc.'s avatar O'Reilly Media, Inc.
Browse files

Initial commit

parents
Loading
Loading
Loading
Loading

README.md

0 → 100644
+15 −0
Changes for README.md: 15 added lines, 0 removed lines.
Original line number Diff line number Diff line
## Example files for the title:  
  
# Using SQLite, by Jay Kreibich
  
[![Using SQLite, by Jay Kreibich](http://akamaicovers.oreilly.com/images/9780596521189/cat.gif)](https://www.safaribooksonline.com/library/view/title/9781449394592//)
  
The following applies to example files from material published by O’Reilly Media, Inc. Content from other publishers may include different rules of usage. Please refer to any additional usage rights explained in the actual example files or refer to the publisher’s website.
  
O'Reilly books are here to help you get your job done. In general, you may use the code in O'Reilly books in your programs and documentation. You do not need to contact us for permission unless you're reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from our books does not require permission. Answering a question by citing our books and quoting example code does not require permission. On the other hand, selling or distributing a CD-ROM of examples from O'Reilly books does require permission. Incorporating a significant amount of example code from our books into your product's documentation does require permission.
  
We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN.
  
If you think your use of code examples falls outside fair use or the permission given here, feel free to contact us at <permissions@oreilly.com>.
  
Please note that the examples are not production code and have not been carefully testing. They are provided "as-is" and come with no warranty of any kind.

UsingSQLiteCode.tar.gz

0 → 100755
+10.1 KiB

File added.

No diff preview for this file type.

ch05/example_data.sql

0 → 100644
+31 −0
Changes for ch05/example_data.sql: 31 added lines, 0 removed lines.
Original line number Diff line number Diff line

-- This file can be run inside sqlite3 
-- using the command ".read example_data.sql"

-- This data has been pre-loaded into the database
-- file "examples.sqlitedb".  You can open it in sqlite3
-- on the command line using the command "sqlite3 examples.sqlitedb"

.headers on
.mode column
.nullvalue [NULL]

.echo on


CREATE TABLE x ( a, b );
INSERT INTO x VALUES ( 1, 'Alice' );
INSERT INTO x VALUES ( 2, 'Bob' );
INSERT INTO x VALUES ( 3, 'Charlie' );

CREATE TABLE y ( c, d );
INSERT INTO y VALUES ( 1, 3.14159 );
INSERT INTO y VALUES ( 1, 2.71828 );
INSERT INTO y VALUES ( 2, 1.61803 );

CREATE TABLE z ( a, e );
INSERT INTO z VALUES ( 1, 100 );
INSERT INTO z VALUES ( 1, 150 );
INSERT INTO z VALUES ( 3, 300 );
INSERT INTO z VALUES ( 9, 900 );
+55 −0
Changes for ch05/example_queries.sql: 55 added lines, 0 removed lines.
Original line number Diff line number Diff line

-- This file can be run inside sqlite3 
-- using the command ".read example_queries.sql"

.headers on
.mode column
.nullvalue [NULL]

.echo on





SELECT * FROM x;
SELECT * FROM y;
SELECT * FROM z;

SELECT d, d*d AS dSquared FROM y;

SELECT * FROM x JOIN y;
SELECT * FROM x CROSS JOIN y;
SELECT * FROM x, y;

SELECT * FROM x JOIN y ON a = c;

SELECT * FROM x JOIN z ON x.a = z.a;

SELECT * FROM x JOIN z USING ( a );
SELECT * FROM x NATURAL JOIN z;

SELECT * FROM x LEFT OUTER JOIN z USING ( a );

SELECT * FROM x JOIN y ON x.a = y.c LEFT OUTER JOIN z ON y.c = z.a;

SELECT * FROM x AS x1 JOIN x AS x2 ON x1.a + 1 = x2.a;

SELECT * FROM x WHERE b = 'Alice';

SELECT * FROM y WHERE d BETWEEN 1.0 AND 3.0;

SELECT c, d, c+d AS sum FROM y WHERE sum < 4.0;

SELECT a, count(a) AS count FROM z GROUP BY a;

SELECT a, sum(e) AS total FROM z GROUP BY a;

SELECT a, sum(e), count(e), 
   sum(e)/count(e) AS expr, avg(e) AS agg
  FROM z GROUP BY a;

SELECT a, sum(e) AS total FROM z GROUP BY a HAVING total > 500;

SELECT * FROM y ORDER BY d;

ch05/examples.sqlitedb

0 → 100644
+4 KiB

File added.

No diff preview for this file type.

Loading