Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CSDN 技术社区
skill_tree_mysql
提交
9adba7b6
S
skill_tree_mysql
项目概览
CSDN 技术社区
/
skill_tree_mysql
通知
21
Star
0
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
skill_tree_mysql
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
9adba7b6
编写于
5月 23, 2022
作者:
M
Mars Liu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
insert
上级
a426a398
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
81 addition
and
7 deletion
+81
-7
data/1.MySQL初阶/4.数据类型/1.数值类型/numbers.json
data/1.MySQL初阶/4.数据类型/1.数值类型/numbers.json
+1
-1
data/1.MySQL初阶/4.数据类型/2.日期和时间类型/datetime.json
data/1.MySQL初阶/4.数据类型/2.日期和时间类型/datetime.json
+1
-1
data/1.MySQL初阶/4.数据类型/3.文本字符串类型/description.json
data/1.MySQL初阶/4.数据类型/3.文本字符串类型/description.json
+1
-1
data/1.MySQL初阶/4.数据类型/4.二进制字符串类型/binary.json
data/1.MySQL初阶/4.数据类型/4.二进制字符串类型/binary.json
+1
-1
data/1.MySQL初阶/5.数据修改/1.插入/config.json
data/1.MySQL初阶/5.数据修改/1.插入/config.json
+3
-1
data/1.MySQL初阶/5.数据修改/1.插入/insert.json
data/1.MySQL初阶/5.数据修改/1.插入/insert.json
+8
-0
data/1.MySQL初阶/5.数据修改/1.插入/insert.md
data/1.MySQL初阶/5.数据修改/1.插入/insert.md
+54
-0
data/tree.json
data/tree.json
+12
-2
未找到文件。
data/1.MySQL初阶/4.数据类型/1.数值类型/numbers.json
浏览文件 @
9adba7b6
{
{
"type"
:
"code_options"
,
"type"
:
"code_options"
,
"author"
:
"
Mars
"
,
"author"
:
"
ccat
"
,
"source"
:
"numbers.md"
,
"source"
:
"numbers.md"
,
"notebook_enable"
:
false
,
"notebook_enable"
:
false
,
"exercise_id"
:
"0093549d885b4eec8f556fc86cc60431"
"exercise_id"
:
"0093549d885b4eec8f556fc86cc60431"
...
...
data/1.MySQL初阶/4.数据类型/2.日期和时间类型/datetime.json
浏览文件 @
9adba7b6
{
{
"type"
:
"code_options"
,
"type"
:
"code_options"
,
"author"
:
"
Mars
"
,
"author"
:
"
ccat
"
,
"source"
:
"datetime.md"
,
"source"
:
"datetime.md"
,
"notebook_enable"
:
false
,
"notebook_enable"
:
false
,
"exercise_id"
:
"9f51c5816b1047368bdab70cb20d5116"
"exercise_id"
:
"9f51c5816b1047368bdab70cb20d5116"
...
...
data/1.MySQL初阶/4.数据类型/3.文本字符串类型/description.json
浏览文件 @
9adba7b6
{
{
"type"
:
"code_options"
,
"type"
:
"code_options"
,
"author"
:
"
Mars
"
,
"author"
:
"
ccat
"
,
"source"
:
"description.md"
,
"source"
:
"description.md"
,
"notebook_enable"
:
false
,
"notebook_enable"
:
false
,
"exercise_id"
:
"772f9b0947074197bbeb414fd5a094b0"
"exercise_id"
:
"772f9b0947074197bbeb414fd5a094b0"
...
...
data/1.MySQL初阶/4.数据类型/4.二进制字符串类型/binary.json
浏览文件 @
9adba7b6
{
{
"type"
:
"code_options"
,
"type"
:
"code_options"
,
"author"
:
"
Mars
"
,
"author"
:
"
ccat
"
,
"source"
:
"binary.md"
,
"source"
:
"binary.md"
,
"notebook_enable"
:
false
,
"notebook_enable"
:
false
,
"exercise_id"
:
"b3cdc6ba96d544969c08fe697df32dde"
"exercise_id"
:
"b3cdc6ba96d544969c08fe697df32dde"
...
...
data/1.MySQL初阶/5.数据修改/1.插入/config.json
浏览文件 @
9adba7b6
...
@@ -2,7 +2,9 @@
...
@@ -2,7 +2,9 @@
"node_id"
:
"mysql-fcca525ab0f04f16834ded9b2b3f38a4"
,
"node_id"
:
"mysql-fcca525ab0f04f16834ded9b2b3f38a4"
,
"keywords"
:
[],
"keywords"
:
[],
"children"
:
[],
"children"
:
[],
"export"
:
[],
"export"
:
[
"insert.json"
],
"keywords_must"
:
[],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
"group"
:
0
...
...
data/1.MySQL初阶/5.数据修改/1.插入/insert.json
0 → 100644
浏览文件 @
9adba7b6
{
"type"
:
"code_options"
,
"author"
:
"ccat"
,
"source"
:
"insert.md"
,
"notebook_enable"
:
false
,
"exercise_id"
:
"81e312020bb04761800918d54a7a5851"
}
\ No newline at end of file
data/1.MySQL初阶/5.数据修改/1.插入/insert.md
0 → 100644
浏览文件 @
9adba7b6
# 插入
Goods 数据库中有一个表:
```
mysql
create table book(
id int primary key auto_increment,
title varchar(200) not null ,
description varchar(1000) default '',
price decimal(12, 4),
isbn char(16) not null ,
publish_at date not null
);
create unique index idx_book_isbn on book(isbn);
```
那么下列哪个选项的代码可以执行成功?
## 答案
```
mysql
insert into book(title, price, isbn, publish_at) select 'a book title', 25.4, 'xx-xxxx-xxxx', '2019-12-1';
insert into book(title, price, isbn, publish_at) select 'a other book title', 25.4, 'yy-yyyy-xxxx', '2019-12-1';
```
## 选项
### 唯一键冲突
```
mysql
insert into book(title, price, isbn, publish_at) select 'a book title', 25.4, 'xx-xxxx-xxxx', '2019-12-1';
insert into book(title, price, isbn, publish_at) select 'a other book title', 35.4, 'xx-xxxx-xxxx', '2019-12-1';
```
### 缺少必要的列
```
mysql
insert into book(price, isbn, publish_at) select 25.4, 'xx-xxxx-xxxx', '2019-12-1';
insert into book(price, isbn, publish_at) select 35.4, 'yy-yyyy-xxxx', '2019-12-1';
```
### 类型错误
```
mysql
insert into book(title, price, isbn, publish_at) select 'a book title', 'unknown', 'xx-xxxx-xxxx', '2019-12-1';
insert into book(title, price, isbn, publish_at) select 'a other book title', 'unknown', 'xx-xxxx-xxxx', '2019-12-1';
```
### 违反非空约束
```
mysql
insert into book(title, price, isbn, publish_at) select null, 'unknown', 'xx-xxxx-xxxx', '2019-12-1';
insert into book(title, price, isbn, publish_at) select null, 'unknown', 'xx-xxxx-xxxx', '2019-12-1';
```
data/tree.json
浏览文件 @
9adba7b6
...
@@ -157,7 +157,13 @@
...
@@ -157,7 +157,13 @@
{
{
"文本字符串类型"
:
{
"文本字符串类型"
:
{
"node_id"
:
"mysql-27ff66e31d3d4118977cbbc04da6887e"
,
"node_id"
:
"mysql-27ff66e31d3d4118977cbbc04da6887e"
,
"keywords"
:
[],
"keywords"
:
[
"text"
,
"varchar"
,
"char"
,
"字符串"
,
"文本"
],
"children"
:
[],
"children"
:
[],
"keywords_must"
:
[],
"keywords_must"
:
[],
"keywords_forbid"
:
[]
"keywords_forbid"
:
[]
...
@@ -166,7 +172,11 @@
...
@@ -166,7 +172,11 @@
{
{
"二进制字符串类型"
:
{
"二进制字符串类型"
:
{
"node_id"
:
"mysql-ec8f22f2c63a4f27bd12815644d0f3db"
,
"node_id"
:
"mysql-ec8f22f2c63a4f27bd12815644d0f3db"
,
"keywords"
:
[],
"keywords"
:
[
"binary"
,
"blob"
,
"二进制"
],
"children"
:
[],
"children"
:
[],
"keywords_must"
:
[],
"keywords_must"
:
[],
"keywords_forbid"
:
[]
"keywords_forbid"
:
[]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录