当前位置:网站首页>MySQL - 删除数据库表中的数据
MySQL - 删除数据库表中的数据
2022-07-24 10:25:00 【骆驼胡杨】
删除数据库表中的数据
- 删除数据记录是数据操作中常见的操作,可以删除表中已经存在的数据记录。在MySQL中可以通过DELETE语句来删除数据记录,该SQL语句可以通过以下几种方式使用:删除特定数据记录、删除所有数据记录。
1. 删除特定数据记录
在MySQL中删除特定数据记录可通过SQL语句DELETE来实现,其语法形式如下:
DELETE FROM tablename WHERE CONDITION;在上述语句中,参数tablename表示所要删除数据记录的表名,参数CONDITION指定删除满足条件的特定数据记录。
mysql> create table class(id int, name varchar(64)); mysql> insert into class values(1, '张三'); mysql> insert into class values(2, '李四'); mysql> delete from class where id=1; //删除表中id为1的记录 mysql> delete from class where name='李四'; //删除表中name为'李四'的记录 mysql> select * from class;
2. 删除所有数据记录
在MySQL中删除所有数据记录同样可通过SQL语句DELETE来实现,其语法形式如下:
DELETE FROM tablename WHERE CONDITION; 或 DELETE FROM tablename;在上述语句中,为了删除所有的数据记录,参数CONDITION需要满足表tablename中所有数据记录,如id>0; 或者无关键字WHERE语句。
mysql> create table class(id int, name varchar(64)); mysql> insert into class values(1, '张三'); mysql> insert into class values(2, '李四'); mysql> delete from class; //删除表中所有记录 mysql> select * from class;
边栏推荐
- Image processing: rgb565 to rgb888
- [STM32 learning] (12) STM32 realizes LCD1602 simple static reality
- Image processing: floating point number to fixed point number
- Simply use golang SQLC to generate MySQL query code
- ES6 question
- zoj-Swordfish-2022-5-6
- 第五章 修改实现(IMPL)类
- Basic SQL operations
- pom文件dependency中的 scope用法
- Sentinel 流量控制快速入门
猜你喜欢

Zoj1137+ operation 1 -- May 28, 2022
![[STM32 learning] (17) STM32 realizes LCD12864 display serial implementation](/img/93/224eaf0bbfff1d38f29e063e6ebfb8.png)
[STM32 learning] (17) STM32 realizes LCD12864 display serial implementation
![[electronic device note 4] inductance parameters and type selection](/img/b1/6c5cb27903bc1093bf49e278e31353.png)
[electronic device note 4] inductance parameters and type selection

CMS vulnerability recurrence - foreground arbitrary user password modification vulnerability

Curse of knowledge

String__
![[electronic device note 3] capacitance parameters and type selection](/img/d2/1ddb309a8f3cfe5f65c71964052006.png)
[electronic device note 3] capacitance parameters and type selection

Sentinel 流量控制快速入门

OSPF含特殊区域实验,MGRE构建和重发布
![[STM32 learning] (15) STM32 realizes DHT11 temperature and humidity acquisition and display](/img/f2/6fcd4b2e747b4ceb52a52eda0c1af4.png)
[STM32 learning] (15) STM32 realizes DHT11 temperature and humidity acquisition and display
随机推荐
unity中物体z旋转同步面板上的数值
[STM32 learning] (10) stm32f1 general timer realizes pulse counter
The best time to buy and sell stocks includes handling charges (leetcode-714)
What did zoneawareloadbalancer of ribbon and its parent class do?
What does resource pooling and resource pooling mean?
CMS vulnerability recurrence - ultra vires vulnerability
Interpretation of websocket protocol -rfc6455
Sentinel 实现 pull 模式规则持久化
Google Earth engine - QA in Landsat 5 toa dataset_ Pixel and QA_ Radsat band
多表查询之子查询_单行单列情况
[STM32 learning] (16) STM32 realizes LCD1602 display (74HC595 drive) - 4-bit bus
【LeeCode】获取2个字符串的最长公共子串
Implementation and traversal of binary tree and binary tree sorting tree
Segment tree--
fatal: unable to commit credential store: Device or resource busy
MySQL - 索引的隐藏和删除
DSP CCS software simulation
Activity exception lifecycle
[carving master learning programming] Arduino hands-on (59) - RS232 to TTL serial port module
Review of new services and functions of Amazon cloud technology in June 2022