DML(資料操作語言,它是對表記錄的操作(增、删、改)!)
插入資料
INSERT INTO 表名(列名1,列名2, ...) VALUES(列值1, 列值2, ...)
1
修改資料
UPDATE 表名 SET 列名1=列值1, 列名2=列值2, ... [WHERE 條件]
- 運算符:
算術運算符:+,-,*,/,%
指派運算符: =
關系運算符:=,!=(不等于),<>(不等于),>=,<=,<,> ....
邏輯運算符:and,or ,not(用于連結多個條件)
update colin set age = 40 where number = '1001';
update colin set age = 34 where number ! = '1001';
update colin set age = 13 where number <> '1003';
update colin set age = 3 where number > '1003';
update colin set age = 12 where number <'1003';
update colin set age =11 where number >='1003';
update colin set age = 44 where number <='1003';
update colin set age =age+2 where age<=45 and age > 15 範圍
BETWEEN...AND
update colin set age =110 where age between 20 and 50;
範圍【前後範圍都包括在
OR
update colin set age = 120 where number = '1002' or number ='102';隻要滿足其中一個條件就可以了
update colin set age = 120 where number in('1002','1003');
隻要包含在小括号内的條件滿足就可以執行
删除資料
DELETE FROM 表名 [WHERE 條件];
delete from colin where name='Chen';
删除 來自一張表 按照什麼條件來删除
delete from 表名;
隻是把全部的資料删除了
drop table 表名
将整個表都删掉了