works:programmer:db-mysql:create-table
Создать таблицу MariaDB
DROP TABLE IF EXISTS `comment`; CREATE TABLE `comment` ( `id` INTEGER UNSIGNED AUTO_INCREMENT, `firstname` VARCHAR(50) NOT NULL, `lastname` VARCHAR(50) NOT NULL, `email` VARCHAR(128) NOT NULL, `phone` VARCHAR(20), `custinfo` JSON NOT NULL, `title` VARCHAR(50) GENERATED ALWAYS AS (JSON_VALUE(`custinfo`, "$.title")), `zipcode` VARCHAR(10) AS (JSON_VALUE(`custinfo`, "$.zipcode")), `created` DATETIME DEFAULT CURRENT_TIMESTAMP, `modified` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY PK_COMMENT_ID(`id`), UNIQUE KEY UI_COMMENT_EMAIL(`email`), KEY IX_COMMENT_ZIPCODE(`zipcode`) ); INSERT INTO `comment` ( `firstname` , `lastname` , `email` , `phone`, `custinfo` ) VALUES ("Eugene", "X", "example@example.com", "00123", '{"zipcode": "123123"}');
works/programmer/db-mysql/create-table.txt · Последнее изменение: 2022/05/24 01:52 — 127.0.0.1