当前位置:网站首页>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)
})
边栏推荐
猜你喜欢
随机推荐
R language ggplot2 visualization: use the ggboxplot function of the ggpubr package to visualize the grouped box plot, use the ggpar function to change the graphical parameters (caption, add, modify th
TCP详解
Getting started with UnityShader (3) - Unity's Shader
Deployment应用生命周期与Pod健康检查
实现防抖与节流函数
更新数据表update
Why is the field of hacking almost filled with boys?
力扣:738.单调递增的数字
QGIS 加载WMS数据,重新投影
华医网冲刺港股:5个月亏2976万 红杉与姚文彬是股东
微信聊天记录中搜索红包
Efficient use of RecyclerView Section 3
工程水文学名词解释总结
Word table to Excel
Gorm—Go语言数据库框架
删除 状态良好(恢复分区)的磁盘
R语言ggstatsplot包ggbarstats函数可视化条形图、并添加假设检验结果(包含样本数、统计量、效应大小及其置信区间、显著性、组间两两比较、贝叶斯假设)、检验结果报告符合APA标准
Internet banking stolen?This article tells you how to use online banking safely
双边滤波加速「建议收藏」
数据库的范式(第一范式,第二范式,第三范式,BCNF范式)「建议收藏」




![[CUDA study notes] First acquaintance with CUDA](/img/a2/f322ebe9dc483028f68882ee2c866b.png)




