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 1hstUv-0001cv-TK for pgsql-general@arkaria.postgresql.org; Wed, 31 Jul 2019 18:38:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hstUu-0004Yf-Ca for pgsql-general@arkaria.postgresql.org; Wed, 31 Jul 2019 18:38:48 +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 1hstUt-0004P2-V3 for pgsql-general@lists.postgresql.org; Wed, 31 Jul 2019 18:38:48 +0000 Received: from mail-ot1-x334.google.com ([2607:f8b0:4864:20::334]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hstUr-0006Eo-1Q for pgsql-general@postgresql.org; Wed, 31 Jul 2019 18:38:46 +0000 Received: by mail-ot1-x334.google.com with SMTP id l15so14013571oth.7 for ; Wed, 31 Jul 2019 11:38:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lucee.org; s=google; h=to:from:subject:message-id:date:user-agent:mime-version :content-transfer-encoding:content-language; bh=6DVKHVxG5qXGlAh+rYzU0GBZwHlAA0Iwj8uGtv+56U8=; b=H2a6r9boEsgTxlSJhYizHRklwltxKvxeOoQRLIG9Ns8u3pC/gGvwW1sE6o7w406Pik FtiHceclqC7KUButRMorvd11NsahTrlFYloTThZ2IjGwBI9QR1q1HsnJ+YxqkfG1bI8S gDVEQbTB3aqapCSFRZ/qRKNoEUGw7QCRTR2iGS/JyJJnsTMHCKEcBpBwUoy42NlNBImq DQZXB5J3BMYzUgnAkJGAN2DCw2iTaqypY0QyvBQrG9Ig3K2RKwwqyzRO+XYuSvkd9QZ0 TSnV7UbZdy81qoVL10/Rl7NEbOsFNDJUyaFXz3Qyd3QTJTnlS/c2loWXqlG6Jnt9U/lx rtXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-transfer-encoding:content-language; bh=6DVKHVxG5qXGlAh+rYzU0GBZwHlAA0Iwj8uGtv+56U8=; b=Eu6+OmfqC9+UX3znmxeMmOx+RBACoDDMpfD2UK+9M4/HyjQuX7MdsMkGpBN3jgd6v+ GftA0Ur2JAdqrBCD2LNR0NI8zlcrWyl9fT7p5cF23br+FFcNSs1a4+QB/nOWk42+5rPC GzkzJmz21bd5VzEiWRHymI2w6Q0KAoeDU9s+LX0Z8j+Q7t30NUzRRIADxuRJFIc43pxn xHJ59dDGb7sMClf9eP3xRTsIsaPA4T4/XjiG7lUmIhkMpvubTAMlRVF4pFOEZbF1l9SV ldwruVPkygFYsdpkMBmadQ+gYvy+oPhukUJbF9tl7W8AWa4IPQdmS9hM8fPAaJF2R5tC 3VhA== X-Gm-Message-State: APjAAAVLlZ6jkAX+DCCVdUgyL/Gujs4VeX6RlO13r2SAnUozwTStXGqQ kJVE9eBiGgxEKUsG1EbbksO8HjY7z3o= X-Google-Smtp-Source: APXvYqzDSpopIzXzvGHwD0+qpdAv3C2FBbe2zf/mqZiqnlV7iSzCP6WfCesgSZjuwWna+d+FnEWhZQ== X-Received: by 2002:a9d:5a82:: with SMTP id w2mr88463560oth.240.1564598321764; Wed, 31 Jul 2019 11:38:41 -0700 (PDT) Received: from ?IPv6:2600:1700:4000:8120:796c:3217:5784:98f0? ([2600:1700:4000:8120:796c:3217:5784:98f0]) by smtp.googlemail.com with ESMTPSA id w13sm21114013oih.17.2019.07.31.11.38.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 31 Jul 2019 11:38:41 -0700 (PDT) To: pgsql-general From: "Igal @ Lucee.org" Subject: DDL and DML in a transaction Message-ID: <28ca745e-f459-95bd-bf80-7d907b65b9cf@lucee.org> Date: Wed, 31 Jul 2019 11:38:39 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk I am trying to change a text column into a numeric one in a large table. My idea was to add a new column, update it, drop the old column, and rename the new one to the old name.  I am hoping that that would make it faster and minimize locking time though I'm not sure that it would. I am therefore trying to execute the following but I'm getting an error that the new column does not exist: begin;     alter table some_table         add column if not exists amount_num numeric(30,12);     update some_table         set amount_num = amount_text::numeric(30,12);     alter table some_table         drop column amount_text;     alter table some_table         rename column amount_num to amount_text;     alter table some_table         drop column amount_num;     commit; end; Am I missing something?  Is this supposed to work? Would it have less locking than simply altering the column? Thanks, Igal