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 1u7cBH-002XbJ-Pd for pgsql-general@arkaria.postgresql.org; Wed, 23 Apr 2025 15:38:36 +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 1u7cBF-007Hhu-QZ for pgsql-general@arkaria.postgresql.org; Wed, 23 Apr 2025 15:38:34 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1u7cBF-007Hhl-CO for pgsql-general@lists.postgresql.org; Wed, 23 Apr 2025 15:38:34 +0000 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1u7cBB-001cX6-2U for pgsql-general@postgresql.org; Wed, 23 Apr 2025 15:38:33 +0000 Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-5eb92df4fcbso11445489a12.0 for ; Wed, 23 Apr 2025 08:38:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=peoplecall-com.20230601.gappssmtp.com; s=20230601; t=1745422709; x=1746027509; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=cMefYSD0pRlkJjb9A7YLSCrYNsQ9RkdKvkItXCY+7Ps=; b=SFsPdlQ0U/MKnr5+0rlw1HioB6CtHEeM3jE+KqU7ZatjAqvTG3MmBfYvDCo2BNJ6kF gjwY09afUapYGmAbUoSV3nI2wPuvhpPf6x9Py73dRFFxwNhQH5lF79mAG6s6Jci7xtPT ebXSgR3eqS5AzxlXuO0ZoBI8/SEKQTt84tyOx5n5UMAdUnnQ9AI5f2FsLgp9wyeg/eRV h5OsfnH91+StU7YaMX2dhuuLqFmHQ3FOYPwaUmL+RQcxQ5TUvlbyPrAixllWf4PWNdHH uROsezrlES0dZNaDhTbm3BzrilMfEZp0CiGPuaBqbR5gjlHk/u9qp6Fl/N13V3owWtzA kIfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745422709; x=1746027509; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cMefYSD0pRlkJjb9A7YLSCrYNsQ9RkdKvkItXCY+7Ps=; b=iAm/5/4l4Iu2sQd/C3BRpJaHyvdXj/1QtVTOGPQSewiogfzS8xz9D+cn1Y41TTIMms x4wyb5C1zQnKGvtDAyQy2htGVhm1JJqwAJpxvIa5GHe5BefQAik8NlQmG2152f4wkPqT 3xnHb6R+f9Q9gbbnWt6B75pTmJVQnTueyBY/IpL+sUIc7KuRieC4o0mGj/PA5drcF34r x6crmXIoxhkI9/a1QtZVVqGsl8snVj8B7XA34/KGvZRDrom5rOZX6Sg40gcKmIbr7UVU rzZLsusEQyUXbXHaE29K3kg6T/lC0QxjYjkZvIoTycXDxEyvakN21tEHLl6u2cZPYuIn 9gqQ== X-Gm-Message-State: AOJu0Yxk8zDL/i4uX44PqA8I6XtbRv3XLIABvIGakrEiT71zefaSMI62 4Aj0BAnbekNnpZkIi4QnFa4Osmqxh3HTCd1Miq2uO7mIxH6V+fo8dMqKEXg9D5c2qZsWl3q+Vlg WbrT1LuWJDdW0C+mvuxM5lD+iMyzf3DVAtrZW X-Gm-Gg: ASbGncuJ3FVH6vcCM1or81WXtueO6q6OLQejFt2oSqXOwZkQ8AQyrjC5ub0+bxQxPBV pXJJyuCFnskPHzjSpTEwH0oOcvnkS8LF4fwcwxvi98ETMjZWV9SYlImAVpVCnZBTDdipuC747QW PqZZZeN5bAYsUr4CDpSJcJuVQ= X-Google-Smtp-Source: AGHT+IERMlmTiEY16LSBOqjBLGr2jLhye5HJCGgrOTfL3+OEF3ze6LKB6fHXJ1wEEhTGELMa8C7QpUtqbW5n/zAfChI= X-Received: by 2002:a05:6402:4404:b0:5eb:ca9b:523a with SMTP id 4fb4d7f45d1cf-5f628598125mr17219240a12.20.1745422709268; Wed, 23 Apr 2025 08:38:29 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Francisco Olarte Date: Wed, 23 Apr 2025 17:37:53 +0200 X-Gm-Features: ATxdqUG0hZwi6CSw55e7zlvr0kuLZRk5Cma09YBMRbH4Of28LTQgVMjHoHfLGM4 Message-ID: Subject: Re: Feature Proposal: Column-Level DELETE Operation in SQL To: Abhishek Hatgine Cc: pgsql-general@postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, 22 Apr 2025 at 14:09, 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, allo= wing removal of specific column values without affecting the entire row. You will need to explain what you mean by that removal. I.e, if I have a table with two rows ( a =3D 1, b=3D2, c=3D3 ), and ( a=3D1= 1, b=3D22, c=3D33) how do you want it to look like when "removing the specific column value in a=3D1? ... > Currently, SQL provides two core commands: > DELETE =E2=80=93 to remove entire rows. > UPDATE =E2=80=93 to change or nullify column values. Because these are the operations allowed in the relational model. > 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. If you want to remove the value, you need to specify how it does look like, i.e. in my example: ( a =3D 1, c=3D3 ), and ( a=3D11, b=3D22, c=3D33) This is not allowed in relational, rows need to have the same structure. ( a =3D 1, b=3D*deleted* c=3D3 ), and ( a=3D11, b=3D22, c=3D33) This is what update does, using NULL for *deleted* ( NULL normaly means more "unknown". In your example, if you distinguish between deleted and unknown, you can use an array, limited to 0 or 1 elements, and use { null } for unknown, {} empty array for deleted. But there is not a concept of removed value in relational. > Proposed Syntax Examples > Here are some ideas for possible new syntax: > DELETE Address FROM Customers WHERE CustomerID =3D 103; > REMOVE COLUMN Address FROM Customers WHERE CustomerID =3D 103; And how you do propose them to work, i.e. explain to me how my simple example would look after delete b from example where a=3D1. > These would act as a shortcut or expressive alias for setting one or more= column values to NULL. Just set to null? You only have thought of trivial examples and syntactic sugar. Adding new commands comes with a heavy weight for every one, they have to be maintained, they need to be learnt in case some other team member uses this. It sounds like a terrible idea. > Why This Matters > Improved readability and code clarity. New keywords do not improve readability. > More intuitive for developers coming from languages or NoSQL systems wher= e fields can be "deleted" from an object/document. No. They mislead them to think rows do not have a fixed schema, where they have it. > Emphasizes intent: deleting a value is conceptually different from updati= ng it to NULL. Not in your example, you have proposed to do the same thing. The problem is sql is relational, relational is fixed schema, so you cannot "remove a column value" like you can in some NoSQL ( which are normally json++ stores ). > I understand this would require careful consideration within the SQL stan= dards, but I believe it could make SQL more expressive and beginner-friendl= y while preserving its power. Then try to write it a standard proposal. It is not that trivial. SQL is a base tool, if you want more expresiveness in your code you should probably just use any of the mapper technologies there are around. It is not that hard to make an SQL++ filter which translates this kinds of things to SQL. Francisco Olarte.