提交 34901cee 编写于 作者: M Mars Liu

generated

上级 7bef956e
......@@ -3,5 +3,8 @@
"keywords": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
"group": 2,
"export": [
"generated.json"
]
}
\ No newline at end of file
{
"type": "code_options",
"author": "ccat",
"source": "generated.md",
"notebook_enable": false,
"exercise_id": "e09151d6764e4e14bd088c858db0a0e3"
}
\ No newline at end of file
# 生成列
Joe 需要为 Points 表
```mysql
create table points(
id int primary key auto_increment,
x float,
y float
)
```
增加一个生成列,保存每个点的模(modulus),即 `√(x^2 + y^2)` 。下面哪个操作是正确的?
## 答案
```mysql
alter table points add modulus double generated always as (sqrt(x*x + y*y));
```
## 选项
### A
```mysql
create generated modulus on table points as (sqrt(x*x + y*y));
```
### B
```mysql
alter table points add modulus generated always as (sqrt(x*x + y*y));
```
### C
```mysql
alter table points add modulus float generated sqrt(x*x + y*y);
```
......@@ -2233,7 +2233,7 @@
"children": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
"group": 2
}
},
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册