snippetsqlMinor
Create Sqlite3 database
Viewed 0 times
sqlite3databasecreate
Problem
I am simply trying to create a database.
In my account's home directory, I type in
sqlite3 test.db
Then once I am in sqlite, I type
.quit
That should create the database file in the current directory.
But there is no such file!
I tried it in other directories (chmodded to 777) to no avail.
What am I doing wrong?
OS is Ubuntu 14.04 LTS. Sqlite version 3.8.2.
In my account's home directory, I type in
sqlite3 test.db
Then once I am in sqlite, I type
.quit
That should create the database file in the current directory.
But there is no such file!
I tried it in other directories (chmodded to 777) to no avail.
What am I doing wrong?
OS is Ubuntu 14.04 LTS. Sqlite version 3.8.2.
Solution
It's because you haven't actually done anything.
Doing nothing:
File not created:
Do something:
File has been created:
Doing nothing:
phil@ironforge:~$ sqlite3 test.db
SQLite version 3.8.2 2013-12-06 14:53:30
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .quitFile not created:
phil@ironforge:~$ ls -al test.db
ls: cannot access test.db: No such file or directoryDo something:
phil@ironforge:~$ sqlite3 test.db
SQLite version 3.8.2 2013-12-06 14:53:30
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> create table a (b number);
sqlite> .quitFile has been created:
phil@ironforge:~$ ls -al test.db
-rw-r--r-- 1 phil phil 2048 Oct 21 09:31 test.db
phil@ironforge:~$Code Snippets
phil@ironforge:~$ sqlite3 test.db
SQLite version 3.8.2 2013-12-06 14:53:30
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .quitphil@ironforge:~$ ls -al test.db
ls: cannot access test.db: No such file or directoryphil@ironforge:~$ sqlite3 test.db
SQLite version 3.8.2 2013-12-06 14:53:30
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> create table a (b number);
sqlite> .quitphil@ironforge:~$ ls -al test.db
-rw-r--r-- 1 phil phil 2048 Oct 21 09:31 test.db
phil@ironforge:~$Context
StackExchange Database Administrators Q#118708, answer score: 5
Revisions (0)
No revisions yet.