Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1phfGL-00062Q-Tq for pgsql-general@arkaria.postgresql.org; Wed, 29 Mar 2023 23:31:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1phfGK-0000tX-NW for pgsql-general@arkaria.postgresql.org; Wed, 29 Mar 2023 23:31:28 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1phfGJ-0000t5-1q for pgsql-general@lists.postgresql.org; Wed, 29 Mar 2023 23:31:28 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1phfGF-0003yb-Kc for pgsql-general@lists.postgresql.org; Wed, 29 Mar 2023 23:31:25 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 8F5785C00FE; Wed, 29 Mar 2023 19:31:22 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Wed, 29 Mar 2023 19:31:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm1; t= 1680132682; x=1680219082; bh=tKpVm6vdrqu6vW57S5fi6d+U3LjdPieyokn HKJ2Qzd8=; b=UdTpzdqRVW/f9Z8Mm9OZlkmMy3ySlqLoDk225EULIEzZMFsgC9Q dvS+rJWAcsfOr+V50Ivvf+df3bpptZNwCjENkfgH4vIFNsOydsBhH5GsT8zBmNqR Z71Vc8nN4ob3X1f4FIF5H9y9JHz69PSBmqFvGCuwqjyh6OaEYFRRRWjyXzIm+EnC bwj/2gcd5BCkRBylvmTf9kDzOkiNsFtbarl0h4NGYkcxRPdMXG9AVyW86Cqb6Jun ntzitudoAWM0P8fqHA84Ywlve8/LBeNwkPyCkoqR77v/S4XlURDB/GDHNV+XV+7U wjGhKOHoHGS0knQtocyhNMn6MwnLsPqAZzg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1680132682; x= 1680219082; bh=tKpVm6vdrqu6vW57S5fi6d+U3LjdPieyoknHKJ2Qzd8=; b=K C0+hpvsbqZ+AYcUajsUQiJ8CDeGMiGpM/M4lhpWIUEf7M7ZdYEaQHoqXnQKpDQb7 /E5qplwWKIq24/838ivshQrv5TyoQDc3qUxiJD/P3q0JYTZJUbbfEjPTGVfXtWRN 5eG49pvVecQZlG2ke8WevNXNS+uYJFUFZANkNB9DSNeEvdeboM7hIJa5rlTUMheM pWQmmO732PdydnxSbZNPcsbRqlCESih2JnkrGbgaD7xV6t4S3z/8XG+/1Ardn//a FYyNb8/FXqD1gQmAK+crT5SPVKoR7DkcWKV45WFCD1UFNTAQCpy06Do4mGAPcpOb dPO0t26Jjcwrj2ifRd9sg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdehjedgvdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefkffggfgfuvfhfhfgjtgfgsehtke ertddtfeejnecuhfhrohhmpeetughrihgrnhcumfhlrghvvghruceorggurhhirghnrdhk lhgrvhgvrhesrghklhgrvhgvrhdrtghomheqnecuggftrfgrthhtvghrnhepfffhgfegte etgeeitdeitddtieejfeehgeeihfduueffvdfgfeekgfejhfejteeinecuffhomhgrihhn pegvgigrmhhplhgvrdgtohhmpdhpohhsthhgrhgvshhqlhdrohhrghenucevlhhushhtvg hrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrughrihgrnhdrkhhlrghv vghrsegrkhhlrghvvghrrdgtohhm X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 29 Mar 2023 19:31:22 -0400 (EDT) Message-ID: <9aa715ce-9485-638f-6567-e642a50699c4@aklaver.com> Date: Wed, 29 Mar 2023 16:31:21 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: COPY and custom datestyles. Or some other technique? To: Ron , pgsql-general@lists.postgresql.org References: Content-Language: en-US From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 3/29/23 16:24, Ron wrote: > Postgresql 13.10 > > $ psql -h myhost.example.com -X dba \ >         -c "\copy ${tbl} from '/var/lib/pgsql/Rdb/${tbl}.csv' WITH > DELIMITER '|';" > ERROR:  date/time field value out of range: "2013061914122501" > CONTEXT:  COPY t_id_master, line 1, column update_timestamp: > "2013061914122501" > > The timestamp format generated by a legacy dbms is YYYYMMDDHHmmSSCC > (year to centisecond, with no delimiters). > > Is there any way to convince Postgresql to import these fields? One option: 1) Import into staging table as varchar field. 2) Use to_timestamp()(NOTE change in template pattern) from here: https://www.postgresql.org/docs/current/functions-formatting.html select to_timestamp('2013061914122501', 'YYYYMMDDHH24miSSCC'); to_timestamp ------------------------- 06/19/2013 14:12:25 PDT to move the data into final table. > > There are 550+ tables, so something that I can do once on this end would > make my life a lot easier. > -- Adrian Klaver adrian.klaver@aklaver.com