init
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
node_modules
|
||||
4
docs/.vuepress/config.js
Normal file
@@ -0,0 +1,4 @@
|
||||
module.exports = {
|
||||
title: '测试',
|
||||
description: '测试'
|
||||
}
|
||||
20
docs/.vuepress/dist/404.html
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>测试</title>
|
||||
<meta name="generator" content="VuePress 1.8.2">
|
||||
|
||||
<meta name="description" content="测试">
|
||||
|
||||
<link rel="preload" href="/assets/css/0.styles.e4d8b86b.css" as="style"><link rel="preload" href="/assets/js/app.44f0a4c8.js" as="script"><link rel="preload" href="/assets/js/9.4839daec.js" as="script"><link rel="prefetch" href="/assets/js/10.c524dfdd.js"><link rel="prefetch" href="/assets/js/2.ed656cef.js"><link rel="prefetch" href="/assets/js/3.4b56ecab.js"><link rel="prefetch" href="/assets/js/4.cf9ea75d.js"><link rel="prefetch" href="/assets/js/5.d2773c15.js"><link rel="prefetch" href="/assets/js/6.a7a6a0d9.js"><link rel="prefetch" href="/assets/js/7.44486ff1.js"><link rel="prefetch" href="/assets/js/8.4b83fec6.js">
|
||||
<link rel="stylesheet" href="/assets/css/0.styles.e4d8b86b.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app" data-server-rendered="true"><div class="theme-container"><div class="theme-default-content"><h1>404</h1> <blockquote>Looks like we've got some broken links.</blockquote> <a href="/" class="router-link-active">
|
||||
Take me home.
|
||||
</a></div></div><div class="global-ui"></div></div>
|
||||
<script src="/assets/js/app.44f0a4c8.js" defer></script><script src="/assets/js/9.4839daec.js" defer></script>
|
||||
</body>
|
||||
</html>
|
||||
1
docs/.vuepress/dist/assets/css/0.styles.e4d8b86b.css
vendored
Normal file
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 37 KiB |
|
After Width: | Height: | Size: 51 KiB |
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 37 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 37 KiB |
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 54 KiB |
|
After Width: | Height: | Size: 37 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 35 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 29 KiB |
|
After Width: | Height: | Size: 54 KiB |
|
After Width: | Height: | Size: 36 KiB |
|
After Width: | Height: | Size: 37 KiB |
|
After Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 33 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 33 KiB |
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 37 KiB |
|
After Width: | Height: | Size: 36 KiB |
|
After Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 24 KiB |
1
docs/.vuepress/dist/assets/img/search.83621669.svg
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?><svg xmlns="http://www.w3.org/2000/svg" width="12" height="13"><g stroke-width="2" stroke="#aaa" fill="none"><path d="M11.29 11.71l-4-4"/><circle cx="5" cy="5" r="4"/></g></svg>
|
||||
|
After Width: | Height: | Size: 216 B |
1
docs/.vuepress/dist/assets/js/10.c524dfdd.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
(window.webpackJsonp=window.webpackJsonp||[]).push([[10],{402:function(t,a,s){"use strict";s.r(a);var r=s(45),e=Object(r.a)({},(function(){var t=this,a=t.$createElement,s=t._self._c||a;return s("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[s("h1",{attrs:{id:"测试课程教案"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#测试课程教案"}},[t._v("#")]),t._v(" 测试课程教案")]),t._v(" "),s("h2",{attrs:{id:"mysql"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#mysql"}},[t._v("#")]),t._v(" mysql")]),t._v(" "),s("h2",{attrs:{id:"http"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#http"}},[t._v("#")]),t._v(" http")]),t._v(" "),s("h2",{attrs:{id:"flask"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#flask"}},[t._v("#")]),t._v(" flask")]),t._v(" "),s("h2",{attrs:{id:"linux"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#linux"}},[t._v("#")]),t._v(" linux")])])}),[],!1,null,null,null);a.default=e.exports}}]);
|
||||
1
docs/.vuepress/dist/assets/js/2.ed656cef.js
vendored
Normal file
1
docs/.vuepress/dist/assets/js/3.4b56ecab.js
vendored
Normal file
1
docs/.vuepress/dist/assets/js/4.cf9ea75d.js
vendored
Normal file
1
docs/.vuepress/dist/assets/js/5.d2773c15.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
(window.webpackJsonp=window.webpackJsonp||[]).push([[5],{327:function(t,e,n){},394:function(t,e,n){"use strict";n(327)},405:function(t,e,n){"use strict";n.r(e);var i={functional:!0,props:{type:{type:String,default:"tip"},text:String,vertical:{type:String,default:"top"}},render:function(t,e){var n=e.props,i=e.slots;return t("span",{class:["badge",n.type],style:{verticalAlign:n.vertical}},n.text||i().default)}},r=(n(394),n(45)),p=Object(r.a)(i,void 0,void 0,!1,null,"15b7b770",null);e.default=p.exports}}]);
|
||||
1
docs/.vuepress/dist/assets/js/6.a7a6a0d9.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
(window.webpackJsonp=window.webpackJsonp||[]).push([[6],{328:function(t,e,a){},395:function(t,e,a){"use strict";a(328)},399:function(t,e,a){"use strict";a.r(e);var n={name:"CodeBlock",props:{title:{type:String,required:!0},active:{type:Boolean,default:!1}},mounted:function(){this.$parent&&this.$parent.loadTabs&&this.$parent.loadTabs()}},i=(a(395),a(45)),s=Object(i.a)(n,(function(){var t=this.$createElement;return(this._self._c||t)("div",{staticClass:"theme-code-block",class:{"theme-code-block__active":this.active}},[this._t("default")],2)}),[],!1,null,"759a7d02",null);e.default=s.exports}}]);
|
||||
1
docs/.vuepress/dist/assets/js/7.44486ff1.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
(window.webpackJsonp=window.webpackJsonp||[]).push([[7],{329:function(e,t,a){},396:function(e,t,a){"use strict";a(329)},400:function(e,t,a){"use strict";a.r(t);a(66),a(27),a(94),a(95);var o={name:"CodeGroup",data:function(){return{codeTabs:[],activeCodeTabIndex:-1}},watch:{activeCodeTabIndex:function(e){this.activateCodeTab(e)}},mounted:function(){this.loadTabs()},methods:{changeCodeTab:function(e){this.activeCodeTabIndex=e},loadTabs:function(){var e=this;this.codeTabs=(this.$slots.default||[]).filter((function(e){return Boolean(e.componentOptions)})).map((function(t,a){return""===t.componentOptions.propsData.active&&(e.activeCodeTabIndex=a),{title:t.componentOptions.propsData.title,elm:t.elm}})),-1===this.activeCodeTabIndex&&this.codeTabs.length>0&&(this.activeCodeTabIndex=0),this.activateCodeTab(0)},activateCodeTab:function(e){this.codeTabs.forEach((function(e){e.elm&&e.elm.classList.remove("theme-code-block__active")})),this.codeTabs[e].elm&&this.codeTabs[e].elm.classList.add("theme-code-block__active")}}},n=(a(396),a(45)),c=Object(n.a)(o,(function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("ClientOnly",[a("div",{staticClass:"theme-code-group"},[a("div",{staticClass:"theme-code-group__nav"},[a("ul",{staticClass:"theme-code-group__ul"},e._l(e.codeTabs,(function(t,o){return a("li",{key:t.title,staticClass:"theme-code-group__li"},[a("button",{staticClass:"theme-code-group__nav-tab",class:{"theme-code-group__nav-tab-active":o===e.activeCodeTabIndex},on:{click:function(t){return e.changeCodeTab(o)}}},[e._v("\n "+e._s(t.title)+"\n ")])])})),0)]),e._v(" "),e._t("default"),e._v(" "),e.codeTabs.length<1?a("pre",{staticClass:"pre-blank"},[e._v("// Make sure to add code blocks to your code group")]):e._e()],2)])}),[],!1,null,"deefee04",null);t.default=c.exports}}]);
|
||||
1
docs/.vuepress/dist/assets/js/8.4b83fec6.js
vendored
Normal file
1
docs/.vuepress/dist/assets/js/9.4839daec.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
(window.webpackJsonp=window.webpackJsonp||[]).push([[9],{398:function(t,e,s){"use strict";s.r(e);var n=["There's nothing here.","How did we get here?","That's a Four-Oh-Four.","Looks like we've got some broken links."],o={methods:{getMsg:function(){return n[Math.floor(Math.random()*n.length)]}}},i=s(45),h=Object(i.a)(o,(function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"theme-container"},[e("div",{staticClass:"theme-default-content"},[e("h1",[this._v("404")]),this._v(" "),e("blockquote",[this._v(this._s(this.getMsg()))]),this._v(" "),e("RouterLink",{attrs:{to:"/"}},[this._v("\n Take me home.\n ")])],1)])}),[],!1,null,null,null);e.default=h.exports}}]);
|
||||
8
docs/.vuepress/dist/assets/js/app.44f0a4c8.js
vendored
Normal file
18
docs/.vuepress/dist/index.html
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>测试课程教案 | 测试</title>
|
||||
<meta name="generator" content="VuePress 1.8.2">
|
||||
|
||||
<meta name="description" content="测试">
|
||||
|
||||
<link rel="preload" href="/assets/css/0.styles.e4d8b86b.css" as="style"><link rel="preload" href="/assets/js/app.44f0a4c8.js" as="script"><link rel="preload" href="/assets/js/2.ed656cef.js" as="script"><link rel="preload" href="/assets/js/10.c524dfdd.js" as="script"><link rel="prefetch" href="/assets/js/3.4b56ecab.js"><link rel="prefetch" href="/assets/js/4.cf9ea75d.js"><link rel="prefetch" href="/assets/js/5.d2773c15.js"><link rel="prefetch" href="/assets/js/6.a7a6a0d9.js"><link rel="prefetch" href="/assets/js/7.44486ff1.js"><link rel="prefetch" href="/assets/js/8.4b83fec6.js"><link rel="prefetch" href="/assets/js/9.4839daec.js">
|
||||
<link rel="stylesheet" href="/assets/css/0.styles.e4d8b86b.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app" data-server-rendered="true"><div class="theme-container no-sidebar"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" aria-current="page" class="home-link router-link-exact-active router-link-active"><!----> <span class="site-name">测试</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <!----></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><!----> <!----> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="测试课程教案"><a href="#测试课程教案" class="header-anchor">#</a> 测试课程教案</h1> <h2 id="mysql"><a href="#mysql" class="header-anchor">#</a> mysql</h2> <h2 id="http"><a href="#http" class="header-anchor">#</a> http</h2> <h2 id="flask"><a href="#flask" class="header-anchor">#</a> flask</h2> <h2 id="linux"><a href="#linux" class="header-anchor">#</a> linux</h2></div> <footer class="page-edit"><!----> <!----></footer> <!----> </main></div><div class="global-ui"></div></div>
|
||||
<script src="/assets/js/app.44f0a4c8.js" defer></script><script src="/assets/js/2.ed656cef.js" defer></script><script src="/assets/js/10.c524dfdd.js" defer></script>
|
||||
</body>
|
||||
</html>
|
||||
35
docs/.vuepress/dist/mysql/create.html
vendored
Normal file
18
docs/.vuepress/dist/mysql/index.html
vendored
Normal file
26
docs/.vuepress/dist/mysql/install.html
vendored
Normal file
9
docs/README.md
Normal file
@@ -0,0 +1,9 @@
|
||||
# 测试课程教案
|
||||
|
||||
## mysql
|
||||
|
||||
## http
|
||||
|
||||
## flask
|
||||
|
||||
## linux
|
||||
55
docs/mysql/README.md
Normal file
@@ -0,0 +1,55 @@
|
||||
# mysql
|
||||
|
||||
> 这一章节主要是介绍mysql是什么
|
||||
|
||||
## 什么是数据库
|
||||
|
||||
数据库(Database)是按照数据结构来组织、存储和管理数据的仓库。
|
||||
|
||||
每个数据库都有一个或多个不同的 API 用于创建,访问,管理,搜索和复制所保存的数据。
|
||||
|
||||
我们也可以将数据存储在文件中,但是在文件中读写数据速度相对较慢。
|
||||
|
||||
所以,现在我们使用关系型数据库管理系统(RDBMS)来存储和管理大数据量。所谓的关系型数据库,是建立在关系模型基础上的数据库,借助于集合代数等数学概念和方法来处理数据库中的数据。
|
||||
|
||||
RDBMS 即关系数据库管理系统(Relational Database Management System)的特点:
|
||||
|
||||
1. 数据以表格的形式出现
|
||||
2. 每行为各种记录名称
|
||||
3. 每列为记录名称所对应的数据域
|
||||
4. 许多的行和列组成一张表单
|
||||
5. 若干的表单组成database
|
||||
|
||||
> 可以理解为数据库就是一个文件夹,文件夹中存放的是excel,一条数据就是excel中的一行。
|
||||
|
||||
## RDBMS 术语
|
||||
|
||||
在我们开始学习MySQL 数据库前,让我们先了解下RDBMS的一些术语:
|
||||
|
||||
- 数据库: 数据库是一些关联表的集合。
|
||||
- 数据表: 表是数据的矩阵。在一个数据库中的表看起来像一个简单的电子表格。
|
||||
- 列: 一列(数据元素) 包含了相同类型的数据, 例如邮政编码的数据。
|
||||
- 行:一行(=元组,或记录)是一组相关的数据,例如一条用户订阅的数据。
|
||||
- 冗余:存储两倍数据,冗余降低了性能,但提高了数据的安全性。
|
||||
- 主键:主键是唯一的。一个数据表中只能包含一个主键。你可以使用主键来查询数据。
|
||||
- 外键:外键用于关联两个表。
|
||||
- 复合键:复合键(组合键)将多个列作为一个索引键,一般用于复合索引。
|
||||
- 索引:使用索引可快速访问数据库表中的特定信息。索引是对数据库表中一列或多列的值进行排序的一种结构。类似于书籍的目录。
|
||||
- 参照完整性: 参照的完整性要求关系中不允许引用不存在的实体。与实体完整性是关系模型必须满足的完整性约束条件,目的是保证数据的一致性。
|
||||
|
||||
MySQL 为关系型数据库(Relational Database Management System), 这种所谓的"关系型"可以理解为"表格"的概念, 一个关系型数据库由一个或数个表格组成
|
||||
|
||||

|
||||
|
||||
## MySQL数据库
|
||||
|
||||
MySQL 是一个关系型数据库管理系统,由瑞典 MySQL AB 公司开发,目前属于 Oracle 公司。MySQL 是一种关联数据库管理系统,关联数据库将数据保存在不同的表中,而不是将所有数据放在一个大仓库内,这样就增加了速度并提高了灵活性。
|
||||
|
||||
- MySQL 是开源的,目前隶属于 Oracle 旗下产品。
|
||||
- MySQL 支持大型的数据库。可以处理拥有上千万条记录的大型数据库。
|
||||
- MySQL 使用标准的 SQL 数据语言形式。
|
||||
- MySQL 可以运行于多个系统上,并且支持多种语言。这些编程语言包括 C、C++、Python、Java、Perl、PHP、Eiffel、Ruby 和 Tcl 等。
|
||||
- MySQL 支持大型数据库,支持 5000 万条记录的数据仓库,32 位系统表文件最大可支持 4GB,64 位系统支持最大的表文件为8TB。
|
||||
- MySQL 是可以定制的,采用了 GPL 协议,你可以修改源码来开发自己的 MySQL 系统。
|
||||
|
||||
> 下一章节将会开始安装mysql
|
||||
176
docs/mysql/create.md
Normal file
@@ -0,0 +1,176 @@
|
||||
# 数据库的链接与创建
|
||||
|
||||
先看下如何连接数据库,安装完成之后,用windows键 就是徽标键 + r键,打开运行,输入cmd然后回车
|
||||
|
||||

|
||||
|
||||
然后输入`mysql -uroot -p` ,然后回车
|
||||
|
||||

|
||||
|
||||
然后输入你安装时候输入的密码,然后回车
|
||||
|
||||

|
||||
|
||||
这样就连接到数据库了
|
||||
|
||||
## 查看所有数据库
|
||||
|
||||
之前说了,mysql中有数据库与数据表,数据库中包含着数据表。
|
||||
|
||||
那么如何查看现在存在的数据库呢?
|
||||
|
||||
```sql
|
||||
show databases;
|
||||
```
|
||||
|
||||
使用上面的命令可以查看当前存在的数据库。
|
||||
|
||||

|
||||
|
||||
> 注意,每条语句后面必须跟;结尾,而且保证是英文的分号
|
||||
|
||||
每个刚安装好的mysql都会有自带的这四个数据库,一般我们不会修改他们,之后用到的时候在进行解释,如果随便修改他们会造成一些意料之外的事情。
|
||||
|
||||
所以我们如何创建我们自己的数据库呢?
|
||||
|
||||
```sql
|
||||
create database demo;
|
||||
```
|
||||
|
||||
上面的命令是创建了一个名字为demo的数据库
|
||||
|
||||
那么名字是怎么定义的呢?
|
||||
|
||||
```sql
|
||||
create database 这里就是数据库的名字;
|
||||
```
|
||||
|
||||
比如我们要创建一个叫school的数据库,就应该使用
|
||||
|
||||
```sql
|
||||
create database school;
|
||||
```
|
||||
|
||||
那么我们运行`create database demo;`之后,再次查看数据库会怎么样?
|
||||
|
||||

|
||||
|
||||
发现数据库列表多了一个demo
|
||||
|
||||
我们执行下`create database school;`会怎么样呢?
|
||||
|
||||

|
||||
|
||||
school数据库也出现了。
|
||||
|
||||
所以这就是创建数据库的方法。
|
||||
|
||||
数据库创建好了,那么如何创建表呢?
|
||||
|
||||
之前说了,表是存在于数据库里面的,我们创建的时候应该指定要在哪个数据库中创建,就是新建文件一样,我们需要打开要新建文件的文件夹。
|
||||
|
||||
所以如何打开数据库呢?
|
||||
|
||||
```sql
|
||||
use 数据库名;
|
||||
```
|
||||
|
||||
使用use来选择要操作的数据库。
|
||||
|
||||
比如我们要在school数据库里面创建一个class的表,那么我们就应该先使用use来选择school这个数据库
|
||||
|
||||
```sql
|
||||
use school;
|
||||
```
|
||||
|
||||

|
||||
|
||||
使用use之后会出现`Database changed` 就是数据库已经选择了,可以进行之后的操作了。
|
||||
|
||||
那么先查看一下有没有数据表,因为是新建立的数据库,所以应该是空白的。
|
||||
|
||||
那么如何查看呢?
|
||||
|
||||
```sql
|
||||
show tables;
|
||||
```
|
||||
|
||||

|
||||
|
||||
并没有出现什么,因为最初创建的数据库是空白的,我们应该新建一个表。
|
||||
|
||||
如何创建一个表呢,是跟创建数据库一样直接`create table 表名;`吗?
|
||||
|
||||
并不是,介绍的时候有说到,数据表包含
|
||||
|
||||
- 表名
|
||||
- 表字段名
|
||||
- 字段类型
|
||||
- 约束等等
|
||||
|
||||
## 类型
|
||||
|
||||
那么我们先看一下类型。
|
||||
> MySQL支持多种类型,大致可以分为三类:数值、日期/时间和字符串(字符)类型。
|
||||
|
||||
数值是 int float double等
|
||||
字符串是 varchar char text等
|
||||
日期时间是 date datetime等
|
||||
|
||||
下面详细介绍一下,
|
||||
|
||||
int 是整数,可以存放一些整数的值 比如 123 2345 这种整数等 范围是(-2 147 483 648,2 147 483 647)
|
||||
float 是小数,是存放小数的,可以存放小数 比如 3.14 2.345 等等 可以有6 - 7 位的准确值
|
||||
double 是双精度小数型,也是存放小数 但是精准度比float好,可以保证 15 - 16 为准确性
|
||||
data 是存放日期的,格式为YYYY-MM-DD,例如 2020-02-02 2021-04-29 等等
|
||||
datatime 存放日期时间的 格式为YYYY-MM-DD HH:MM:SS 例如 2020-02-02 02:02:02 就是年-月-日 时:分:秒
|
||||
char 定长字符串,定义的时候需要传入长度,char(10) 定义一个长度为10的字符类型
|
||||
varchar 变长字符串,与char一样,但是有一些区别,在下面解释
|
||||
|
||||
### char 与 varchar
|
||||
|
||||
1. char类型时定长的类型,即当定义的是char(10),输入的是"abc"这三个字符时,它们占的空间一样是10个字节,包括7个空字节。当输入的字符长度超过指定的数时,char会截取超出的字符。而且,当存储char值时,MySQL是自动删除输入字符串末尾的空格。
|
||||
|
||||
2. char是适合存储很短的、一般固定长度的字符串。例如,char非常适合存储密码的MD5值,因为这是一个定长的值。对于非常短的列,char比varchar在存储空间上也更有效率。
|
||||
|
||||
3. varchar(n)类型用于存储可变长的,比如varchar(10), 然后输入abc三个字符,那么实际存储大小为3个字节。
|
||||
|
||||
4. 所以,从空间上考虑,varcahr较合适;从效率上考虑,用char合适。二者之间需要权衡。
|
||||
|
||||
## 创建数据表
|
||||
|
||||
那么如何简单的创建一个表呢?
|
||||
|
||||
```sql
|
||||
create table 表名(字段 类型,字段 类型,.....);
|
||||
```
|
||||
|
||||
例如,我们要创建一个下面样式的表
|
||||
|
||||

|
||||
|
||||
我们先考虑一下名字与类型,因为数据库中不能用中文作为字段名,所以我们需要给起一个英文名
|
||||
|
||||
- 姓名 name 类型是 varchar 长度给10 因为名字是字符串 并且没有人会有10个字的名字,可能会有5个6个.
|
||||
- 性别 sex 类型是varchar 长度给2 性别一般是男 女 未知,在一般项目中可能会用数字代替。
|
||||
- 年龄 age 类型 int
|
||||
|
||||
那么我们接下来创建这个表,表名就叫class
|
||||
|
||||
```sql
|
||||
create table class(name varchar(10),sex varchar(2),age int);
|
||||
```
|
||||
|
||||
执行一下
|
||||
|
||||

|
||||
|
||||
完成了,然后再查看一下当前数据库的表
|
||||
|
||||

|
||||
|
||||
已经可以看到我们创建的class了
|
||||
|
||||
下节就是数据的增删改查了。
|
||||
|
||||
96
docs/mysql/insert.md
Normal file
@@ -0,0 +1,96 @@
|
||||
# 数据操作
|
||||
|
||||
## 插入数据
|
||||
|
||||
上面已经创建了一个class表,表的格式为
|
||||
|
||||
| name | sex | age |
|
||||
| ---- | ---- | ---- |
|
||||
|
||||
所以应该如何添加数据呢?
|
||||
|
||||
```sql
|
||||
insert into 表名(字段名,字段名,....) value(值,值,...);
|
||||
```
|
||||
|
||||
添加数据就是使用上面的格式。
|
||||
|
||||
所以class表添加数据的方法就是
|
||||
|
||||
```sql
|
||||
insert into class(name,sex,age) value("张三","男",20);
|
||||
```
|
||||
|
||||

|
||||
|
||||
出现这样就是添加成功了
|
||||
|
||||
虽然到这里应该还有很多疑问,但是没办法一时解释清楚,请带着疑问走下去。
|
||||
|
||||
## 查询数据
|
||||
|
||||
已经插入数据了,那么如何查看呢?
|
||||
|
||||
```sql
|
||||
select * from 表名;
|
||||
```
|
||||
|
||||
这样就是查询数据的方法,让我们来试一下。
|
||||
|
||||
```sql
|
||||
select * from class;
|
||||
```
|
||||
|
||||

|
||||
|
||||
看到了我们的数据已经出现在里面了,那么插入的数据都已经成功了。
|
||||
|
||||
## 插入数据详解
|
||||
|
||||
下面详细来了解一下插入数据的语句
|
||||
|
||||
```sql
|
||||
insert into 表名(字段名,字段名,....) value(值,值,...);
|
||||
```
|
||||
|
||||
表名就可以不用说了,那么后面的字段名如何写呢?
|
||||
|
||||
### 必须是表中含有的字段
|
||||
|
||||
就像我们现在的class表,只有name sex 与 age 这三个字段,所以插入的时候是`(name,sex,age)`
|
||||
|
||||
如果写一个不存在的字段就会报错,比如下面,我们写一个classname
|
||||
|
||||
```sql
|
||||
insert info class(name,sex,age,classname) value("李三","男",20,"一班");
|
||||
```
|
||||
|
||||

|
||||
|
||||
现在就报错了
|
||||
|
||||
>ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'class(name,sex,age,classname) value("李三","男",20,"一班")' at line 1
|
||||
|
||||
翻译一下
|
||||
|
||||
> 错误1064(42000):您的SQL语法有错误;请查看与您的MySQL服务器版本对应的手册,以了解使用“class(name,sex,age,classname)value(”李三","男",20,"一班")' 在1号线
|
||||
|
||||
sql语法错误了,不能写表内没有的字段
|
||||
|
||||
### 可以省略一些字段
|
||||
|
||||
举个例子
|
||||
|
||||
```sql
|
||||
insert class(name) value("李四");
|
||||
```
|
||||
|
||||

|
||||
|
||||
可以成功
|
||||
|
||||
查询一下
|
||||
|
||||

|
||||
|
||||
只有名字 其他的都是null
|
||||
58
docs/mysql/install.md
Normal file
@@ -0,0 +1,58 @@
|
||||
# 安装
|
||||
|
||||
> 这是mysql8.0 安装,与5.7是一样的,如果要安装5.7就下载5.7的安装包就可以安装mysql并不需要多么复杂
|
||||
|
||||
1. 进入mysql官网
|
||||
- [mysql](https://www.mysql.com/)
|
||||
2. 点击下载
|
||||
- 
|
||||
3. 在下面选择社区版下载
|
||||
- 
|
||||
4. 选择for windows
|
||||
- 
|
||||
5. 然后选择离线安装包
|
||||
- 
|
||||
6. 下载完成之后,双击打开安装包
|
||||
- 
|
||||
- 
|
||||
- 这一部分可能需要稍等一会
|
||||
- 
|
||||
7. 选择最后一个,然后点击next,下面将会详细说明每个选项的作用
|
||||
- 
|
||||
8. 选择要安装的
|
||||
- 依次点击前面的+符号,依次展开
|
||||
- 
|
||||
- 
|
||||
- 
|
||||
- 
|
||||
- 然后点击下面的next
|
||||
- 
|
||||
- 点击下面的execute
|
||||
- 
|
||||
- 
|
||||
- 等待安装完成点击next
|
||||
- 
|
||||
- 再次点击next
|
||||
- 
|
||||
- 这一步也直接选择next
|
||||
- 
|
||||
- 也是直接next
|
||||
- 
|
||||
- 这一步需要输入密码,下面那个是重复输入密码
|
||||
- 
|
||||
- 输入完成之后下面的next就会亮起来,这个密码一定要记住,后面链接会用到,可以理解为登录密码
|
||||
- 
|
||||
- 这一步也直接next
|
||||
- 
|
||||
- 这一步点击execute
|
||||
- 
|
||||
- 等待完成
|
||||
- 
|
||||
- 完成之后点击finish
|
||||
- 
|
||||
- 点击next
|
||||
- 
|
||||
- 点击finish
|
||||
- 
|
||||
- 然后就安装成功了
|
||||
|
||||
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 37 KiB |
|
After Width: | Height: | Size: 51 KiB |
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 6.1 KiB |
|
After Width: | Height: | Size: 37 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 37 KiB |
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 3.9 KiB |
|
After Width: | Height: | Size: 54 KiB |
|
After Width: | Height: | Size: 37 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 35 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 8.7 KiB |
|
After Width: | Height: | Size: 5.5 KiB |
|
After Width: | Height: | Size: 29 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 54 KiB |
|
After Width: | Height: | Size: 36 KiB |
|
After Width: | Height: | Size: 37 KiB |
|
After Width: | Height: | Size: 4.9 KiB |
|
After Width: | Height: | Size: 6.2 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 4.8 KiB |
|
After Width: | Height: | Size: 33 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 33 KiB |
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 37 KiB |
|
After Width: | Height: | Size: 36 KiB |
|
After Width: | Height: | Size: 9.0 KiB |
|
After Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 24 KiB |
13
package.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "vuepress",
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"vuepress": "^1.8.2"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "vuepress dev docs",
|
||||
"build": "vuepress build docs"
|
||||
}
|
||||
}
|
||||