提交 a426a398 编写于 作者: M Mars Liu

text

上级 079814a1
{
"node_id": "mysql-27ff66e31d3d4118977cbbc04da6887e",
"keywords": [],
"keywords": ["text", "varchar", "char", "字符串", "文本"],
"children": [],
"export": [],
"export": [
"description.json"
],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
......
{
"type": "code_options",
"author": "Mars",
"source": "description.md",
"notebook_enable": false,
"exercise_id": "772f9b0947074197bbeb414fd5a094b0"
}
\ No newline at end of file
# 文本字段
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
{
"type": "code_options",
"author": "Mars",
"source": "binary.md",
"notebook_enable": false,
"exercise_id": "b3cdc6ba96d544969c08fe697df32dde"
}
\ No newline at end of file
# 二进制字符串
现在 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()
);
```
{
"node_id": "mysql-ec8f22f2c63a4f27bd12815644d0f3db",
"keywords": [],
"keywords": ["binary", "blob", "二进制"],
"children": [],
"export": [],
"export": [
"binary.json"
],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册