HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlMinor

Create Sqlite3 database

Submitted by: @import:stackexchange-dba··
0
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.

Solution

It's because you haven't actually done anything.

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> .quit


File not created:

phil@ironforge:~$ ls -al test.db
ls: cannot access test.db: No such file or directory


Do 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> .quit


File 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> .quit
phil@ironforge:~$ ls -al test.db
ls: cannot access test.db: No such file or directory
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> .quit
phil@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.