插入记录: INSERT INTO 表名称(字段名1,字段名2…
VALUES(字段1的值,字段2的值
如:mysql>insert into student (sno,sname,ssex,sbirthday,sdepa)
values(‘0321001’,’Liu Tao’,dagault,19870201,’math’);
查看表 mysql>select * from student;
插入与前面相同的记录,可用insert命令的缩写格式,
如: mysql>insert into student values (‘0321001’, ‘Liu Tao’, default, 19870201, ‘mth’);
如果字段名列表中没有给出表中的某些字段,那么这些字段设置为默认值,
如:mysql>insert into student (sno,sname,sbirthday)
values(‘0321002’,’Wang Jun’,1870112);
一个单独的insert语句中可使用多个valuse字句,插入多条记录,
如:mysql>insert into student values
(‘0322001’, ‘Zhang Liaoyun’, ‘f’ 1971102,’computer’),
(‘0322002’, ‘Li Ming’, ‘t’ 1971105,’computer’);
删除记录: DELETE FROM 表名称 WHERE 条件表达式;
如:mysql>delete from student where sno=’0321002’;
删除student表中sno字段值前4位为‘0322’的记录
如:mysql>delete from student where left (sno,4)=’0322’;
删除所以记录,可以不带where字句
如:mysql>delete from student;
删除所以记录可以用命令truncate 删除表,然后重建表,所以比delete命令快
如:mysql>truncate table student;
修改记录 UPDATE 表名称 SET 字段名1=字段值1
WHERE 条件表达式
如: mysql>update student set sbirthday=1920113, sdepa=’math’ where sno=’0321002’;