Using Laravel Migrations, is there a way to create this an MyISAM table with a two-column primary key and an auto-increment in one of them?
CREATE TABLE animals (
grp ENUM('fish','mammal','bird') NOT NULL,
id MEDIUMINT NOT NULL AUTO_INCREMENT,
name CHAR(30) NOT NULL,
PRIMARY KEY (grp,id)
) ENGINE=MyISAM;
In this case the id AUTO_INCREMENT is done relative to the value of grp column. And you get something like this:
+--------+----+---------+
| grp | id | name |
+--------+----+---------+
| fish | 1 | lax |
| mammal | 1 | dog |
| mammal | 2 | cat |
| mammal | 3 | whale |
| bird | 1 | penguin |
| bird | 2 | ostrich |
+--------+----+---------+
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire