一次Navicat Premium 15(绿色) 命令页面的测试
Navicat Premium 15 :后台 SQL预览
CREATE TABLE NewTable (id int(11) NOT NULL AUTO_INCREMENT ,operation varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,operation_id int(11) NULL DEFAULT NULL ,operation_time datetime NULL DEFAULT NULL ,operation_params varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,PRIMARY KEY (id))ENGINE=InnoDBDEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ciAUTO_INCREMENT=2ROW_FORMAT=DYNAMIC;
CREATE TABLE ‘student_log’(’id‘ INT NOT NULL AUTO_INCREMENT, 这里有一个bug :INT没有11内存’operation‘ VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,’operation_id‘ INT(11),’operation_time‘ DATE, 2019-07-14 or '2019-07-14'’operation_params‘ VARCHAR(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL)ENGINE=INNODB 往下没有空格DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ciAUTO_INCREMENT=1ROW_FORMAT=DYNAMIC;
CHARACTER SET=utf8 这个是在建表的时候写的DEFAULT CHARACTER SET=utf8 这个好像是在后台配置的时候只有VARCHAR(200) 字符串才规定字符集和排序规则
CREATE TABLE ‘student_log’(’id‘ INT NOT NULL AUTO_INCREMENT, ’operation‘ VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,’operation_id‘ INT(11),’operation_time‘ DATE,’operation_params‘ VARCHAR(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL)ENGINE=INNODB DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ciAUTO_INCREMENT=1ROW_FORMAT=DYNAMIC;
1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key
CREATE TABLE ‘student_log’(’id‘ INT NOT NULL AUTO_INCREMENT, ’operation‘ VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,’operation_id‘ INT(11),’operation_time‘ DATE,’operation_params‘ VARCHAR(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULLPRIMARY KEY(’id‘))ENGINE=INNODB DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ciAUTO_INCREMENT=1ROW_FORMAT=DYNAMIC;
1067 - Invalid default value for '’operation_params‘' 不合法的值? 它说的这一句后面没有加','
CREATE TABLE student_log(
id INT NOT NULL AUTO_INCREMENT,
operation VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,operation_id INT(11),operation_time DATE,operation_params VARCHAR(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULLPRIMARY KEY(id))ENGINE=INNODB DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ciAUTO_INCREMENT=1ROW_FORMAT=DYNAMIC;
1067 - Invalid default value for 'operation_params' 不合法的默认值?
CREATE TABLE student_log(
id INT NOT NULL AUTO_INCREMENT, 这里没有 INT(11) 也没报错
operation VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,operation_id INT(11),operation_time DATE,operation_params VARCHAR(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,PRIMARY KEY(id))ENGINE=INNODB DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ciAUTO_INCREMENT=1ROW_FORMAT=DYNAMIC;
Query OK, 0 rows affected
注意:
别人写的name VARCHAR(20) PRIMARY KEY 字符列也可以成为主键。