From 99f28cbb6be4f335fee3e4ec235b7057f33f129e Mon Sep 17 00:00:00 2001 From: Mars Liu Date: Thu, 9 Jun 2022 20:01:18 +0800 Subject: [PATCH] convert --- .../config.json" | 6 ++- .../convert.json" | 7 +++ .../convert.md" | 48 +++++++++++++++++++ data/tree.json | 3 +- 4 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 "data/2.MySQL\344\270\255\351\230\266/3.\345\206\205\347\275\256\345\207\275\346\225\260/5.\345\205\266\345\256\203\345\207\275\346\225\260/convert.json" create mode 100644 "data/2.MySQL\344\270\255\351\230\266/3.\345\206\205\347\275\256\345\207\275\346\225\260/5.\345\205\266\345\256\203\345\207\275\346\225\260/convert.md" diff --git "a/data/2.MySQL\344\270\255\351\230\266/3.\345\206\205\347\275\256\345\207\275\346\225\260/5.\345\205\266\345\256\203\345\207\275\346\225\260/config.json" "b/data/2.MySQL\344\270\255\351\230\266/3.\345\206\205\347\275\256\345\207\275\346\225\260/5.\345\205\266\345\256\203\345\207\275\346\225\260/config.json" index 460272b..be5b840 100644 --- "a/data/2.MySQL\344\270\255\351\230\266/3.\345\206\205\347\275\256\345\207\275\346\225\260/5.\345\205\266\345\256\203\345\207\275\346\225\260/config.json" +++ "b/data/2.MySQL\344\270\255\351\230\266/3.\345\206\205\347\275\256\345\207\275\346\225\260/5.\345\205\266\345\256\203\345\207\275\346\225\260/config.json" @@ -2,11 +2,13 @@ "node_id": "mysql-df29b082d5364530b95bbdc14adc107e", "keywords": [ "函数", - "cast" + "cast", + "convert" ], "children": [], "export": [ - "cast.json" + "cast.json", + "convert.json" ], "keywords_must": [], "keywords_forbid": [], diff --git "a/data/2.MySQL\344\270\255\351\230\266/3.\345\206\205\347\275\256\345\207\275\346\225\260/5.\345\205\266\345\256\203\345\207\275\346\225\260/convert.json" "b/data/2.MySQL\344\270\255\351\230\266/3.\345\206\205\347\275\256\345\207\275\346\225\260/5.\345\205\266\345\256\203\345\207\275\346\225\260/convert.json" new file mode 100644 index 0000000..606fa78 --- /dev/null +++ "b/data/2.MySQL\344\270\255\351\230\266/3.\345\206\205\347\275\256\345\207\275\346\225\260/5.\345\205\266\345\256\203\345\207\275\346\225\260/convert.json" @@ -0,0 +1,7 @@ +{ + "type": "code_options", + "author": "ccat", + "source": "convert.md", + "notebook_enable": false, + "exercise_id": "a152ea2ab0c5410fa2d2b808afd063ae" +} \ No newline at end of file diff --git "a/data/2.MySQL\344\270\255\351\230\266/3.\345\206\205\347\275\256\345\207\275\346\225\260/5.\345\205\266\345\256\203\345\207\275\346\225\260/convert.md" "b/data/2.MySQL\344\270\255\351\230\266/3.\345\206\205\347\275\256\345\207\275\346\225\260/5.\345\205\266\345\256\203\345\207\275\346\225\260/convert.md" new file mode 100644 index 0000000..c63e469 --- /dev/null +++ "b/data/2.MySQL\344\270\255\351\230\266/3.\345\206\205\347\275\256\345\207\275\346\225\260/5.\345\205\266\345\256\203\345\207\275\346\225\260/convert.md" @@ -0,0 +1,48 @@ +# 编码转换 + +Joe 需要将下面这个查询 + +```mysql +select name from goods; +``` + +中的 name 字段的字符集改为 gb 18030,他应该怎么做? + +## 答案 + +```mysql +select convert(name using 'gb18030') from goods; +``` + +## 选项 + + +### A + +```mysql +select str(name, 'gb18303') from goods; +``` + + +### B + +```mysql +select encode(decode(name, 'utf8mb4'), 'gb18303') from goods; +``` + + +### C + +```mysql +select convert(name from 'utf8mb4' to 'gb18303') from goods; +``` + +### D + +```mysql +select convert(name to 'gb18303') from goods; +``` + +### E + +所有都错 \ No newline at end of file diff --git a/data/tree.json b/data/tree.json index c28a839..4f86682 100644 --- a/data/tree.json +++ b/data/tree.json @@ -958,7 +958,8 @@ "node_id": "mysql-df29b082d5364530b95bbdc14adc107e", "keywords": [ "函数", - "cast" + "cast", + "convert" ], "children": [], "keywords_must": [], -- GitLab