MySQL必備技能之設置編碼(九)

1、問題提出

在表中插入中文時,顯示亂碼。

2、問題解決

創建數據庫並指定編碼格式:

CREATE DATABASE world_test DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
USE world_test;

創建表格:

CREATE TABLE world_1(
city_id int not null auto_increment,
city_name char(50) not null,
date datetime not null,
city_price int not null
);

添加數據:

INSERT INTO world_1(
1,
'美國',
'2020-03-10',
12
);

查看數據:

SELECT * FROM world_1;

返回數據:

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章