当前位置:网站首页>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
边栏推荐
- 本地浏览器打开远程服务器上的Jupyter Notebook/Lab以及常见问题&设置
- [untitled]
- asp.net core JWT传递
- ICLR'22 Spotlight | 怎样度量神经网络权重中的信息量?
- 介绍一款|用于多组学整合和网络可视化分析的在线平台
- Ten security measures against unauthorized access attacks
- 双立体柱状图/双y轴
- 企业保护 API 安全迫在眉睫
- Clickhouse native monitoring item, system table description
- Can flinksql two Kafka streams join?
猜你喜欢
Understand what MySQL index push down (ICP) is in one article
测试媒资缓存问题

Go build server Foundation

go搭建服务器基础

pytorch geometric torch-scatter和torch-sparse安装报错问题解决
笔记【JUC包以及Future介绍】

科研中遇到迷茫困惑如何向前一步?如何在科研中发挥女性优势?

What about degradation of text generation model? Simctg tells you the answer

Four Misunderstandings of Internet Marketing

Spatiotemporal data mining: an overview
随机推荐
Markdown notes concise tutorial
ceshi deces
. NETCORE redis geo type
【无标题】第一次参加csdn活动
【等级测评师】等级测评师怎么报名?多少分及格?
sqlserver 字符串类型转换成小数或者整数类型
A small step in code change and a big leap in thinking
物联网僵尸网络Gafgyt家族与物联网设备后门漏洞利用
Introduction of 3D Max fine model obj model into ArcGIS pro (II) key points supplement
Encryption and decryption and the application of OpenSSL
Apply for vector bus protocol color picture wallpaper hanging picture, very good!
文本识别-SVTR论文解读
做一个 Scrollbar 的思考
Clickhouse native monitoring item, system table description
个人开发的渗透测试工具Satania
Testing media cache
clickhouse原生监控项,系统表描述
Use the log server to output the topn of various Apache logs
MySQL batch update
等级测评是什么意思?工作流程包含哪些?