[MDEV-13627] Support for ALTER TABLE MODIFY NOT NULL syntax Created: 2017-08-23  Updated: 2023-01-16

Status: Open
Project: MariaDB Server
Component/s: Data Definition - Alter Table, Server
Fix Version/s: None

Type: Task Priority: Minor
Reporter: Anders Karlsson Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Oracle supports a useful ALTER TABLE syntax that allows you to add / remove a NOT NULL constraint of a column wihile retaining the original datatype, i.e.

CREATE TABLE orders(order_id INTEGER NOT NULL PRIMARY KEY, customer_id INTEGER);
ALTER TABLE orders MODIFY customer_id NOT NULL;

This is rather useful in some cases.



 Comments   
Comment by Sergei Golubchik [ 2017-08-23 ]

FWIW, SQL Standard syntax is

ALTER TABLE orders ALTER customer_id SET NOT NULL

Comment by Anders Karlsson [ 2017-08-23 ]

That is true, I did check first but only in SQL:99, I see now that it is there in more recent versions of the SQL standard. In any case, the syntax I show is the Oracle one and the SQL:2011 one is different, but it is still a useful command, if for no other reasons so for Oracle compatibility.

Comment by Sergei Golubchik [ 2017-08-24 ]

Right. First, Oracle compatibility isn't bad per se (esp. taking into account 10.3 work). Second, we don't do ALTER TABLE according to SQL standard (yet). No ALTER COLUMN, for example, no SET. So doing it SQL Standard way would be strange and inconsistent. I'd say, we should support all ALTER TABLE standard syntax (not in this MDEV), but not introduce it piece-wise.

Generated at Thu Feb 08 08:07:04 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.