I'm trying to learn SQL through "Learn SQL the Hard Way" and I am having difficulty with the the command prompt. In particular, I am having trouble with the 3rd exercise.
I am able to create a database from ex2.sql by calling
sqlite3 ex3.db < ex2.sql
This should build a database with the schema:
CREATE TABLE person (
id INTEGER PRIMARY KEY,
first_name TEXT,
last_name TEXT,
age INTEGER
);
CREATE TABLE pet (
id INTEGER PRIMARY KEY,
name TEXT,
breed TEXT,
age INTEGER,
dead INTEGER
);
CREATE TABLE person_pet (
person_id INTEGER,
pet_id INTEGER
);
Calling .schema on sqlite3 ex3.db prints out exactly this.
Then I use ex3.sql which has the contents:
INSERT INTO person (id, first_name, last_name, age)
VALUES (0, "Zed", "Shaw", 37);
INSERT INTO pet (id, name, breed, age, dead)
VALUES (0, "Fluffy", "Unicorn", 1000, 0);
INSERT INTO pet VALUES (1, "Gigantor", "Robot", 1, 1);
I insert to ex3.db by saying:
sqlite3 -echo ex3.db < ex3.sql
According to the book, this should insert the values from ex3.sql into ex3.db while printing out what it is doing. However, when I type the above into cmd it prints nothing. And when I call
sqlite3 ex3.db
select * from person;
it still shows nothing. My guess is that either the database file is not updating, something with my install went wrong, or I'm messing something else up here. Appreciate any help that can be given.
Aucun commentaire:
Enregistrer un commentaire