当前位置:网站首页>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语言ggstatsplot包ggbarstats函数可视化条形图、并添加假设检验结果(包含样本数、统计量、效应大小及其置信区间、显著性、组间两两比较、贝叶斯假设)、检验结果报告符合APA标准
- RecyclerView高效使用第二节
- ASP.NET Core 产生连续 Guid
- Deployment application life cycle and Pod health check
- OpenCV测量物体的尺寸技能 get~
- Ubuntu Topic 5: Setting a Static IP Address
- R language test whether the sample conforms to normality (test whether the sample comes from a normally distributed population): shapiro.test function tests whether the sample conforms to the normal d
- Excel quickly aligns the middle name of the table (two-word name and three-word name alignment)
- Efficient use of RecyclerView Section 3
- Matlab矩阵基本操作(定义,运算)
猜你喜欢
模板与泛型编程值typelist实现
Synchronized and volatile interview brief summary
leetcode303 Weekly Match Replay
WPF project - basic usage of controls entry, you must know XAML
自适应控制——仿真实验三 用超稳定性理论设计模型参考自适应系统
The meaning of node_exporter performance monitoring information collection in Prometheus
Jmeter常用的十大组件
Ubuntu Topic 5: Setting a Static IP Address
Kubernetes常用命令
名创优品斥资6.95亿购买创始人叶国富所持办公楼股权
随机推荐
Why don't you make a confession during the graduation season?
Deployment application life cycle and Pod health check
Groupid(artifact id)
How useful is four-quadrant time management?
R语言ggstatsplot包ggbarstats函数可视化条形图、并添加假设检验结果(包含样本数、统计量、效应大小及其置信区间、显著性、组间两两比较、贝叶斯假设)、检验结果报告符合APA标准
Excel quickly aligns the middle name of the table (two-word name and three-word name alignment)
hough变换检测直线原理(opencv霍夫直线检测)
三、数组
力扣:56. 合并区间
力扣:714. 买卖股票的最佳时机含手续费
Why is the field of hacking almost filled with boys?
R语言ggplot2可视化:使用ggpubr包的ggboxplot函数可视化分组箱图、使用ggpar函数改变图形化参数(caption、添加、修改可视化图像的题注、脚注内容)
Synchronized和volatile 面试简单汇总
WPF project - basic usage of controls entry, you must know XAML
乡村基冲刺港交所:5个月期内亏2224万 SIG与红杉中国是股东
01 邂逅typescript,环境搭建
自动化测试如何创造业务价值?
工程水文学名词解释总结
Matlab矩阵基本操作(定义,运算)
R语言ggplot2可视化:使用ggpubr包的ggmaplot函数可视化MA图(MA-plot)、font.legend参数和font.main参数设置标题和图例字体加粗