Re: [sqlite] Foreign key support
On Jan 31, 2009, at 12:25 AM, Adam DeVita wrote: > Good day, > > If I write into the sqlite3 using the analyzer: > > create table mysns (SN int primary key, desc text); > insert into mysns (SN, desc) values (1,2); > create table t2 (mynum int, desc2 text, SN references mysns(SN) ); > > insert into t2 (mynum, desc2, SN) values (1,"two", 3); > > This insert didn't produce an error, despite the fact 3 isn't in table > mysns. Why? Foreign keys are not supported. See the first entry in this list: http://www.sqlite.org/omitted.html > > > regards, > Adam > ___ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Foreign key support
On Fri, Jan 30, 2009 at 11:25 AM, Adam DeVitawrote: > Good day, > > If I write into the sqlite3 using the analyzer: > > create table mysns (SN int primary key, desc text); > insert into mysns (SN, desc) values (1,2); > create table t2 (mynum int, desc2 text, SN references mysns(SN) ); > > insert into t2 (mynum, desc2, SN) values (1,"two", 3); > > This insert didn't produce an error, despite the fact 3 isn't in table > mysns. Why? > http://www.sqlite.org/omitted.html > regards, > Adam > ___ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > -- Puneet Kishor http://www.punkish.org/ Nelson Institute for Environmental Studies http://www.nelson.wisc.edu/ Open Source Geospatial Foundation (OSGeo) http://www.osgeo.org/ ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] Foreign key support
Good day, If I write into the sqlite3 using the analyzer: create table mysns (SN int primary key, desc text); insert into mysns (SN, desc) values (1,2); create table t2 (mynum int, desc2 text, SN references mysns(SN) ); insert into t2 (mynum, desc2, SN) values (1,"two", 3); This insert didn't produce an error, despite the fact 3 isn't in table mysns. Why? regards, Adam ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Index keywords
Vance E. Neffwrote: > Just to be straight, I would use the Query: > SELECT last_insert_rowid() AS TheNewKeyValue FROM TableX No, you would just do select last_insert_rowid(); Or you could call sqlite3_last_insert_rowid() API directly. Last inserted ROWID is the property of a connection, not of a table. Igor Tandetnik ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] playing with sqlite3
On Jan 30, 2009, at 8:42 AM, Mike Eggleston wrote: > This box is fedora core 5 with sqlite3 3.3.3. Version 3.3.3 will be three years old tomorrow. From this I'm guessing you didn't compile SQLite yourself but are using whatever happen to come with fedora core 5. And there is no telling how they compiled it. I'd suggest you download the latest sqlite3 command-line shell from http://www.sqlite.org/download.html - precompiled and ready to run, and try again using that. FWIW, SQLite does not use mmap(), at least not directly. (Maybe the system malloc() is calling mmap().) So I do not know what is causing all of those mremap() calls you are seeing in strace. D. Richard Hipp d...@hwaci.com ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] playing with sqlite3
On Fri, 30 Jan 2009, John Machin might have said: > On 30/01/2009 2:27 AM, Mike Eggleston wrote: > > On Thu, 29 Jan 2009, Thomas Briggs might have said: > > > >>When you say the load "stops", what do you mean? Does the sqlite3 > >> process end? Does it sit there doing nothing? > >> > >>The first thing I would do is look at line 55035 of the source file > >> and see if there's something weird about it. > >> > >>Also, have you done a line count on the file so you know exactly > >> how many rows it should load? > >> > >>-T > >> > >> On Wed, Jan 28, 2009 at 5:33 PM, Mike Egglestonwrote: > >>> Hi, > >>> > >>> I'm curious how sqlite3 may perform for some of my applications that > >>> really don't need things like MySQL or larger. I am using bacula > >>> (http://www.bacula.org) at work so I dumped the bacula data from MySQL > >>> (mysqldump bacula > bacula.sql), wrote a perl script to massage the data, > >>> and now I'm trying to load that data into a sqlite3 file. > >>> > >>> I don't see any errors on stdout, but the loading of rows stops after > >>> 55034 rows (file size is 6338560 bytes). I know in MySQL this table > >>> has rows. > >>> > >>> Where can I look and what might be the error that the rows are not > >>> loading? > >>> > >>> Mike > >>> > >>> Fedora Core 5 > >>> sqlite3 3.3.3 > > > > After deleting the three rows in my previous message (that has not yet > > made it through moderation), the load now stops at 6337536 bytes when > > using the command 'time sqlite3 x.db < x.sql ; date'. Still no messages > > nor errors from sqlite to stdout nor stderr from the above command. > > > > What to try next? > > Have you looked at the stoppage points in your file(s) with a hex > editor? Any non-printable non-ASCII characters other than newline ('\n')? This box is fedora core 5 with sqlite3 3.3.3. > [If you were on Windows I'd bet you had Ctrl-Z aka '\x1a' aka CPMEOF > bytes in there] [Right, this is not windows.] > You could also try answering Thomas Briggs's questions: > > (1) When you say the load "stops", what do you mean? Does the sqlite3 > process end? Does it sit there doing nothing? I start sqlite3, several tables are created, data for the largest table (File) starts loading, after 55000+ rows the loading stops, no further rows are loaded nor are the rest of the tables later in the x.sql file created. > (2) Also, have you done a line count on the file so you know exactly how > many rows it should load? [mi...@zurich tmp]$ grep -ci 'insert into file ' x.sql 6093439 [mi...@zurich tmp]$ mysql --user=root --exec='select count(*) from File' bacula +--+ | count(*) | +--+ | 2289331 | +--+ My test with sqlite3 so far is only loading 55034 rows of the 6093439 in the x.sql file. > Also while you are getting the line count from wc, get the character > count and compare it with the file size from ls. Below. > And another thought, bit of a long shot, try running it without the > "time" and "; date". > > Oh, and try running it with only the 3 lines that you cut out plus a > couple more on the end. If that reproduces the problem, then at least > you don't have to wait around while experimenting. The next experiment > would be to try to reproduce the problem with a non-confidential set of > 5 or so lines so that you could post it here for scrutiny. > > And double-check the SQL syntax in the 3 lines that you cut out. I did. > HTH, > John $ ls -l total 2012088 drwxr-xr-x 20 geDomain Users 4096 Sep 17 2007 acads -rw-r--r-- 1 mikee Domain Users 944217701 Jan 28 14:21 bacula.sql -rw-r--r-- 1 mikee Domain Users969 Jan 28 15:22 x.pl -rw-r--r-- 1 mikee Domain Users 1114109293 Jan 29 08:52 x.sql $ cp x.sql y.sql $ ls -l total 3101160 drwxr-xr-x 20 geDomain Users 4096 Sep 17 2007 acads -rw-r--r-- 1 mikee Domain Users 944217701 Jan 28 14:21 bacula.sql -rw-r--r-- 1 mikee Domain Users969 Jan 28 15:22 x.pl -rw-r--r-- 1 mikee Domain Users 1114109293 Jan 29 08:52 x.sql -rw-r--r-- 1 mikee Domain Users 1114109293 Jan 30 06:59 y.sql $ df -k . Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/rootvg-datalv 1887255336 1780873492 12026644 100% /opt/data $ wc x.sql 9459865 138924803 1114109293 x.sql $ Running the command: $ strace -o /opt/data/tmp/sqlite3.strace sqlite3 x.db < x.sql The strace output when the error starts is: fcntl64(4, F_SETLK64, {type=F_WRLCK, whence=SEEK_SET, start=1073741824, len=1}, 0xbfbc8a94) = 0 fcntl64(4, F_SETLK64, {type=F_WRLCK, whence=SEEK_SET, start=1073741826, len=510}, 0xbfbc8a94) = 0 _llseek(4, 0, [0], SEEK_SET)= 0 write(4, "SQLite format 3\0\4\0\1\1\0@ \0\0\327\16\0\0\0\0"..., 1024) = 1024 _llseek(4, 6336512, [6336512], SEEK_SET) = 0 write(4, "\r\0\0\0\n\0^\0\3\225\3*\2\326\2\202\2\32\1\306\1q\1\34"..., 1024) = 1024 fsync(4)= 0 close(5)
Re: [sqlite] Index keywords
Thank you Igor! Just to be straight, I would use the Query: SELECT last_insert_rowid() AS TheNewKeyValue FROM TableX Vance Igor Tandetnik wrote: >"Vance E. Neff"wrote >in message news:4982fd7c.2090...@intouchmi.com > > >>When I INSERT a new row with INTEGER PRIMARY KEY AUTOINCREMENT >>specified for the key column, how do I find out what the new value >>for that column (the new key value) as that may be the only unique >>column value in the table? >> >> > >http://sqlite.org/lang_corefunc.html >last_insert_rowid > >http://sqlite.org/c3ref/last_insert_rowid.html > >Igor Tandetnik > > > >___ >sqlite-users mailing list >sqlite-users@sqlite.org >http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > > > > ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Index keywords
"Vance E. Neff"wrote in message news:4982fd7c.2090...@intouchmi.com > When I INSERT a new row with INTEGER PRIMARY KEY AUTOINCREMENT > specified for the key column, how do I find out what the new value > for that column (the new key value) as that may be the only unique > column value in the table? http://sqlite.org/lang_corefunc.html last_insert_rowid http://sqlite.org/c3ref/last_insert_rowid.html Igor Tandetnik ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Index keywords
Thanks Ron, That was what I was looking for. Just did not know where to find it. When I INSERT a new row with INTEGER PRIMARY KEY AUTOINCREMENT specified for the key column, how do I find out what the new value for that column (the new key value) as that may be the only unique column value in the table? Vance Wilson, Ron P wrote: >If you click the link for 'create table' on the page below, you get >here: > >http://www.sqlite.org/lang_createtable.html > >Most of the constraint keywords are explained briefly there. > >RW > >Ron Wilson, S/W Systems Engineer III, Tyco Electronics, 434.455.6453 > >-Original Message- >From: sqlite-users-boun...@sqlite.org >[mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Daniel Watrous >Sent: Thursday, January 29, 2009 1:10 PM >To: General Discussion of SQLite Database >Subject: Re: [sqlite] Index keywords > >oops, sorry, here's the link: http://www.sqlite.org/lang.html > >On Thu, Jan 29, 2009 at 11:09 AM, Daniel Watrous>wrote: > > >>Could this be what you're looking for? >> >>On Thu, Jan 29, 2009 at 11:04 AM, Vance E. Neff >> >> >wrote: > > >>>I have seen that list of keywords, but I'm looking for a description >>> >>> >of > > >>>what they mean. In particular those associated with index >>> >>> >definitions. > > >>>Vance >>> >>>D. Richard Hipp wrote: >>> >>> >>> On Jan 29, 2009, at 9:38 AM, Vance E. Neff wrote: >Hi, > >I've searched and can not find where the keywords like PRIMARY, >UNIQUE, >etc. in the Documentation. Please point me to the correct section. >Also, if I use autoincrement, how do I retrieve the new index value >for >use in other tables? Again a doc. pointer would be good. > > > > http://www.sqlite.org/lang_keywords.html >Thanks! >Vance > >___ >sqlite-users mailing list >sqlite-users@sqlite.org >http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > > > > D. Richard Hipp d...@hwaci.com ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users >>>___ >>>sqlite-users mailing list >>>sqlite-users@sqlite.org >>>http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users >>> >>> >>> >___ >sqlite-users mailing list >sqlite-users@sqlite.org >http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users >___ >sqlite-users mailing list >sqlite-users@sqlite.org >http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > > > > ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Index keywords
If you click the link for 'create table' on the page below, you get here: http://www.sqlite.org/lang_createtable.html Most of the constraint keywords are explained briefly there. RW Ron Wilson, S/W Systems Engineer III, Tyco Electronics, 434.455.6453 -Original Message- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Daniel Watrous Sent: Thursday, January 29, 2009 1:10 PM To: General Discussion of SQLite Database Subject: Re: [sqlite] Index keywords oops, sorry, here's the link: http://www.sqlite.org/lang.html On Thu, Jan 29, 2009 at 11:09 AM, Daniel Watrouswrote: > Could this be what you're looking for? > > On Thu, Jan 29, 2009 at 11:04 AM, Vance E. Neff wrote: >> I have seen that list of keywords, but I'm looking for a description of >> what they mean. In particular those associated with index definitions. >> >> Vance >> >> D. Richard Hipp wrote: >> >>>On Jan 29, 2009, at 9:38 AM, Vance E. Neff wrote: >>> >>> >>> Hi, I've searched and can not find where the keywords like PRIMARY, UNIQUE, etc. in the Documentation. Please point me to the correct section. Also, if I use autoincrement, how do I retrieve the new index value for use in other tables? Again a doc. pointer would be good. >>> >>>http://www.sqlite.org/lang_keywords.html >>> >>> >>> Thanks! Vance ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users >>> >>>D. Richard Hipp >>>d...@hwaci.com >>> >>> >>> >>>___ >>>sqlite-users mailing list >>>sqlite-users@sqlite.org >>>http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users >>> >>> >>> >>> >> >> ___ >> sqlite-users mailing list >> sqlite-users@sqlite.org >> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users >> > ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] playing with sqlite3
On 30/01/2009 2:27 AM, Mike Eggleston wrote: > On Thu, 29 Jan 2009, Thomas Briggs might have said: > >>When you say the load "stops", what do you mean? Does the sqlite3 >> process end? Does it sit there doing nothing? >> >>The first thing I would do is look at line 55035 of the source file >> and see if there's something weird about it. >> >>Also, have you done a line count on the file so you know exactly >> how many rows it should load? >> >>-T >> >> On Wed, Jan 28, 2009 at 5:33 PM, Mike Egglestonwrote: >>> Hi, >>> >>> I'm curious how sqlite3 may perform for some of my applications that >>> really don't need things like MySQL or larger. I am using bacula >>> (http://www.bacula.org) at work so I dumped the bacula data from MySQL >>> (mysqldump bacula > bacula.sql), wrote a perl script to massage the data, >>> and now I'm trying to load that data into a sqlite3 file. >>> >>> I don't see any errors on stdout, but the loading of rows stops after >>> 55034 rows (file size is 6338560 bytes). I know in MySQL this table >>> has rows. >>> >>> Where can I look and what might be the error that the rows are not >>> loading? >>> >>> Mike >>> >>> Fedora Core 5 >>> sqlite3 3.3.3 > > After deleting the three rows in my previous message (that has not yet > made it through moderation), the load now stops at 6337536 bytes when > using the command 'time sqlite3 x.db < x.sql ; date'. Still no messages > nor errors from sqlite to stdout nor stderr from the above command. > > What to try next? Have you looked at the stoppage points in your file(s) with a hex editor? Any non-printable non-ASCII characters other than newline ('\n')? [If you were on Windows I'd bet you had Ctrl-Z aka '\x1a' aka CPMEOF bytes in there] You could also try answering Thomas Briggs's questions: (1) When you say the load "stops", what do you mean? Does the sqlite3 process end? Does it sit there doing nothing? (2) Also, have you done a line count on the file so you know exactly how many rows it should load? Also while you are getting the line count from wc, get the character count and compare it with the file size from ls. And another thought, bit of a long shot, try running it without the "time" and "; date". Oh, and try running it with only the 3 lines that you cut out plus a couple more on the end. If that reproduces the problem, then at least you don't have to wait around while experimenting. The next experiment would be to try to reproduce the problem with a non-confidential set of 5 or so lines so that you could post it here for scrutiny. And double-check the SQL syntax in the 3 lines that you cut out. HTH, John ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Index keywords
Hi Frank, I'm looking for their meanings and details. Vance Frank Juestel wrote: >Hi Vance, > >Here we go with a list of SQLite keywords: > >http://www.sqlite.org/lang_keywords.html > >Best regards >Franky > >- Ursprüngliche Nachricht - >Von: "Vance E. Neff">An: "General Discussion of SQLite Database" >Gesendet: Donnerstag, 29. Januar 2009 15.38 Uhr (GMT+0100) Europe/Berlin >Betreff: [sqlite] Index keywords > >Hi, > >I've searched and can not find where the keywords like PRIMARY, UNIQUE, >etc. in the Documentation. Please point me to the correct section. >Also, if I use autoincrement, how do I retrieve the new index value for >use in other tables? Again a doc. pointer would be good. > >Thanks! >Vance > >___ >sqlite-users mailing list >sqlite-users@sqlite.org >http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > > > > ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] playing with sqlite3
On Thu, 29 Jan 2009, Thomas Briggs might have said: >When you say the load "stops", what do you mean? Does the sqlite3 > process end? Does it sit there doing nothing? > >The first thing I would do is look at line 55035 of the source file > and see if there's something weird about it. > >Also, have you done a line count on the file so you know exactly > how many rows it should load? > >-T > > On Wed, Jan 28, 2009 at 5:33 PM, Mike Egglestonwrote: > > Hi, > > > > I'm curious how sqlite3 may perform for some of my applications that > > really don't need things like MySQL or larger. I am using bacula > > (http://www.bacula.org) at work so I dumped the bacula data from MySQL > > (mysqldump bacula > bacula.sql), wrote a perl script to massage the data, > > and now I'm trying to load that data into a sqlite3 file. > > > > I don't see any errors on stdout, but the loading of rows stops after > > 55034 rows (file size is 6338560 bytes). I know in MySQL this table > > has rows. > > > > Where can I look and what might be the error that the rows are not > > loading? > > > > Mike > > > > Fedora Core 5 > > sqlite3 3.3.3 After deleting the three rows in my previous message (that has not yet made it through moderation), the load now stops at 6337536 bytes when using the command 'time sqlite3 x.db < x.sql ; date'. Still no messages nor errors from sqlite to stdout nor stderr from the above command. What to try next? Mike ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] playing with sqlite3
On Thu, 29 Jan 2009, Thomas Briggs might have said: >When you say the load "stops", what do you mean? Does the sqlite3 > process end? Does it sit there doing nothing? > >The first thing I would do is look at line 55035 of the source file > and see if there's something weird about it. > >Also, have you done a line count on the file so you know exactly > how many rows it should load? > >-T > > On Wed, Jan 28, 2009 at 5:33 PM, Mike Egglestonwrote: > > Hi, > > > > I'm curious how sqlite3 may perform for some of my applications that > > really don't need things like MySQL or larger. I am using bacula > > (http://www.bacula.org) at work so I dumped the bacula data from MySQL > > (mysqldump bacula > bacula.sql), wrote a perl script to massage the data, > > and now I'm trying to load that data into a sqlite3 file. > > > > I don't see any errors on stdout, but the loading of rows stops after > > 55034 rows (file size is 6338560 bytes). I know in MySQL this table > > has rows. > > > > Where can I look and what might be the error that the rows are not > > loading? > > > > Mike > > > > Fedora Core 5 > > sqlite3 3.3.3 Duh, I should have tried that first. I've removed three lines around line 55035 and will try the inserts again. Inspecting the file of lines I see no difference other than the values for the columns. The File table should have 2671022 rows (that count is from mysql and from last night's backup, so the count is bound to be off some, but sqlite3 should be close). Mike ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Index keywords
Hi Vance, Here we go with a list of SQLite keywords: http://www.sqlite.org/lang_keywords.html Best regards Franky - Ursprüngliche Nachricht - Von: "Vance E. Neff"An: "General Discussion of SQLite Database" Gesendet: Donnerstag, 29. Januar 2009 15.38 Uhr (GMT+0100) Europe/Berlin Betreff: [sqlite] Index keywords Hi, I've searched and can not find where the keywords like PRIMARY, UNIQUE, etc. in the Documentation. Please point me to the correct section. Also, if I use autoincrement, how do I retrieve the new index value for use in other tables? Again a doc. pointer would be good. Thanks! Vance ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users -- Frank Juestel mailto: frank.jues...@jsmarts.de phone: +49 6002 930955 Frankfurt Office: JSM Arts IT Consulting GbR JSM Arts Webservices GbR Am Pfahlgraben 19 61239 Ober-Moerlen Germany ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users