当前位置:网站首页>MySQL database operations
MySQL database operations
2022-07-31 15:20:00 【do not disturb】
什么是数据库
数据库(database)是用来组织,存储和管理数据的仓库.
当今世界是一个充满着数据的互联网世界,充斥着大量的数据,数据来源很多,比如出行记录,消费记录,浏览的网页,messages sent, etc,除了文本类型的数据,图像,music is data.
常见的数据库分类
There are many common databases on the market,The most common databases have
- 传统数据库/关系型数据库
- MySQL数据库(目前使用最广泛,The most popular open source free database:Communit+EnterPrise)
- Oracle 数据库 收费
- SQL Server 数据库 收费
- 新型数据库/非关系型数据库
- Mongodb 数据库 Community + EnterPrise
Communit:社区免费版 + Enterprise 企业收费版
- 传统型数据库的数据组织结构
- Excel data structure organization
每个Excel中,数据的组织结构分别为工作簿,工作表,数据行,List these four parts.
- 传统型数据库的数据组织结构
在传统型数据库中,数据的组织结构分为数据库,数据表,数据行,Four parts of the field
- Libraries in actual development,表,行,字段的关系
一般情况下,每个项目都对应独立的数据库
不同的数据,to be stored in a different table,例如:用户数据存储到user列中,图书数据存储到books表中
What data is stored in each table,There are fields to decide.例如:我们可以为user表设计id,username,password这三个字段
表中的行,代表每一条具体的数据
安装并配置MySQL
- Which need to be installedMySQL相关的软件
- 对于开发人员来说,只需要安装MySQL,Server和MySQL Workbench这两个软件,can meet the development needs
- SQL Server:Software specifically designed to provide database storage and services
- MySQL Workbench:可视化MySQL管理工具,通过它,Can be conveniently stored in the operationSQL Server中的数据
使用MySQL Workbench管理数据库
- DataType数据类型
- init 整数
- varchar(len)字符串
- tinyinit(1)布尔
- 字段的特殊标识:
- PK(primary Key) 主键 唯一标识
- NN(Not Null) 值不能为空
- UQ(Unique)值唯一
- AI(Auto increment)值自动增长
- 向表中写入数据
- Click on the table mail where you want to insert data,选择Select Row - Limit 1000
MySQL 的基本使用
- 什么是SQL
- SQL是结构化查询语言,A programming language specifically designed to access and process databases,能够让我们以编程的形式,操作数据库里面的数据
- 三个关键点
- SQL是一门数据库编程语言
- 使用SQLcode written in the language,叫做SQL语句
- SQLStatements can only be used in relational databases,非关系型数据库不支持SQL语言
- SQL能做什么
- 对数据库进行增删改查
- 可以创建新数据库
- 可在数据库中创建新表
- 可在数据库中创建存储过程,视图
在项目中操作MySQL
- Perform the current operation againMySQL
- 安装mysql,数据库的第三方模块
- 通过mysqlThe module connects to the database
- 通过mysql模块执行sql语句
- 安装mysql数据的第三方模块
- mysql模块是托管与npm的第三方模块,它提供了nodejs项目中连接和操作MySQL数据库的能力,想要在项目中使用,需要下载依赖
npm install mysql
- 在使用mysql模块操作MySQL数据库之前,必须对mysql进行必要的配置
const mysql = require('mysql');
const db = mysql.createPool({
host:'127.0.0.1',
user:'root',
password:'fb980728',
database:'my_fb_01'
})
// 列1
const sqlStr = 'select * from users';
// query()用于执行SQL语句 Successfully passed the callback functionres返回
db.query(sqlStr,(err,res)=>{
if(err) return console.log(err.message);
console.log(res)
})
// 列2
const user = {
username:'spider-man',password:'pcc123' };
// Add data to the data table,其中username 为splid-man password为pcc123 可以通过? 占位
const sqlStr ='insert into user (username,password) value (?,?)'
db.query(sqlStr,(err,res)=>{
if(err) return console.log(err.message)
console.log(res)
})
边栏推荐
- 更新数据表update
- button控件的使用
- 四象限时间管理有多好用?
- 学习笔记12--路径-速度分解法之局部路径搜索
- 「秋招系列」MySQL面试核心25问(附答案)
- 11 pinia使用
- R语言ggplot2可视化:使用ggpubr包的ggboxplot函数可视化分组箱图、使用ggpar函数改变图形化参数(caption、添加、修改可视化图像的题注、脚注内容)
- WeChat chat record search in a red envelope
- 删除表格数据或清空表格
- Internet banking stolen?This article tells you how to use online banking safely
猜你喜欢
随机推荐
【MySQL】Mysql范式及外键作用
PDF 拆分/合并
力扣:738.单调递增的数字
thread_local 变量的析构顺序
自适应控制——仿真实验二 用Narendra方案设计模型参考自适应系统
435. 无重叠区间
为什么黑客领域几乎一片男生?
11 pinia use
Small test knife: Go reflection helped me convert Excel to Struct
Word table to Excel
贪吃蛇项目(简单)
Web自动化实战——Selenium4(自动化测试环境的搭建)
看交互设计如何集成到Scrum敏捷流程中
数据表插入数据insert into
R language ggplot2 visualization: use the ggmapplot function of the ggpubr package to visualize the MA plot (MA-plot), the font.legend parameter and the font.main parameter to set the title and legend
R语言ggplot2可视化:使用ggpubr包的ggboxplot函数可视化分组箱图、使用ggpar函数改变图形化参数(caption、添加、修改可视化图像的题注、脚注内容)
实现防抖与节流函数
763.划分字母区间——之打开新世界
01 邂逅typescript,环境搭建
Advanced Mathematics - Commonly Used Indefinite Integral Formulas









