Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iioKJ-0006Qu-BJ for pgsql-general@arkaria.postgresql.org; Sat, 21 Dec 2019 23:38:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iioJI-00073d-VJ for pgsql-general@arkaria.postgresql.org; Sat, 21 Dec 2019 23:37:24 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iioJH-00073W-5N for pgsql-general@lists.postgresql.org; Sat, 21 Dec 2019 23:37:24 +0000 Received: from [64.147.123.24] (helo=wout1-smtp.messagingengine.com) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iioJC-0003Tx-TM for pgsql-general@lists.postgresql.org; Sat, 21 Dec 2019 23:37:22 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 91BCA473; Sat, 21 Dec 2019 18:37:06 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Sat, 21 Dec 2019 18:37:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm1; bh=H 06ubBMYz9ic0z4cQ6WaAceX65zMBKzZ3ErSJl3mKRs=; b=THkjDCucW8R+U40X/ 3dot7auvIBvuq2qSG74h3BOz9cRQPIjW9gvSqHRTsjri9kF9O5uwdi0ACpBO0G1u XAY0kJ4MV8S2IHKopEWL35UnH971gX0Sr0fXOfvFAWsVRPhzsFaiVpFiSRqySdEA Hno2ZRJPJzRfFdlJQEmykK2X/UB585d/Io/07E930nFARL6HmMcXm6SIRZ73fOuR xyL/OswS3kiX/ThYpY0sNNzR+tecpnGJ6+FWYMMO0B8V/6I+dmeebm3UXwR4+1wZ wsatBy0CLIEHK72XPsFSDhT82VduRQ/8fubmhY5qxqGeJIDSxj2scri4N4RVXN2E MU58w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=H06ubBMYz9ic0z4cQ6WaAceX65zMBKzZ3ErSJl3mK Rs=; b=tjw51D2wesGX/ysIMRzQ2sEjbExXmb0v1F+h+p/8EwrUOJZVb5OlNnl8u CXlg7P9UKDLrvfXYhYQtIu1BV3CJIx/8AJaXmQMmOIC1bLKBsDefxFYhEZ5j/IQq aB+E31ACLSx78HXCqyLGo+Vu+2JAskp3M0oAX7Rh8MtKUW/XTx/4A4hVuDW9flCV +bpYKKHZ/2maHYcCIwKusWBCte6vHC9yqN8K9jgv8ZbF7RZKMIiBaH6UR8uEkDaS K9LL954XSSVxmtUdKBeUib9kZm+XEogqzoQAh1bif5QhKTnXUBNN810FKsQB1toH TiStXz91jPOPlY1qVnPiuaXMotHrg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrvdduiedgtdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhkffffgggjggtgfesthejredttdefjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucffohhmrghinheprhhothdufedrohhrghdptgihnhgvrhhgihdrnhgvthenucfk phepjedurddvuddvrdduvdelrdduleefnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrug hrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhmnecuvehluhhsthgvrhfuihii vgeptd X-ME-Proxy: Received: from [192.168.1.2] (unknown [71.212.129.193]) by mail.messagingengine.com (Postfix) with ESMTPA id 552B98005A; Sat, 21 Dec 2019 18:37:05 -0500 (EST) Subject: Re: Semi-unable to add new records to table--primary key needed? To: "Boylan, Ross" , Ron , "pgsql-general@lists.postgresql.org" References: <9c113278-3593-92dc-fbe5-7e3e0018218a@gmail.com> <66c14222-ac25-e9f5-7a29-3ccebb26e987@aklaver.com> From: Adrian Klaver Message-ID: <85eb0351-57dd-85f5-cb24-03ef38a39008@aklaver.com> Date: Sat, 21 Dec 2019 15:37:04 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 64.147.123.24 (deferred) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 12/21/19 1:41 PM, Boylan, Ross wrote: > My mail interface (Outlook on the Web) really can't quote properly, so I'll just do snips. > >> "When you create a new table in Datasheet view, Access automatically > creates a primary key for you and assigns it a field name of "ID" and > the AutoNumber data type." > > That quote, and the documentation mentioned before it, is not directly relevant, since I'm not creating new tables in Access > >> My guess is the migration process missed that aliquotid was the PK. > > Substantively aliquotid is the primary key, but in terms of formal table properties there is no primary key. The export process does create primary keys in PG for tables that have them in Access. My export process also has no foreign key relations. > It is quite likely that subjecting the current data to "should be there" constraints on primary and foreign keys will reveal features of the data that shouldn't be there, such as missing or lost references or values. > > Also, if I impose those constraints when I create the table definitions, the import will become much more order sensitive, I think. If I import a table with a foreign key in a table not yet imported, it will presumably fail. And since tables can refer to each other, there may be no import order that will work. So I guess I better add foreign key constraints after the main import. Of course, that will require valid data, but that's a separate problem. > > I migrated by using a slightly modified version of > ' exportSQL version 3.2-dev > ' www.rot13.org/~dpavlin/projects.html#sql > ' > ' based on exportSQL version 2.0 from www.cynergi.net/prod/exportsql/ > ' > ' (C) 1997-98 CYNERGI - www.cynergi.net, info@cynergi.net > ' (C) Pedro Freire - pedro.freire@cynergi.net (do not add to mailing lists without permission) > ' (c) 2000-2001 Dobrica Pavlinusic - added PostgreSQL support > > It needed some tweaks to work with current PG. It does preserve primary key values. > > Thanks for the references on log_cnt and sequences. I can see that just using the defaults is the easiest path, but I clearly can't do that on import. Cleaning the sequence up after import seems straightforward, though the export code isn't doing it. Whether the main application relies strictly on defaults I don't know. This might be easier to figure out if you outline what is going on: 1) The purpose of the migration? 2) A general sense of what the application is and what it does. 3) Have you looked at the Relations tab in Access to see what if any relationships are there? > > Ross > -- Adrian Klaver adrian.klaver@aklaver.com