[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
<> 向表中插入数据(增)
<>一次添加一条数据
语法格式:
INSETR [INTO] table_name [column_name1,column_name2, ....] VALUES
(values1,values2,....)
<>一次添加多条数据
语法格式:
INSETR [INTO] table_name [column_name1,column_name2, ....] VALUES
(values1,values2,....), (values1,values2,....), (values1,values2,....);
特点:
* 关键字INTO可以省略
* 语句中的所有列名也可以省略;但是,添加数据时,此时字段必须是全部按照顺序指定值
* 在有默认值约束的列添加数据时,可以不指定值来添加默认值
* 添加记录不指定所有字段值,不指定字段时,该字段必须是允许为空
* 自动增长列不建议指定值
* PRIMARY KEY约束和UNIQUE约束在添加值时,需要注意,数据严禁重复
* 值与字段名必须一一匹配,但是可以不按照表中的字段顺序指定
<> 修改表中的数据(改)
语法格式:
UPDATE table_name SET column_name = values,column_name = values,column_name =
values,..... [WHERE <表达式>]
说明:
WHERE :条件语句时可选的,代表修改表时的条件,如果不选择该语句,代表的则是修改表中的全部数据
<> 删除表中的数据(删)
<>DELETE语句
语法格式:
DELETE FROM table_name [WHERE search_condition]
注意:
*
如果将 WHERE 省略 ,将删除所有的信息
DELETE FROM table_name;
*
不要轻易使用DELETE 命令,因为大多数数据库中的提交方式是自动的;在没有标识为事务的情况下是不能回滚的。DELETE
命令是要记录到日志的操作,如果无意使用,只能从备份的数据库中进行恢复
*
DELETE 删除数据量比较大时,删除的速度会受到影响,DELETE 删除数据后,表所占用的空间并没有收回
<>TRUNCATE语句
语法格式:
TRUNCATE TABLE table_name;
注意:
* TRUNCATE可以删除表中的所有数据,只留下一个表的结构定义
* 使用TRUNCATE语句执行操作是不记录日志操作的,因此其速度要比DELETE语句快的多
* TRUNCATE语句将释放数据表的数据和索引所占据的所有空间,以及释放所有索引分配的空间
* 实际工作中,不建议使用TRUNCATE TABLE命令,因为使用它删除的数据不能恢复还原