drop,delete

drop 是对表进行操作

  1. drop table product_name;

delete 是对表中的数据行进行操作,delete无法使用 :::danger delete * from product_insert ::: 由于是对表中的数据行进行操作,所以要指定条件,基本语法为

/* delete from <表名>
where <条件>; */

delete from product_insert_copy
where sale_price = 0;

在条件选择上面,只能使用where,无法使用having

update

基本语法

/* update <表名>
   set <设置列> = <值>
   where <条件>
*/


update product_insert
set sale_price = sale_price * 10
where sale_price = 100

/*
  将sale_price为100的行数据sale_price数据更新至之前的10
*/

同表中多个update语句合并

/* 需求:将product_type = 衣服的数据,
 他们的名字改成衣服2,价格除以100 */

UPDATE product_insert_copy
set sale_price = sale_price / 100 , 
        product_type = '衣服2'
where product_type = '衣服';