? ? ? DML(Data Manipulation Language)数据操作语言,常用语句:
注意:这里方式四在下一章会进行展示,此处不进行展示
CREATE TABLE IF NOT EXISTS teampeople (
ID INT PRIMARY KEY AUTO_INCREMENT COMMENT '编号',
people VARCHAR(30) NOT NULL UNIQUE COMMENT '名字',
birthday DATE NOT NULL COMMENT '生日',
height INT NOT NULL CHECK (height > 0) COMMENT '身高',
weight INT NOT NULL CHECK (weight > 0) COMMENT '体重',
location VARCHAR(6) COMMENT '位置'
);
-- 插入记录
INSERT INTO teampeople (people, birthday, height, weight, location) VALUES ('德怀恩·韦德', '1982-1-17', 193, 96, NULL);
INSERT INTO teampeople (people, birthday, height, weight, location) VALUES ('勒布朗·詹姆斯', '1984-12-30', 203, 113, '前锋'),('科比·布莱恩特', '1978-8-23', 198, 99, '后卫');
INSERT INTO teampeople SET people='德克·诺维斯基', birthday='1978-6-19', height=213, weight=111, location=NULL;
结果:
update 表名 set 列名=‘新值’ where 条件
UPDATE teampeople SET people='牢大' WHERE ID=19;
结果:
DELETE FROM teampeople WHERE people='牢大';
结果:
TRUNCATE TABLE teampeople;
结果:
注意:若删除部分数据时不加入条件,则会删除所有数据?