oracle新手笔记
oracle数据库的新手笔记,高手绕过!
1. 创建表 employee,字段为:
Id number(4),
First_Name varchar2(20),
last_Name varchar2(20),
mgrid NUMBER(4),
Job varchar2(20),
Salary number(7,2)
[sql] view plaincopy
- create table employee(
- Id number(4),
- First_Name varchar2(20),
- last_Name varchar2(20),
- mgrid NUMBER(4),
- Job varchar2(20),
- Salary number(7,2));
2.向表中插入下列数据,并提交,查询数据;
ID FIRST_NAME LAST_NAME MGRID SALARY
1 Rose Tyler 4 1500
2 Matha Jones 4 2200
3 Donna Noble 4 1300
4 Doctor Who 3500
5 Jack Harkness 1 3000
[sql] view plaincopy
- insert into employee values(1,’Rose’,’Tyler ‘,4,null,1500);
- insert into employee values(2,’Matha’,’Jones’,4,null,2200);
- insert into employee values(3,’Donna’,’Noble’,4,null,1300);
- insert into employee values(4,’Doctor’,’Who’,null,null,3500);
- insert into employee values(5,’Jack’,’Harkness’,1,null,3000);
3. 将 3 号员工的 last_name 修改为“Tate”,并提交,查询数据;
[sql] view plaincopy
- update employee set last_name=’Tate’ where id=3;
- commit;
- select * from employee;
4. 将所有工资少于 5000 的员工的工资修改为 5000 (丌提交),并设置保存点,查询数据;
[sql] view plaincopy
- update employee set salary=5000 where salary<5000;
- savepoint a;
- select * from employee;
5. 删除 employee 表中所有数据(丌提交),查询数据;
//delete from +表名==delete+表名
[sql] view plaincopy
- delete employee where 2=2;
- select * from employee;
6. 回滚到第四题中的设置的保存点,查询数据;
[sql] view plaincopy
- rollback to a;
- select * from employee;
7. 删除表 employee 中所有数据,并提交,查询数据;
[sql] view plaincopy
- truncate table employee;
发表评论
评论已关闭。
评论列表(1)
weight loss
2013.7.23 08:07
谢谢分享,文章说的很透彻。