`SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- Table structure for user
DROP TABLE IF EXISTS user
;
CREATE TABLE user
(
uid
int(11) NOT NULL AUTO_INCREMENT,
username
varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '',
password
varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '',
PRIMARY KEY (uid
) USING BTREE,
UNIQUE INDEX username
(username
) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- Records of user
INSERT INTO user
VALUES (1, 'admin', '123');
INSERT INTO user
VALUES (2, '123', '456');
SET FOREIGN_KEY_CHECKS = 1;
`
唯一主键判断,若唯一主键重复执行修改,若不重复则插入,mysql方言
INSERT INTO USER ( username,
password ) VALUES ( 'demo', '789' ) ON DUPLICATE KEY UPDATE username = 123,
password = 456