Re: [sqlite] adding/dropping foreign key to existing table

2011-03-23 Thread Sam Carleton
On Wed, Mar 23, 2011 at 2:00 PM, Nico Williams wrote: > Also, just to be clear, making the schema writable and then making any > updates to sqlite_master is completely unsupported, and should be. > This is good, very good, IMHO. Which is also why I won't do it:) hehehehe Thank you for insight!

Re: [sqlite] adding/dropping foreign key to existing table

2011-03-23 Thread Nico Williams
Also, just to be clear, making the schema writable and then making any updates to sqlite_master is completely unsupported, and should be. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Re: [sqlite] adding/dropping foreign key to existing table

2011-03-23 Thread Sam Carleton
On Wed, Mar 23, 2011 at 12:20 PM, Nico Williams wrote: > I do think that SQLite3 will eventually need to grow ALTER support for > altering constraints. This whole copy-the-table thing is not really a > scalable solution. Without such ALTER functionality users will often > have to implement all c

Re: [sqlite] adding/dropping foreign key to existing table

2011-03-23 Thread Nico Williams
I do think that SQLite3 will eventually need to grow ALTER support for altering constraints. This whole copy-the-table thing is not really a scalable solution. Without such ALTER functionality users will often have to implement all constraints as triggers and/or unique indexes instead of using co

Re: [sqlite] adding/dropping foreign key to existing table

2011-03-23 Thread Simon Slavin
On 23 Mar 2011, at 11:39am, Sam Carleton wrote: > My goal in adding foreign keys (FK) is simple: Implement referential > integrity (RI) at the database level, that way I don't shoot myself in the > foot later (I am the only developer at this time). [snip] That's fine. > So what I am wondering

Re: [sqlite] adding/dropping foreign key to existing table

2011-03-23 Thread Sam Carleton
On Tue, Mar 22, 2011 at 10:55 PM, BareFeetWare wrote: > > You have to drop the old table and create a new one with the changed > foreign keys. This is a bummer. Is there any desire/plan to add an alter feature, in the future? > > Also, from a performance perspective, is there an advantage to

Re: [sqlite] adding/dropping foreign key to existing table

2011-03-22 Thread Simon Slavin
On 23 Mar 2011, at 2:55am, BareFeetWare wrote: > begin immediate; > create temp table "My Table Backup" as select * from "My Table"; > drop table "My Table"; > create table "My Table" (); > insert into "My Table" select * from "My Table Backup"; > drop table "My Table Backup"; > commit; > > Unfo

Re: [sqlite] adding/dropping foreign key to existing table

2011-03-22 Thread BareFeetWare
On 23/03/2011, at 1:17 PM, Sam Carleton wrote: > I don't see any examples on http://www.sqlite.org/foreignkeys.html how to > either add or drop a foreign key to an existing table. What might that > syntax look like exactly? You have to drop the old table and create a new one with the changed f

[sqlite] adding/dropping foreign key to existing table

2011-03-22 Thread Sam Carleton
I don't see any examples on http://www.sqlite.org/foreignkeys.html how to either add or drop a foreign key to an existing table. What might that syntax look like exactly? Also, from a performance perspective, is there an advantage to using a foreign key in SQLite verses just an index? (aka, is it