当前位置:网站首页>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)
})
边栏推荐
- 使用 Chainlink Keepers 实现智能合约函数的自动化执行
- Bilateral filtering acceleration "recommended collection"
- 763.划分字母区间——之打开新世界
- OpenShift 4 - Deploy Redis Cluster with Operator
- 工程力学复习资料
- 公告
- R language ggplot2 visualization: use the ggboxplot function of the ggpubr package to visualize the box plot, use the font function to customize the font size, color, style (bold, italic) of the legen
- 基于最小二乘法和SVM从天气预报中预测太阳能发电量(Matlab代码实现)
- 贪吃蛇项目(简单)
- Selenium自动化中无头浏览器的应用
猜你喜欢
随机推荐
《微信小程序-进阶篇》Lin-ui组件库源码分析-Icon组件
WeChat chat record search in a red envelope
AVH部署实践 (一) | 在Arm虚拟硬件上部署飞桨模型
TRACE32——常用操作
Groupid(artifact id)
R语言ggplot2可视化:使用ggpubr包的ggboxplot函数可视化箱图、使用font函数自定义图例标题文本(legend.title)字体的大小、颜色、样式(粗体、斜体)
思路迪医药冲刺港股:5个月亏2.9亿 泰格医药与先声药业是股东
TextBlock控件入门基础工具使用用法,取上法入门
border控件的使用
乡村基冲刺港交所:5个月期内亏2224万 SIG与红杉中国是股东
mongo进入报错
Getting started with UnityShader (1) - GPU and Shader
How useful is four-quadrant time management?
11 pinia使用
vb中如何连接mysql_vb怎么连接数据库「建议收藏」
org.apache.jasperException(could not initialize class org)
Linux check redis version (check mongodb version)
深入浅出边缘云 | 4. 生命周期管理
TRACE32——基于SNOOPer的变量记录
华医网冲刺港股:5个月亏2976万 红杉与姚文彬是股东









