插入
插入数据有四种方法,代码如下
-- 给表中添加元素
-- insert into 表名 (列名) values(数据)
INSERT INTO student(NAME,gender,birthday,phone)VALUES('张三','男','2003-2-10','13333333333')
INSERT INTO student(NAME,gender,birthday,phone,address,height,rig_time)
VALUES('张三','男','2003-2-10','13333333334','西安',1.80,NOW())
INSERT INTO student(NAME,gender,birthday,phone,address,height,rig_time)
VALUES('李四','男','2004-1-6','12222222222','西安',1.80,NOW()),
('王五','女','2003-1-12','13434343433','深圳',1.67,NOW()),
('赵六','女','2004-3-12','12233455667','上海',1.57,NOW())
INSERT INTO student SET NAME='李宏杰',gender='女',phone='15498512645'
INSERT INTO stu(NAME,gender,birthday,phone,address,height,rig_time)
SELECT NAME,gender,birthday,phone,address,height,rig_time FROM student
修改
-- 修改语句 需要注意条件的准确性,否则默认修改所有的数据
UPDATE student SET address='北京',gender='女',phone='19845625487' WHERE num=1
删除
-- 删除语句
DELETE FROM stu -- 没有条件 删除所有数据
DELETE FROM student WHERE num = 11