查看所有数据方法
select * from 表名称 where 条件
插入数据
有两种方式:
注意:字符类型, 日期数据都要加上单引号''
insert语句中指定所有字段名:
insert into 表名 (字段名1,字段名2,...)
VALUES(值1,值2,...);
- 例子:
insert into em (empno, ename, job, mgr, birthdate, sal, deptno) values(1001, '甘宁', '文员', '1013', '2000-12-17', 8000.00,'20');
insert into em (empno, ename, job, mgr, birthdate, sal, comm,deptno) values(1002, '黛绮丝', '销售员', '1006', '2001-02-20', 16000.00, 3000.00,'20');
insert语句按顺序写出字段值:
INSERT INTO 表名 VALUES(值1,值2,....);
- 例子:
insert into em values(1003, '殷天正', '销售员', '1006', '2001-02-22', 12500.00, 5000.00,'30');
insert into em values(1004, '刘备', '经理', '1007', '2001-04-02',29750.00, 0, 20);
insert into em values(1005, '谢逊', '销售员', '1006', '2001-09-28',12500.00, NULL, 30);
insert into em values(1006, '关羽', '经理', '1009', '2001-05-28',28500.00, NULL, 30);
insert into em values(1007, '张飞', '经理', '1007', '2001-09-01',24500.00, NULL, 10);
insert into em values(1009, '曾阿牛', '董事长', NULL, '2001-11-17',50000.00, NULL, 10);
insert into em values(1010, '韦一笑', '销售员', '1006', '2001-09-08',15000.00, 0.00,30);
insert into em values(1011, '周泰', '文员', '1008', '2007-05-23',11000.00, NULL, 20);
insert into em values(1012, '程普', '文员', '1006', '2001-12-03',9500.00, NULL, 30);
insert into em values(1013, '庞统', '分析师', '1004', '2001-12-03',30000.00, NULL, 10);
insert into em values(1014, '黄盖', '文员', '1007', '2002-01-23',13000.00, NULL, 10);
insert into em values(1015, '张三', '保洁员', '1001', '2013-05-01',80000.00, 50000.00, 50);
更新数据
update 表名称 set 字段名称=字段名 where 条件
- 例子:
update em set deptno='30' where empno=1002;
update em set deptno='20' where empno=1001;
删除数据
delete from 表名称 where 条件;
- 例子:
delete from em where empno = '1001';