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 de1019c8ec3b4e73d05166d16c80939cbf1adb8a..f740f9be93742bba848dd60d1e9d67d4af826975 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 0000000000000000000000000000000000000000..80b0216a4914f68863f575774b51a16f729dd0c1 --- /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 0000000000000000000000000000000000000000..4d29f3bb15b186362b8ebc8521d43d68d68820e7 --- /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 0000000000000000000000000000000000000000..ac622bb210040a36347c1e4692e417accc975ce6 --- /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 0000000000000000000000000000000000000000..8fd9ef4d39e8e0bc4851f6cb909e44c2d42a726c --- /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 096f1eb012bfdbae82ada0d3f5fca2adf147c8d7..0c53be6d446570862f9fe87116a069cdb059fd3a 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