Does MODIFY retain other column attributes in MariaDB?

Viewed 47

Taking this example from the MariaDB knowledgebase:

CREATE TABLE t1 (
  a INT UNSIGNED AUTO_INCREMENT PRIMARY_KEY,
  b VARCHAR(20) NOT NULL UNIQUE
);
ALTER TABLE t1 MODIFY b VARCHAR(40);
  1. Will b still be NOT NULL after this statement?
  2. Will b still have a uniqueness constraint attached to it?

Assume the latest release of MariaDB.

1 Answers

After testing this myself, I concluded that:

  1. b will not retain the NOT NULL attribute; this is reset to the default of allowing nulls.
  2. The uniqueness constraint remains.

Apparently I also completely overlooked the fact that the knowledgebase explains this behavior: https://mariadb.com/kb/en/alter-table/#modify-column

Related