[mysql rookie] encountered an unsolvable error in creating a database with navicat

when learning the database, I tapped at the code in the book, but it couldn"t be implemented. I checked the source code and found no errors.
as shown in the picture, this is the content of the book:

clipboard.png

clipboard.png

:

clipboard.png
:

clipboard.png
:


:

clipboard.png

clipboard.png

this is the result even if you enter it in the terminal, which means it"s not the software, it"s the code itself, but the code itself is automatically generated by the software, so I can"t understand it. What"s wrong with
?

Feb.23,2022

gender field length


may be a character set encoding problem. Take a look at this


sex field to varchar


.

show variables like'% character%'; take a look at the default encoding. For the lower version of MySQL , the default encoding is latin1 , which is not supported in Chinese. Just change it to utf8 .

latin1:

db83-3306>>CREATE TABLE `test_c`  (                                                                                                                          
    ->   `studentNo` int(4) NOT NULL COMMENT '',
    ->   `loginPwd` varchar(20) NOT NULL COMMENT '',
    ->   `studentName` varchar(50) NOT NULL COMMENT '',
    ->   `sex` char(2) NOT NULL DEFAULT '' COMMENT '',
    ->   `gradeId` int(4) NULL COMMENT '',
    ->   `phone` varchar(50) NULL COMMENT '',
    ->   `address` varchar(255) NULL DEFAULT '' COMMENT '',
    ->   `bornDate` datetime(0) NULL COMMENT '',
    ->   `email` varchar(50) NULL COMMENT '',
    ->   `identityCard` varchar(18) NULL COMMENT '',
    ->   PRIMARY KEY (`studentNo`),
    ->   UNIQUE INDEX `n_identityCard`(`identityCard`(18))
    -> ) CHARSET=latin1 COMMENT = '';
ERROR 1067 (42000): Invalid default value for 'sex'

utf8:

db83-3306>>CREATE TABLE `test_c`  (
    ->   `studentNo` int(4) NOT NULL COMMENT '',
    ->   `loginPwd` varchar(20) NOT NULL COMMENT '',
    ->   `studentName` varchar(50) NOT NULL COMMENT '',
    ->   `sex` char(2) NOT NULL DEFAULT '' COMMENT '',
    ->   `gradeId` int(4) NULL COMMENT '',
    ->   `phone` varchar(50) NULL COMMENT '',
    ->   `address` varchar(255) NULL DEFAULT '' COMMENT '',
    ->   `bornDate` datetime(0) NULL COMMENT '',
    ->   `email` varchar(50) NULL COMMENT '',
    ->   `identityCard` varchar(18) NULL COMMENT '',
    ->   PRIMARY KEY (`studentNo`),
    ->   UNIQUE INDEX `n_identityCard`(`identityCard`(18))
    -> ) CHARSET=utf8 COMMENT = '';
Query OK, 0 rows affected (0.02 sec)
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3dd47-2c3d0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3dd47-2c3d0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?