From a426a39830fcdb0249e276aeaa4f48ec9047bd84 Mon Sep 17 00:00:00 2001 From: Mars Liu Date: Mon, 23 May 2022 23:22:47 +0800 Subject: [PATCH] text --- .../config.json" | 6 +- .../description.json" | 7 ++ .../description.md" | 88 +++++++++++++++++ .../binary.json" | 7 ++ .../binary.md" | 94 +++++++++++++++++++ .../config.json" | 6 +- 6 files changed, 204 insertions(+), 4 deletions(-) create mode 100644 "data/1.MySQL\345\210\235\351\230\266/4.\346\225\260\346\215\256\347\261\273\345\236\213/3.\346\226\207\346\234\254\345\255\227\347\254\246\344\270\262\347\261\273\345\236\213/description.json" create mode 100644 "data/1.MySQL\345\210\235\351\230\266/4.\346\225\260\346\215\256\347\261\273\345\236\213/3.\346\226\207\346\234\254\345\255\227\347\254\246\344\270\262\347\261\273\345\236\213/description.md" create mode 100644 "data/1.MySQL\345\210\235\351\230\266/4.\346\225\260\346\215\256\347\261\273\345\236\213/4.\344\272\214\350\277\233\345\210\266\345\255\227\347\254\246\344\270\262\347\261\273\345\236\213/binary.json" create mode 100644 "data/1.MySQL\345\210\235\351\230\266/4.\346\225\260\346\215\256\347\261\273\345\236\213/4.\344\272\214\350\277\233\345\210\266\345\255\227\347\254\246\344\270\262\347\261\273\345\236\213/binary.md" diff --git "a/data/1.MySQL\345\210\235\351\230\266/4.\346\225\260\346\215\256\347\261\273\345\236\213/3.\346\226\207\346\234\254\345\255\227\347\254\246\344\270\262\347\261\273\345\236\213/config.json" "b/data/1.MySQL\345\210\235\351\230\266/4.\346\225\260\346\215\256\347\261\273\345\236\213/3.\346\226\207\346\234\254\345\255\227\347\254\246\344\270\262\347\261\273\345\236\213/config.json" index de1019c..f740f9b 100644 --- "a/data/1.MySQL\345\210\235\351\230\266/4.\346\225\260\346\215\256\347\261\273\345\236\213/3.\346\226\207\346\234\254\345\255\227\347\254\246\344\270\262\347\261\273\345\236\213/config.json" +++ "b/data/1.MySQL\345\210\235\351\230\266/4.\346\225\260\346\215\256\347\261\273\345\236\213/3.\346\226\207\346\234\254\345\255\227\347\254\246\344\270\262\347\261\273\345\236\213/config.json" @@ -1,8 +1,10 @@ { "node_id": "mysql-27ff66e31d3d4118977cbbc04da6887e", - "keywords": [], + "keywords": ["text", "varchar", "char", "字符串", "文本"], "children": [], - "export": [], + "export": [ + "description.json" + ], "keywords_must": [], "keywords_forbid": [], "group": 0 diff --git "a/data/1.MySQL\345\210\235\351\230\266/4.\346\225\260\346\215\256\347\261\273\345\236\213/3.\346\226\207\346\234\254\345\255\227\347\254\246\344\270\262\347\261\273\345\236\213/description.json" "b/data/1.MySQL\345\210\235\351\230\266/4.\346\225\260\346\215\256\347\261\273\345\236\213/3.\346\226\207\346\234\254\345\255\227\347\254\246\344\270\262\347\261\273\345\236\213/description.json" new file mode 100644 index 0000000..80b0216 --- /dev/null +++ "b/data/1.MySQL\345\210\235\351\230\266/4.\346\225\260\346\215\256\347\261\273\345\236\213/3.\346\226\207\346\234\254\345\255\227\347\254\246\344\270\262\347\261\273\345\236\213/description.json" @@ -0,0 +1,7 @@ +{ + "type": "code_options", + "author": "Mars", + "source": "description.md", + "notebook_enable": false, + "exercise_id": "772f9b0947074197bbeb414fd5a094b0" +} \ No newline at end of file diff --git "a/data/1.MySQL\345\210\235\351\230\266/4.\346\225\260\346\215\256\347\261\273\345\236\213/3.\346\226\207\346\234\254\345\255\227\347\254\246\344\270\262\347\261\273\345\236\213/description.md" "b/data/1.MySQL\345\210\235\351\230\266/4.\346\225\260\346\215\256\347\261\273\345\236\213/3.\346\226\207\346\234\254\345\255\227\347\254\246\344\270\262\347\261\273\345\236\213/description.md" new file mode 100644 index 0000000..4d29f3b --- /dev/null +++ "b/data/1.MySQL\345\210\235\351\230\266/4.\346\225\260\346\215\256\347\261\273\345\236\213/3.\346\226\207\346\234\254\345\255\227\347\254\246\344\270\262\347\261\273\345\236\213/description.md" @@ -0,0 +1,88 @@ +# 文本字段 + +Joe 在设计订单表,他已经完成了下列内容: + +```mysql +create table orders ( + id int primary key auto_increment, + item_id int, + amount int, + unit_price decimal(12, 4), + total_price decimal(12, 4), + ts timestamp default now() +); +``` + +现在他需要给订单表加入一个 description 字段,这个字段需要保存订单的文字说明,这些文本不会超过两千字节, Joe 应该把建表语句修改为: + +## 答案 + +```mysql +create table orders ( + id int primary key auto_increment, + item_id int, + amount int, + unit_price decimal(12, 4), + total_price decimal(12, 4), + description varchar(2000), + ts timestamp default now() +); +``` + +## 选项 + +### A + +```mysql +create table orders ( + id int primary key auto_increment, + item_id int, + amount int, + unit_price decimal(12, 4), + total_price decimal(12, 4), + description char(2000), + ts timestamp default now() +); +``` + +### B + +```mysql +create table orders ( + id int primary key auto_increment, + item_id int, + amount int, + unit_price decimal(12, 4), + total_price decimal(12, 4), + description varchar(256) default '', + ts timestamp default now() +); +``` + +### C + +```mysql +create table orders ( + id int primary key auto_increment, + item_id int, + amount int, + unit_price decimal(12, 4), + total_price decimal(12, 4), + description text(2000), + ts timestamp default now() +); +``` + +### D + +```mysql +create table orders ( + id int primary key auto_increment, + item_id int, + amount int, + unit_price decimal(12, 4), + total_price decimal(12, 4), + description tinytext(2000), + ts timestamp default now() +); +``` \ No newline at end of file diff --git "a/data/1.MySQL\345\210\235\351\230\266/4.\346\225\260\346\215\256\347\261\273\345\236\213/4.\344\272\214\350\277\233\345\210\266\345\255\227\347\254\246\344\270\262\347\261\273\345\236\213/binary.json" "b/data/1.MySQL\345\210\235\351\230\266/4.\346\225\260\346\215\256\347\261\273\345\236\213/4.\344\272\214\350\277\233\345\210\266\345\255\227\347\254\246\344\270\262\347\261\273\345\236\213/binary.json" new file mode 100644 index 0000000..ac622bb --- /dev/null +++ "b/data/1.MySQL\345\210\235\351\230\266/4.\346\225\260\346\215\256\347\261\273\345\236\213/4.\344\272\214\350\277\233\345\210\266\345\255\227\347\254\246\344\270\262\347\261\273\345\236\213/binary.json" @@ -0,0 +1,7 @@ +{ + "type": "code_options", + "author": "Mars", + "source": "binary.md", + "notebook_enable": false, + "exercise_id": "b3cdc6ba96d544969c08fe697df32dde" +} \ No newline at end of file diff --git "a/data/1.MySQL\345\210\235\351\230\266/4.\346\225\260\346\215\256\347\261\273\345\236\213/4.\344\272\214\350\277\233\345\210\266\345\255\227\347\254\246\344\270\262\347\261\273\345\236\213/binary.md" "b/data/1.MySQL\345\210\235\351\230\266/4.\346\225\260\346\215\256\347\261\273\345\236\213/4.\344\272\214\350\277\233\345\210\266\345\255\227\347\254\246\344\270\262\347\261\273\345\236\213/binary.md" new file mode 100644 index 0000000..8fd9ef4 --- /dev/null +++ "b/data/1.MySQL\345\210\235\351\230\266/4.\346\225\260\346\215\256\347\261\273\345\236\213/4.\344\272\214\350\277\233\345\210\266\345\255\227\347\254\246\344\270\262\347\261\273\345\236\213/binary.md" @@ -0,0 +1,94 @@ +# 二进制字符串 + +现在 Joe 的订单表已经有了如下形态: + +```mysql +create table orders ( + id int primary key auto_increment, + item_id int, + amount int, + unit_price decimal(12, 4), + total_price decimal(12, 4), + description varchar(2000), + ts timestamp default now() +); +``` + +他需要添加一个字段,用来保存订单的相关图片,由于特殊的业务需要,这些图片必须保存在数据库中,图片的大小不超过100K。那么他应该将建表语句修改为: + +## 答案 + +```mysql +create table orders ( + id int primary key auto_increment, + item_id int, + amount int, + unit_price decimal(12, 4), + total_price decimal(12, 4), + description varchar(2000), + picture blob, + ts timestamp default now() +); +``` + +## 选项 + +### A + +```mysql +create table orders ( + id int primary key auto_increment, + item_id int, + amount int, + unit_price decimal(12, 4), + total_price decimal(12, 4), + description varchar(2000), + picture varchar(100000), + ts timestamp default now() +); +``` + +### B + +```mysql +create table orders ( + id int primary key auto_increment, + item_id int, + amount int, + unit_price decimal(12, 4), + total_price decimal(12, 4), + description varchar(2000), + picture text, + ts timestamp default now() +); +``` + +### C + +```mysql +create table orders ( + id int primary key auto_increment, + item_id int, + amount int, + unit_price decimal(12, 4), + total_price decimal(12, 4), + description varchar(2000), + picture binary(100000), + ts timestamp default now() +); +``` + +### D + +```mysql +create table orders ( + id int primary key auto_increment, + item_id int, + amount int, + unit_price decimal(12, 4), + total_price decimal(12, 4), + description varchar(2000), + picture varbinary(100000), + ts timestamp default now() +); +``` diff --git "a/data/1.MySQL\345\210\235\351\230\266/4.\346\225\260\346\215\256\347\261\273\345\236\213/4.\344\272\214\350\277\233\345\210\266\345\255\227\347\254\246\344\270\262\347\261\273\345\236\213/config.json" "b/data/1.MySQL\345\210\235\351\230\266/4.\346\225\260\346\215\256\347\261\273\345\236\213/4.\344\272\214\350\277\233\345\210\266\345\255\227\347\254\246\344\270\262\347\261\273\345\236\213/config.json" index 096f1eb..0c53be6 100644 --- "a/data/1.MySQL\345\210\235\351\230\266/4.\346\225\260\346\215\256\347\261\273\345\236\213/4.\344\272\214\350\277\233\345\210\266\345\255\227\347\254\246\344\270\262\347\261\273\345\236\213/config.json" +++ "b/data/1.MySQL\345\210\235\351\230\266/4.\346\225\260\346\215\256\347\261\273\345\236\213/4.\344\272\214\350\277\233\345\210\266\345\255\227\347\254\246\344\270\262\347\261\273\345\236\213/config.json" @@ -1,8 +1,10 @@ { "node_id": "mysql-ec8f22f2c63a4f27bd12815644d0f3db", - "keywords": [], + "keywords": ["binary", "blob", "二进制"], "children": [], - "export": [], + "export": [ + "binary.json" + ], "keywords_must": [], "keywords_forbid": [], "group": 0 -- GitLab