Return-Path: X-Original-To: apmail-db-derby-user-archive@www.apache.org Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DC1A29B53 for ; Fri, 15 Jun 2012 12:23:20 +0000 (UTC) Received: (qmail 61503 invoked by uid 500); 15 Jun 2012 12:23:20 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 61334 invoked by uid 500); 15 Jun 2012 12:23:20 -0000 Mailing-List: contact derby-user-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Reply-To: "Derby Discussion" Delivered-To: mailing list derby-user@db.apache.org Received: (qmail 61314 invoked by uid 99); 15 Jun 2012 12:23:19 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 Jun 2012 12:23:19 +0000 X-ASF-Spam-Status: No, hits=0.7 required=5.0 tests=FSL_RCVD_USER,RCVD_IN_DNSWL_NONE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [209.86.89.65] (HELO elasmtp-kukur.atl.sa.earthlink.net) (209.86.89.65) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 Jun 2012 12:23:11 +0000 Received: from [66.32.145.183] (helo=[192.168.2.50]) by elasmtp-kukur.atl.sa.earthlink.net with esmtpa (Exim 4.67) (envelope-from ) id 1SfVYB-0004Lt-3F for derby-user@db.apache.org; Fri, 15 Jun 2012 08:22:51 -0400 Subject: Re: Importing tables which have references to other tables From: Tim Watts To: Derby Discussion In-Reply-To: <1339762688.30268.130.camel@dellberry> References: <34016274.post@talk.nabble.com> <1339762688.30268.130.camel@dellberry> Content-Type: multipart/signed; micalg="pgp-sha1"; protocol="application/pgp-signature"; boundary="=-PasPzxy3OL/GkSIsiDsf" Organization: Clifton Farm Date: Fri, 15 Jun 2012 08:24:01 -0400 Message-ID: <1339763041.30268.133.camel@dellberry> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 X-ELNK-Trace: 3a5701426d89357f74bf435c0eb9d4785ca670a6702476d4fb2ded08e0c0a5556761882214c08e28350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c X-Originating-IP: 66.32.145.183 X-Virus-Checked: Checked by ClamAV on apache.org --=-PasPzxy3OL/GkSIsiDsf Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, 2012-06-15 at 08:18 -0400, Tim Watts wrote: > On Thu, 2012-06-14 at 23:26 -0700, jaz1988 wrote: > > Hi, > >=20 > > I have a table, TABLE1 which has a column which is GENERATED BY DEFAULT= AS > > IDENTITY. I managed to export this table and import into an existing DB= with > > the same table. The import is able to adjust the IDENTITY column accord= ingly > > with regards to the existing data in the table.=20 > >=20 > > The problem is, I have another table, TABLE2 which has a foreign key th= at > > referenced to the IDENTITY column in TABLE1. When the IDENTITY column i= n > > TABLE1 is adjusted after import, the import of TABLE2 will fail since t= he > > References is messed up already. Am I doing it right or is there other = ways > > to do import and exports of Tables with references. > >=20 > > Thank you! >=20 > Since you specified BY DEFAULT that means you can import TABLE1 using > the existing id values so that when you import TABLE2 you shouldn't have > any referential integrity issues. But, of course, you'll want to export > the id values from TABLE1. >=20 > I was able to do this using Derby's SYSCS_UTIL.SYSCS_IMPORT_DATA > procedure. >=20 Let me further point out that you should read the fine print for generated-column-spec in the Derby SQL manual under Create Table / column-definition / generated-column-spec, especially the part about using a START WITH clause. --=-PasPzxy3OL/GkSIsiDsf Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iQEcBAABAgAGBQJP2ylhAAoJEAfDBXDHBQilBj0H/AuUTW8jVPgglHHvrmRRRbX6 sYq/3QlMbbHqOOy0ziHz8ZtyeI/uBlz+zVUwFg0Dsu3enoWgmpQBTvsvCkCFpM++ 8XCMHWiGdk6tgCz9/datWZkRXcqAv3xjwSsdCXuFaHDWsFyWwFPq3ze5uWL1IdMC DHk605oB6VtKjfWT/4iU4nwEqFrGQOF4h/Sb2GrLYq01JNWot1BFeuYPRK5Iaugg FH6BcZ4aXcC+9RBfyJp6CXzqzIpbcC4r8DMaujVrQAAXa+cuWPfa6eqdQMrLR+2J BLCG/FqSZYtSyh77R/tQDzhgtXwCt+qX9ni4iPnOlRjh/nAgq+lC9gy5oZbwsf8= =sXhZ -----END PGP SIGNATURE----- --=-PasPzxy3OL/GkSIsiDsf--