public inbox for [email protected]  
help / color / mirror / Atom feed
From: Laurenz Albe <[email protected]>
To: Abhishek Hatgine <[email protected]>
To: [email protected]
Subject: Re: Feature Proposal: Column-Level DELETE Operation in SQL
Date: Tue, 22 Apr 2025 15:39:58 +0200
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAD2voTQMUmNCKBok-_HvYLqFNECRWNkvqPruq0NcsFgd6g-Odw@mail.gmail.com>
References: <CAD2voTQMUmNCKBok-_HvYLqFNECRWNkvqPruq0NcsFgd6g-Odw@mail.gmail.com>

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 — 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:
>  * 
>    DELETE – to remove entire rows.
>  * 
>    UPDATE – to change or nullify column values.
>
> However, there’s no specific, expressive way to delete the value of a column directly.
> The typical workaround is to use:
>
> UPDATE Customers SET Address = NULL WHERE CustomerID = 103;
>
> While this works fine, it doesn't semantically express that the developer intends to
> remove the value — not just update it.
>
> Proposed Syntax Examples
> Here are some ideas for possible new syntax:
> 
> DELETE Address FROM Customers WHERE CustomerID = 103;
> -- or
> REMOVE COLUMN Address FROM Customers WHERE CustomerID = 103;
> And even:
> DELETE Address, PostalCode FROM Customers WHERE Country = 'India';
>
> These would act as a shortcut or expressive alias for setting one or more column values
> to NULL.
>
> Why This Matters
>  * Improved readability and code clarity.
>  * More intuitive for developers coming from languages or NoSQL systems where fields can be
>    "deleted" from an object/document.
>  * Emphasizes intent: deleting a value is conceptually different from updating it to NULL.
>  * Opens doors for potential enhancements in tooling and IDE support.
> I understand this would require careful consideration within the SQL standards, but I
> believe it could make SQL more expressive and beginner-friendly while preserving 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 syntax, 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 = NULL" or "SET col = DEFAULT".  So the UPDATE syntax is actually clearer.

- Also, the proposed syntax could easily be confused with "ALTER tab DROP col", 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






reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: Feature Proposal: Column-Level DELETE Operation in SQL
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox