Can't create empty database

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Can't create empty database

L Anderson
Googling on how to create a sqlite database (empty one) it appears
I need only do 'sqlite3 test.db'.  However, when I try that I get:

->sqlite3 test.db
SQLite version 3.7.13 2012-06-11 02:05:22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite>

however, no database is created.  What am I doing wrong and what
do I need to do to create an empty database 'test.db'?

Thanks,

LA

_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Can't create empty database

Patrik Nilsson-2
sqlite3 test.db ""

It creates an empty file, zero bytes long.

On 06/25/2012 10:01 AM, L Anderson wrote:

> Googling on how to create a sqlite database (empty one) it appears
> I need only do 'sqlite3 test.db'.  However, when I try that I get:
>
> ->sqlite3 test.db
> SQLite version 3.7.13 2012-06-11 02:05:22
> Enter ".help" for instructions
> Enter SQL statements terminated with a ";"
> sqlite>
>
> however, no database is created.  What am I doing wrong and what
> do I need to do to create an empty database 'test.db'?
>
> Thanks,
>
> LA
>
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>

_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Can't create empty database

oliver1804
In reply to this post by L Anderson
Am 25.06.2012 10:01, schrieb L Anderson:

> Googling on how to create a sqlite database (empty one) it appears
> I need only do 'sqlite3 test.db'.  However, when I try that I get:
>
> ->sqlite3 test.db
> SQLite version 3.7.13 2012-06-11 02:05:22
> Enter ".help" for instructions
> Enter SQL statements terminated with a ";"
> sqlite>
>
> however, no database is created.  What am I doing wrong and what
> do I need to do to create an empty database 'test.db'?
>
> Thanks,
>
> LA


read http://souptonuts.sourceforge.net/readme_sqlite_tutorial.html

for instruction how to use the CLI (sqlite3.exe or the Linux binary)

Oliver
_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Can't create empty database

L Anderson
In reply to this post by Patrik Nilsson-2
Patrik Nilsson wrote:
> sqlite3 test.db ""
>
> It creates an empty file, zero bytes long.
>
Thanks for your quick reply.  So then on page
'http://www.sqlite.org/quickstart.html'
under 'Create A New Database', the first bullet:

'At a shell or DOS prompt, enter: "sqlite3 test.db". This will create a
new database named "test.db". (You can use a different name if you like.)'

is not strictly correct.

I guess I was expecting 'sqlite3 test.db' or even 'sqlite3 test.db ""'
to have created an "empty database" that contained the 100 byte 'SQLite
format 3' database header structure together with any internal tables
such as 'sqlite_master' and not just an empty file.

Regards,

LA


> On 06/25/2012 10:01 AM, L Anderson wrote:
>> Googling on how to create a sqlite database (empty one) it appears
>> I need only do 'sqlite3 test.db'.  However, when I try that I get:
>>
>> ->sqlite3 test.db
>> SQLite version 3.7.13 2012-06-11 02:05:22
>> Enter ".help" for instructions
>> Enter SQL statements terminated with a ";"
>> sqlite>
>>
>> however, no database is created.  What am I doing wrong and what
>> do I need to do to create an empty database 'test.db'?
>>
>> Thanks,
>>
>> LA
>>


_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Can't create empty database

L Anderson
In reply to this post by oliver1804
Oliver Peters wrote:

> Am 25.06.2012 10:01, schrieb L Anderson:
>> Googling on how to create a sqlite database (empty one) it appears
>> I need only do 'sqlite3 test.db'.  However, when I try that I get:
>>
>> ->sqlite3 test.db
>> SQLite version 3.7.13 2012-06-11 02:05:22
>> Enter ".help" for instructions
>> Enter SQL statements terminated with a ";"
>> sqlite>
>>
>> however, no database is created.  What am I doing wrong and what
>> do I need to do to create an empty database 'test.db'?
>>
>> Thanks,
>>
>> LA
>
>
> read http://souptonuts.sourceforge.net/readme_sqlite_tutorial.html
>
> for instruction how to use the CLI (sqlite3.exe or the Linux binary)
>
> Oliver

Thanks for your reply.  As it turns out, that's the very tutorial I used
to run my test case.  The tutorial shows:

$ sqlite3 test.db
   SQLite version 3.0.8
   Enter ".help" for instructions
   sqlite> .quit

and I did:

->sqlite3 test.db
   SQLite version 3.7.13 2012-06-11 02:05:22
   Enter ".help" for instructions
   Enter SQL statements terminated with a ";"
   sqlite> .q

but did not get an empty file.

As an OP pointed out, I needed 'sqlite3 test.db ""'

I think this thread can now safely die--thanks all.

Regards,

LA

_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Can't create empty database

Niall O'Reilly
In reply to this post by L Anderson

On 25 Jun 2012, at 11:06, L Anderson wrote:

> So then on page 'http://www.sqlite.org/quickstart.html'
> under 'Create A New Database', the first bullet:
>
> 'At a shell or DOS prompt, enter: "sqlite3 test.db". This will create a new database named "test.db". (You can use a different name if you like.)'
>
> is not strictly correct.

        It has always worked for me.
        /N

_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Can't create empty database

Black, Michael (IS)
Well...it doesnt' any more on Windows and Linux at least as of 3.7.9



The file doesn't get created until you execute at least one command relevant to it.



So do a .schema or .dump or such and it creates the empty file.



Or just enter a ";" and it will create it too (ergo the "" works from the command line).





Michael D. Black

Senior Scientist

Advanced Analytics Directorate

Advanced GEOINT Solutions Operating Unit

Northrop Grumman Information Systems

________________________________
From: [hidden email] [[hidden email]] on behalf of Niall O'Reilly [[hidden email]]
Sent: Monday, June 25, 2012 6:26 AM
To: General Discussion of SQLite Database
Subject: EXT :Re: [sqlite] Can't create empty database


On 25 Jun 2012, at 11:06, L Anderson wrote:

> So then on page 'http://www.sqlite.org/quickstart.html'
> under 'Create A New Database', the first bullet:
>
> 'At a shell or DOS prompt, enter: "sqlite3 test.db". This will create a new database named "test.db". (You can use a different name if you like.)'
>
> is not strictly correct.

        It has always worked for me.
        /N

_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Can't create empty database

Niall O'Reilly

On 25 Jun 2012, at 12:48, Black, Michael (IS) wrote:

> Well...it doesnt' any more on Windows and Linux at least as of 3.7.9
>
> The file doesn't get created until you execute at least one command relevant to it.
>
> So do a .schema or .dump or such and it creates the empty file.
>
> Or just enter a ";" and it will create it too (ergo the "" works from the command line).

        I'm sorry.  I live on a Mac with 3.6.12.
        Thanks for bringing me up to date.

        /Niall

_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Can't create empty database

Valentin Davydov-2
In reply to this post by L Anderson
On Mon, Jun 25, 2012 at 01:01:46AM -0700, L Anderson wrote:

> Googling on how to create a sqlite database (empty one) it appears
> I need only do 'sqlite3 test.db'.  However, when I try that I get:
>
> ->sqlite3 test.db
> SQLite version 3.7.13 2012-06-11 02:05:22
> Enter ".help" for instructions
> Enter SQL statements terminated with a ";"
> sqlite>
>
> however, no database is created.  What am I doing wrong and what
> do I need to do to create an empty database 'test.db'?

Perhaps you have to fill the database with some of your own data (and later
delete them if you want really empty DB). Otherwise it will not even remember
your PRAGMA settings etc.:

$ rm -f test.db
$ sqlite3 test.db "pragma page_size=512;"
$ wc -c test.db
       0 test.db
$ sqlite3 test.db "pragma page_size;"
1024
$ sqlite3 test.db "pragma page_size=512;
        create table t(c);drop table t;vacuum;"
$ wc -c test.db
     512 test.db
$ sqlite3 test.db "pragma page_size;"
512
$

Valentin Davydov.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: EXT :Re: Can't create empty database

Black, Michael (IS)
In reply to this post by Niall O'Reilly
I'd be surprised if the shell behaves differently on the Mac...that' s just Unix-like under the hood so I'd figure it would act just like Linux.  Does the shell compile differently for Mac?

Michael D. Black
Senior Scientist
Advanced Analytics Directorate
Advanced GEOINT Solutions Operating Unit
Northrop Grumman Information Systems



From: [hidden email] [[hidden email]] on behalf of Niall O'Reilly [[hidden email]]
Sent: Monday, June 25, 2012 7:00 AM
To: General Discussion of SQLite Database
Subject: EXT :Re: [sqlite] Can't create empty database



On 25 Jun 2012, at 12:48, Black, Michael (IS) wrote:

> Well...it doesnt' any more on Windows and Linux at least as of 3.7.9
>
> The file doesn't get created until you execute at least one command relevant to it.
>
> So do a .schema or .dump or such and it creates the empty file.
>
> Or just enter a ";" and it will create it too (ergo the "" works from the command line).

        I'm sorry.  I live on a Mac with 3.6.12.
        Thanks for bringing me up to date.

        /Niall

_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: EXT :Re: Can't create empty database

Simon Slavin-3

On 25 Jun 2012, at 1:24pm, "Black, Michael (IS)" <[hidden email]> wrote:

> I'd be surprised if the shell behaves differently on the Mac...that' s just Unix-like under the hood so I'd figure it would act just like Linux.  Does the shell compile differently for Mac?

I can tell you about 3.7.12 on a Mac.  Starting the shell tool with something like

sqlite3 ~/Desktop/test.sqlite

and then quitting does not make a file.  Issuing '.tables' makes a file which is zero bytes long.  Issuing instead a SELECT command on either sqlite_master or any other TABLE (which, of course, doesn't exist) also makes a file which is zero bytes long.

I'm not sure about the semantics of making a zero byte file.  It doesn't agree with the SQLite documentation in that that states that every file should have the header, but it doesn't seem to actually cause any problems if you have SQLite to open the database later.

Simon.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: EXT :Re: Can't create empty database

Niall O'Reilly
In reply to this post by Black, Michael (IS)

On 25 Jun 2012, at 13:24, Black, Michael (IS) wrote:

> Does the shell compile differently for Mac?

        Sorry.  I've no idea whether it does.
        SQLite comes bundled with OSX and I haven't had a need to build it from source.
        Besides, I haven't needed either to upgrade (?) to current OSX.  You mentioned
        a later version of SQLite than the one I have.  I guess that has something to
        do with the divergence in behaviour.

        Thanks again
        /N

_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: EXT :Re: Can't create empty database

Tim Streater-3
In reply to this post by Black, Michael (IS)
On 25 Jun 2012 at 14:30, Niall O'Reilly <[hidden email]> wrote:

> On 25 Jun 2012, at 13:24, Black, Michael (IS) wrote:
>
>> Does the shell compile differently for Mac?
>
> Sorry.  I've no idea whether it does.
> SQLite comes bundled with OSX and I haven't had a need to build it from
> source.
> Besides, I haven't needed either to upgrade (?) to current OSX.  You
> mentioned
> a later version of SQLite than the one I have.  I guess that has something to
> do with the divergence in behaviour.
I've built it from the amalgamation, but only because I wanted to fiddle in a trivial way with some of the output. But in my case I just shove all the code in an Xcode project and let Xcode figure out how to compile and build it. Seems to work - so I don't know what Michael means by "differently".

--
Cheers  --  Tim

_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users