And remembering that you will lose any indexes or triggers defined for the
table by doing this.

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

Pete
lcSQL Software <http://www.lcsql.com>


On Tue, Jan 1, 2013 at 9:00 AM, <sqlite-users-requ...@sqlite.org> wrote:

> Message: 1
> Date: Mon, 31 Dec 2012 10:13:40 -0800
> From: Ward Willats <sqlite-us...@wardco.com>
> To: General Discussion of SQLite Database <sqlite-users@sqlite.org>
> Subject: Re: [sqlite] Is there a way to create a foreign key in
>         existing        table?
> Message-ID: <e0b03b27-8371-476d-bddd-e58752eb2...@wardco.com>
> 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 you want, INSERT SELECT
> to bring the records from the renamed table to the new table, and DROP
> TABLE to get rid of the renamed original.
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to