Re: [sqlite] Is there a way to create a foreign key in existing table?

2013-03-07 Thread Igor Korot
Ryan, On Thu, Mar 7, 2013 at 4:31 PM, Ryan Johnson wrote: > On 07/03/2013 5:59 PM, Igor Korot wrote: >> >> Ryan, >> >> On Thu, Mar 7, 2013 at 5:26 AM, Ryan Johnson >> wrote: >>> >>> Well, you *do* want an index for the target side of the join, but for FK >>> joins the existing PK index already t

Re: [sqlite] Is there a way to create a foreign key in existing table?

2013-03-07 Thread Ryan Johnson
On 07/03/2013 5:59 PM, Igor Korot wrote: Ryan, On Thu, Mar 7, 2013 at 5:26 AM, Ryan Johnson wrote: Well, you *do* want an index for the target side of the join, but for FK joins the existing PK index already takes care of that. OK, At this point you only need to add an index on d.id to make

Re: [sqlite] Is there a way to create a foreign key in existing table?

2013-03-07 Thread Igor Korot
Ryan, On Thu, Mar 7, 2013 at 5:26 AM, Ryan Johnson wrote: > Well, you *do* want an index for the target side of the join, but for FK > joins the existing PK index already takes care of that. OK, > > At this point you only need to add an index on d.id to make the d.id=1 test > fast. And yes, it

Re: [sqlite] Is there a way to create a foreign key in existing table?

2013-03-07 Thread Ryan Johnson
Well, you *do* want an index for the target side of the join, but for FK joins the existing PK index already takes care of that. At this point you only need to add an index on d.id to make the d.id=1 test fast. And yes, it will make updates predicated on d.id faster as well. Ryan On 07/03/20

Re: [sqlite] Is there a way to create a foreign key in existing table?

2013-03-07 Thread Stephen Chrzanowski
Try: [ select distinct a.playerid, a.name, d.value, b.name, d currvalue from a join d on a.playerid=d.playerid join b on a.teamid=b.teamid where d.id=1 ] Indexes should be created for WHERE clauses, not JOIN. On Thu, Mar 7, 2013 at 3:59 AM, Igor Korot wrote: > Hi, Ryan, > > On Fri, Mar 1, 2013

Re: [sqlite] Is there a way to create a foreign key in existing table?

2013-03-07 Thread Igor Korot
Hi, Ryan, On Fri, Mar 1, 2013 at 12:48 PM, Ryan Johnson wrote: > On 01/03/2013 2:23 PM, Igor Korot wrote: >> >> Hi, guys, >> >> On Fri, Mar 1, 2013 at 8:48 AM, Ryan Johnson >> wrote: >>> >>> On 01/03/2013 11:10 AM, Stephen Chrzanowski wrote: ***I'm waiting for the repair man to show up

Re: [sqlite] Is there a way to create a foreign key in existing table?

2013-03-02 Thread kyan
On Sat, Mar 2, 2013 at 6:02 PM, Simon Slavin wrote: > Nevertheless, you do now understand that there are no magic undocumented > calls in SQLite that people are using to do things like his. Which is what > your question was. OK, thanks again. ___ sql

Re: [sqlite] Is there a way to create a foreign key in existing table?

2013-03-02 Thread Simon Slavin
On 2 Mar 2013, at 3:19pm, kyan wrote: > Thank you for your response Simon. > > On Sat, Mar 2, 2013 at 3:51 PM, Simon Slavin wrote: >> SQLite isn't at its root a DDL. It's a C API, fully documented here: >> >> >> >> That's SQLite and that's its full docu

Re: [sqlite] Is there a way to create a foreign key in existing table?

2013-03-02 Thread kyan
Thank you for your response Simon. On Sat, Mar 2, 2013 at 3:51 PM, Simon Slavin wrote: > SQLite isn't at its root a DDL. It's a C API, fully documented here: > > > > That's SQLite and that's its full documentation. As designed, to add SQLite > facilities t

Re: [sqlite] Is there a way to create a foreign key in existing table?

2013-03-02 Thread Simon Slavin
On 2 Mar 2013, at 1:24pm, kyan wrote: > On Tue, Jan 1, 2013 at 8:01 PM, Peter Haworth wrote: >> There are plenty of third party tools out there that will take care of >> adding/removing constraints to existing tables and a whole lot of other >> functions that aren't available in SQLite's DDL, w

Re: [sqlite] Is there a way to create a foreign key in existing table?

2013-03-02 Thread kyan
On Tue, Jan 1, 2013 at 8:01 PM, Peter Haworth wrote: > There are plenty of third party tools out there that will take care of > adding/removing constraints to existing tables and a whole lot of other > functions that aren't available in SQLite's DDL, while accounting for all > their secondary effe

Re: [sqlite] Is there a way to create a foreign key in existing table?

2013-03-02 Thread Ryan Johnson
On 01/03/2013 8:08 PM, Stephen Chrzanowski wrote: On Fri, Mar 1, 2013 at 11:48 AM, Ryan Johnson wrote: On 01/03/2013 11:10 AM, Stephen Chrzanowski wrote: ***I'm waiting for the repair man to show up to fix my waterheater... so... I'm bored. This is going to be to the point at the beginning, b

Re: [sqlite] Is there a way to create a foreign key in existing table?

2013-03-02 Thread Ryan Johnson
On 01/03/2013 4:09 PM, Igor Korot wrote: Ryan, On Fri, Mar 1, 2013 at 12:48 PM, Ryan Johnson wrote: On 01/03/2013 2:23 PM, Igor Korot wrote: Hi, guys, On Fri, Mar 1, 2013 at 8:48 AM, Ryan Johnson wrote: On 01/03/2013 11:10 AM, Stephen Chrzanowski wrote: ***I'm waiting for the repair man t

Re: [sqlite] Is there a way to create a foreign key in existing table?

2013-03-01 Thread James K. Lowden
On Fri, 1 Mar 2013 20:08:55 -0500 Stephen Chrzanowski wrote: > > I can't think of any reason a foreign key constraint would impact > > the cost of joins in any query. The cost is entirely at update time > > (when you have to enforce the constraint). > > > > Wouldn't you have to do a look up to p

Re: [sqlite] Is there a way to create a foreign key in existing table?

2013-03-01 Thread Stephen Chrzanowski
On Fri, Mar 1, 2013 at 11:48 AM, Ryan Johnson wrote: > > On 01/03/2013 11:10 AM, Stephen Chrzanowski wrote: > >> ***I'm waiting for the repair man to show up to fix my waterheater... >> so... >> I'm bored. This is going to be to the point at the beginning, but get >> wordy >> and technical near th

Re: [sqlite] Is there a way to create a foreign key in existing table?

2013-03-01 Thread Igor Korot
Ryan, On Fri, Mar 1, 2013 at 12:48 PM, Ryan Johnson wrote: > On 01/03/2013 2:23 PM, Igor Korot wrote: >> >> Hi, guys, >> >> On Fri, Mar 1, 2013 at 8:48 AM, Ryan Johnson >> wrote: >>> >>> On 01/03/2013 11:10 AM, Stephen Chrzanowski wrote: ***I'm waiting for the repair man to show up to

Re: [sqlite] Is there a way to create a foreign key in existing table?

2013-03-01 Thread Ryan Johnson
On 01/03/2013 2:23 PM, Igor Korot wrote: Hi, guys, On Fri, Mar 1, 2013 at 8:48 AM, Ryan Johnson wrote: On 01/03/2013 11:10 AM, Stephen Chrzanowski wrote: ***I'm waiting for the repair man to show up to fix my waterheater... so... I'm bored. This is going to be to the point at the beginning, b

Re: [sqlite] Is there a way to create a foreign key in existing table?

2013-03-01 Thread Igor Korot
Hi, guys, On Fri, Mar 1, 2013 at 8:48 AM, Ryan Johnson wrote: > > On 01/03/2013 11:10 AM, Stephen Chrzanowski wrote: >> >> ***I'm waiting for the repair man to show up to fix my waterheater... >> so... >> I'm bored. This is going to be to the point at the beginning, but get >> wordy >> and techni

Re: [sqlite] Is there a way to create a foreign key in existing table?

2013-03-01 Thread Ryan Johnson
On 01/03/2013 11:10 AM, Stephen Chrzanowski wrote: ***I'm waiting for the repair man to show up to fix my waterheater... so... I'm bored. This is going to be to the point at the beginning, but get wordy and technical near the end. ;) Super over kill. ahem Nice explanation... just a cou

Re: [sqlite] Is there a way to create a foreign key in existing table?

2013-03-01 Thread Stephen Chrzanowski
***I'm waiting for the repair man to show up to fix my waterheater... so... I'm bored. This is going to be to the point at the beginning, but get wordy and technical near the end. ;) Super over kill. ahem To better answer your question "...is it better to...", it entirely depends on the s

Re: [sqlite] Is there a way to create a foreign key in existing table?

2013-03-01 Thread Igor Korot
hole lot of other >>> functions that aren't available in SQLite's DDL, while accounting for all >>> their secondary effects. >>> >>> Pete >>> lcSQL Software <http://www.lcsql.com> >>> >>> >>> On Tue, J

Re: [sqlite] Is there a way to create a foreign key in existing table?

2013-03-01 Thread Dan Kennedy
atabase Subject: Re: [sqlite] Is there a way to create a foreign key in existingtable? Message-ID: Content-Type: text/plain; charset=us-ascii Or, if you want to do it "live:" use ALTER TABLE to rename the existing table, CREATE TABLE to make the table with the FK

Re: [sqlite] Is there a way to create a foreign key in existing table?

2013-03-01 Thread Igor Korot
; > > > On Tue, Jan 1, 2013 at 9:00 AM, wrote: > >> Message: 1 >> Date: Mon, 31 Dec 2012 10:13:40 -0800 >> From: Ward Willats >> To: General Discussion of SQLite Database >> Subject: Re: [sqlite] Is there a way to create a foreign key in >>

Re: [sqlite] Is there a way to create a foreign key in existing table?

2013-01-01 Thread Peter Haworth
DDL, while accounting for all their secondary effects. Pete lcSQL Software <http://www.lcsql.com> On Tue, Jan 1, 2013 at 9:00 AM, wrote: > Message: 1 > Date: Mon, 31 Dec 2012 10:13:40 -0800 > From: Ward Willats > To: General Discussion of SQLite Database > Subject: Re: [sql

Re: [sqlite] Is there a way to create a foreign key in existing table?

2012-12-31 Thread Baruch Burstein
On Mon, Dec 31, 2012 at 8:13 PM, Ward Willats wrote: > > On Dec 31, 2012, at 12:57 AM, Simon Slavin wrote: > > > > > On 31 Dec 2012, at 8:54am, Igor Korot wrote: > > > >> I simply forgot to do it on the table creation. And now the table has > >> many rows... > > > > You can easily modify a TABLE

Re: [sqlite] Is there a way to create a foreign key in existing table?

2012-12-31 Thread Ward Willats
On Dec 31, 2012, at 12:57 AM, Simon Slavin wrote: > > On 31 Dec 2012, at 8:54am, Igor Korot wrote: > >> I simply forgot to do it on the table creation. And now the table has >> many rows... > > You can easily modify a TABLE definition or even an entire database by using > the SQLite shell t

Re: [sqlite] Is there a way to create a foreign key in existing table?

2012-12-31 Thread Simon Slavin
On 31 Dec 2012, at 8:54am, Igor Korot wrote: > I simply forgot to do it on the table creation. And now the table has > many rows... You can easily modify a TABLE definition or even an entire database by using the SQLite shell tool to dump the database as text file of SQL commands, then edit t

[sqlite] Is there a way to create a foreign key in existing table?

2012-12-31 Thread Igor Korot
Hi, ALL, Subj, please. I simply forgot to do it on the table creation. And now the table has many rows... Thank you. P.S.: Maybe it is somehow possible to do with "CREATE INDEX..."? ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org