Last login: Sat Jun 1 11:44:42 on ttys000
bianshuaideMacBook-Pro:~ bianshuai$ mysql --default-character-set=gbk -uroot -proot
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.7.25 MySQL Community Server (GPL)
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> -- 1、创建数据库jt_db数据库(如果不存在才创建)
mysql> create database if not exists jt_db charset utf8;
Query OK, 1 row affected, 1 warning (0.00 sec)
mysql> use jt_db; -- 选择jt_db数据库
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> -- 2、在 jt_db 库中创建 stu 表(学生表)
mysql> drop table if exists stu;
Query OK, 0 rows affected (0.00 sec)
mysql> create table stu(
-> stuid varchar(50),
-> name varchar(50),
-> gender char(4),
-> addr varchar(50),
-> score double
-> );
Query OK, 0 rows affected (0.01 sec)
mysql> insert into stu values("1001",'张三','男', '北京', 86);
ERROR 1406 (22001): Data too long for column 'gender' at row 1