oracle-----熟悉基本使用
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]
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]
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]
update employee set last_name='Tate' where id=3;
commit;
select * from employee;
4. 将所有工资少于 5000 的员工的工资修改为 5000 (丌提交),并设置保存点,查询数据;
[sql]
update employee set salary=5000 where salary<5000;
savepoint a;
select * from employee;
5. 删除 employee 表中所有数据(丌提交),查询数据;
//delete from +表名==delete+表名
[sql]
delete employee where 2=2;
select * from employee;
6. 回滚到第四题中的设置的保存点,查询数据;
[sql]
rollback to a;
select * from employee;
7. 删除表 employee 中所有数据,并提交,查询数据;
[sql]
truncate table employee;