Skip to content

Instantly share code, notes, and snippets.

@kastaneda
Created August 27, 2021 12:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kastaneda/0aae5469848784010159ef9cb9446165 to your computer and use it in GitHub Desktop.
Save kastaneda/0aae5469848784010159ef9cb9446165 to your computer and use it in GitHub Desktop.
Hi there
CREATE TABLE foo1 (id int(10) UNSIGNED NOT NULL, msg varchar(20) NOT NULL);
ALTER TABLE foo1 ADD PRIMARY KEY (id);
INSERT INTO foo1 (id, msg) VALUES (1, 'foo'), (2, 'bar');
/*
MariaDB [sandbox]> SELECT * FROM `foo1`;
+----+-----+
| id | msg |
+----+-----+
| 1 | foo |
| 2 | bar |
+----+-----+
*/
ALTER TABLE foo1 ADD xxx VARCHAR(20) NULL DEFAULT NULL, ADD UNIQUE (xxx);
/*
MariaDB [sandbox]> SELECT * FROM `foo1`;
+----+-----+------+
| id | msg | xxx |
+----+-----+------+
| 1 | foo | NULL |
| 2 | bar | NULL |
+----+-----+------+
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment