当前位置:网站首页>1-3 使用SQL管理数据库
1-3 使用SQL管理数据库
2022-06-30 21:26:00 【画不完的饼】
什么是SQL?
SQL(英文全称:Structured Query Language)是结构化查询语言,专门用来访问和处理数据库的编程语言。能够让我们以编程的形式,操作 数据库里面的数据。
三个关键点:
- SQL是一门数据库编程语言
- 使用SQL语言编写出来的代码,叫做SQL语句
- SQL语言只能在关系型数据库中使用(例如MySQL、Oracle、SQL Server)。非关系型数据库(例如Mongodb)不支持SQL语言。
SQL能做什么?
- 从数据库中查询数据
- 项数据中插入新的数据
- 更新数据库中的数据
- 从数据库删除数据
- 可以创建新数据库
- 可在数据库中创建新表
- 可在数据库中创建存储过程、视图
SQL的学习目标?
查询数据(select)、插入数据(insert into)、更新数据(update)、删除数据(delete)
额外需要掌握的4种SQL语法:
where条件、and和or运算符、order by排序、count(*)函数
SQL的SELECT语句
SELECT语句勇于从表中查询数据。执行的结果被存储在一个结果中(称为结果集)。语法格式如下:
//查询全部列
SELECT * FROM 表名称
//查询指定列
SELECT 列名称 FROM 表名称
-- 通过*把users表所有的数据查询出来
-- select * from users
-- 从users表中username和password对应的数据查询出来
select username, password from users
INSERT INTO语句用于向数据表中插入新的数据行
-- 向users表中,插入新数据,username的值为 tony stark password 的值为 098123
-- insert into users (username,password) values ('tony stark','098123')
SQL的UPDATE语句
-- 把users表中id为4的用户密码,更新为888888
-- update users set password='888888' where id=4
-- select * from users
-- update users set password='admin123',status=1 where id=2
-- select *from users
SQL的DELETE语句
注意:删除表数据的时候一定要加一个 where 条件,不然整张表的数据都会被删除掉
-- 删除users表中id=4的数据
-- delete from users where id=4
select *from users
边栏推荐
- ssh 默认端口不是22时的一些问题
- asp. Net core JWT delivery
- 两个skyline
- Internet of things botnet gafgyt family and backdoor vulnerability exploitation of Internet of things devices
- Introduction of 3D Max fine model obj model into ArcGIS pro (II) key points supplement
- Three techniques for reducing debugging time of embedded software
- 防范未授权访问攻击的十项安全措施
- 电子方案开发——智能跳绳方案
- 开发技术-使用easyexcel导入文件(简单示例)
- Phoenix architecture: an architect's perspective
猜你喜欢
笔记【JUC包以及Future介绍】

ArcGIS构建发布简单路网Network数据服务及Rest调用测试

本地浏览器打开远程服务器上的Jupyter Notebook/Lab以及常见问题&设置

Qiao NPMS: search for NPM packages
Understand what MySQL index push down (ICP) is in one article

Iclr'22 spotlight | how to measure the amount of information in neural network weights?

Four Misunderstandings of Internet Marketing

Multi table operation - foreign key constraint

Five years after graduation, I wondered if I would still be so anxious if I hadn't taken the test

Radar data processing technology
随机推荐
双立体柱状图/双y轴
文本生成模型退化怎麼辦?SimCTG 告訴你答案
Is it safe to open an account for stock trading on mobile phones?
介绍一款|用于多组学整合和网络可视化分析的在线平台
ceshi deces
3Ds Max 精模obj模型导入ArcGIS Pro (二)要点补充
What does grade evaluation mean? What is included in the workflow?
“信任机器”为发展赋能
What about degradation of text generation model? Simctg tells you the answer
asp.net core JWT传递
ssh 默认端口不是22时的一些问题
Why have the intelligent investment advisory products collectively taken off the shelves of banks become "chicken ribs"?
【无标题】
Ssh server configuration file parameter permitrootlogin introduction
Personal developed penetration testing tool Satania
Learning summary
Adobe Photoshop (PS) - script development - remove file bloated script
申请Vector 总线协议彩图壁纸挂画,非常棒哦!
网络营销之四大误解
Two skylines