Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1u7Dr2-00CrCk-Ft for pgsql-general@arkaria.postgresql.org; Tue, 22 Apr 2025 13:40:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1u7Dr0-00EVG9-H9 for pgsql-general@arkaria.postgresql.org; Tue, 22 Apr 2025 13:40:03 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1u7Dr0-00EVFw-3q for pgsql-general@lists.postgresql.org; Tue, 22 Apr 2025 13:40:02 +0000 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1u7Dqy-001MMP-2g for pgsql-general@postgresql.org; Tue, 22 Apr 2025 13:40:02 +0000 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-39c266c2dd5so5265055f8f.3 for ; Tue, 22 Apr 2025 06:40:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1745329200; x=1745934000; darn=postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=54k3TSPpcuhaSYWZ3yZOl9hyOxyv1MJWJ+3rWXJ4SjI=; b=cpI1KzbJ7rjvekRFhE7R3nYZSfgtJFhbBu85A3hfi29Oy3Pi8XzhkyBDku1fGNKEKS cBLw7Qg8lLvnPIbrmPuKHMS5tqmnGiR5sJxzjzkr6n3NT0hfvGHSA9w7HRmEext6YEa8 3zfppJJjGx/d/bbXEvTVRiooNrq4V4wS42U7fYSMleuSQ6vVwKO7ewpIgEiDYHHu8uIB 7biY9GNm87Msxb6kHwTdQ6EA/LCbVf9rQisEuSiT/XA9fNKOAMcPfO/MNSZNd3/ZaAs3 w9Cs4/TNZCq+f0ZBgVYuVajd1rIHfaL2bVM4RG8gme5r31C8VDA1E3ci+UxFek0zjfsA Qd6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745329200; x=1745934000; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=54k3TSPpcuhaSYWZ3yZOl9hyOxyv1MJWJ+3rWXJ4SjI=; b=H+39OcGQ8erzYTinbt5xUipCO0PVDhPw9VXkpHFiObGRwZ4q7alI6V2tbeLYTdrud6 +zlVE/kHn2Mk0TRZVhZvMuD3yR9+liKzznaAY98yPgrOazjSCikpvGd9ROlk0LJny37/ ixuQMH5FW5xKFTEefXsP4UP0ftmEagrhE7xGU6gcujx3qMMd6cTFDJ47EVP1n5i8W2X5 R25NasLieppNsWcAEL16ppHT9dXF6j6tkDFWgLaAS+1W0Z1z+9/GE31VPLmeIy4Sfpiq WhDlPMoJXiVREqyIPB8cMW66aYbKMWn0/MZ4aU8dKeVoTfBsMVkH1WvEiLV8DtId4c9a ZOlg== X-Forwarded-Encrypted: i=1; AJvYcCXDdt7gTLzFsr8Y6Znec/kTzaeVkR9Z+t3JwKxW1yuWGCmWP8B5M7L3IqbEXPpm9t4CYR/QrdKEYyPwbyJ5@postgresql.org X-Gm-Message-State: AOJu0YyzcJrM6UBGH8A/jl2TEbKnCCjMLIVwPKbtX80e59NiEuLZMP/P M/iGWAkqT+oYVNNpIMFPd3L3vkSn9PGATcPwlMBQ6LjpZXhUU7qyRFHKM/zFlT0flYl1fVQH2Lv E X-Gm-Gg: ASbGnctvVJxMQmgEPZ83Op3cdesz5Jx0uQ67GbQgureUdayBB1jWQ0ccWmQXRgiHsDp 2tDi9MRM3lDOhtxWhUxK65sxAcAWu60wIQ9kqspnx4WTxhi01PgLHS3cqf+8dy2Co2iwIqFLU5W GXiBmGF9q7RFvPqa8y1qSV0vtMjeZL7DfqQ80a5grN/CAvgd/c7Ap1rBofLN7IAQhLXXBeNe2wP 6Ko+FzMS50ynZwdL35DY8EFJPHKYZIphQZAqXFVo+wiihHtCTsalQF+VKhoTJlxGl+YguWCLla+ bJ1KmkqZnBt2qGV9QujMiOtymI0RfCUNs24gt/CBDuG7fclUq8hFB3ei0sV8Lv2J4cgM3Vs= X-Google-Smtp-Source: AGHT+IHZpwwEcZ4HdWRBHXRFahfvUiC6OE9nQCs965G+yBbZn520FhjdbJdjm+h3fOCyUJ9S2rk15w== X-Received: by 2002:a05:6000:2509:b0:39e:e75b:5cd with SMTP id ffacd0b85a97d-39efba2c98emr13162289f8f.3.1745329199515; Tue, 22 Apr 2025 06:39:59 -0700 (PDT) Received: from localhost.localdomain ([2001:871:260:e754:5e12:787:a896:2a2e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-39efa43330esm15062405f8f.21.2025.04.22.06.39.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Apr 2025 06:39:59 -0700 (PDT) Message-ID: <97d29fa4f3738ce6869dc30fd58f2a3136abb2e2.camel@cybertec.at> Subject: Re: Feature Proposal: Column-Level DELETE Operation in SQL From: Laurenz Albe To: Abhishek Hatgine , pgsql-general@postgresql.org Date: Tue, 22 Apr 2025 15:39:58 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.54.3 (3.54.3-1.fc41) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 2025-04-21 at 22:23 +0530, Abhishek Hatgine wrote: > I'd like to propose a new feature for consideration in future versions of= SQL =E2=80=94 the ability > to perform a column-level DELETE operation, allowing removal of specific = column values > without affecting the entire row. In PostgreSQL, it affects the entire row anyway... > Proposal Summary > Currently, SQL provides two core commands: > =C2=A0*=20 > =C2=A0=C2=A0=C2=A0DELETE =E2=80=93 to remove entire rows. > =C2=A0*=20 > =C2=A0=C2=A0=C2=A0UPDATE =E2=80=93 to change or nullify column values. > > However, there=E2=80=99s no specific, expressive way to delete the value = of a column directly. > The typical workaround is to use: > > UPDATE Customers SET Address =3D NULL WHERE CustomerID =3D 103; > > While this works fine, it doesn't semantically express that the developer= intends to > remove the value =E2=80=94 not just update it. > > Proposed Syntax Examples > Here are some ideas for possible new syntax: >=20 > DELETE Address FROM Customers WHERE CustomerID =3D 103; > -- or > REMOVE COLUMN Address FROM Customers WHERE CustomerID =3D 103; > And even: > DELETE Address, PostalCode FROM Customers WHERE Country =3D 'India'; > > These would act as a shortcut or expressive alias for setting one or more= column values > to NULL. > > Why This Matters > =C2=A0* Improved readability and code clarity. > =C2=A0* More intuitive for developers coming from languages or NoSQL syst= ems where fields can be > "deleted" from an object/document. > =C2=A0* Emphasizes intent: deleting a value is conceptually different fro= m updating it to NULL. > =C2=A0* Opens doors for potential enhancements in tooling and IDE support= . > I understand this would require careful consideration within the SQL stan= dards, but I > believe it could make SQL more expressive and beginner-friendly while pre= serving its power. My immediate gut reaction is "no, thank you". For anybody who knows SQL, the code would become *less* readable. But I'd say that PostgreSQL is the wrong place to propose this change. We = are unlikely to implement SQL syntax that deviates from the standard like that. You should try to convince the SQL standard committee to accept that new sy= ntax, then we'd feel more motivated to implement it. Apart from my strong gut reaction, I have some techical problems with your = proposed syntax: - If you REMOVE or DELETE a column in a row, will it always become NULL or = should it become the DEFAULT value? With an UPDATE, that is clear: either you say "SET col =3D NULL" or "SET col =3D DEFAULT". So the UPDATE syntax is act= ually clearer. - Also, the proposed syntax could easily be confused with "ALTER tab DROP c= ol", which actually removes the column from a table. SQL users would be confused by= your syntax, because they would expect that if you REVOVE or DELETE a column, it would= no longer be there. Yours, Laurenz Albe