高级复习Oracle

发布 2020-01-01 22:23:28 阅读 2429

数据库**操作练习(高级)

oracle 9i:

考试时采用**操作方式,后台连接实际的数据库,前台是用网页**的sql/plus,因此所创建的数据库对象将保存在数据库中。

如果创建已经存在的对象,则会报错,应该先删除该对象再重新创建。

要求不使用commit、if、replace等语句。

书写完语句后执行。

一般语句以分号结束以便执行,但trigger、procedure的相关语句必须以/结束。

在sql/plus中使用sql语句完成以下工作:

1、创建表test, 字段为id varchar(20), name varchar(30), birthday date。 create table test(id varchar(20), name varchar(30), birthday date);

2、在表test上创建字段id的索引test_idx. create index test_idx on test(id);

3、向表test内插入两条数据:insert into test values('a01','abc',to_date('1983-02-15','yyyy-mm-dd'))insert into test values('a02','ccc',to_date('1983-05-09','yyyy-mm-dd'))注意to_date()的用法。

4、修改表test中id为a01的纪录,将其name值改为'bcc'。 update test set name = bcc' where id = a01';

5、查询test中的所有纪录,按照id的降序排列。 select * from test order by id desc;

6、查询test中id为a01的纪录。 select * from test where id = a01';

7、删除表test中id为a01的纪录。 delete from test where id = a01'; 注意不要用delete * from test...

8、删除表test。 drop table test;

9、创建视图(单表)。 create view v_test as select id,name from test; 删除视图:drop view v_test;

10、创建视图(多表)。 create view v_test as select id,name,city from test,state where = and to_date(birthday,'yyyy-mm-dd')>1985-01-01';

11、创建存储过程。 create procedure p_test as bengin select * from test end;/ 注意一定要使用“/”符号结束。

12、创建存触发器。 create trigger t_test as select * from test;/ 注意一定要使用“/”符号结束。

13、查询表test的所有纪录,输出id,name,birthday,以及name的前两个字符(显示名为v_name)。 select id,name,birthday,substr(name,1,2) as v_name from test;

14、查询test中的所有纪录,id和name两个字段连起来以iname名称显示出来。 select id||name as iname from test;

15、根据test表的id,name两个字段建立一个新表test1,要求包括test中的数据。 create table test1 as select id,name from test;

16、创建索引: 在表test的id字段上建立索引idx_testid。 create index idx_testid on test(id); 删除索引:

drop index idx_testid;

oracle高级

loop循环结构。looppl sql exit when 判断条件 当判断条件为真时退出 end loop 例子 用loop输出一年中的每一天 create table rili day date declare time date begintime to date 2014 01 01 yyy...

ORACLE高级查询

本章目标 多表查询。联接查询 inner join 内联接 left outer join 左外联接 right outer join 右外联接 full join 全联接 子查询。集合操作。union 联合 union all 联合所有 intersect 交集 minus 减集 一 连接类型。o...

Oracle高级培训纲要

实力成就稳定。技术创造价值4 21 2008 1 oracle 高级培训方案建议书。1.0版 技术顾问 盖国强。实力成就稳定 摘要 本方案为根据用户需求制订的培训方案书,具体内容与用户商定后作为最终培训纲要。用户的学员情况及培训需求 人数大概在30人左右,其中有少半的人具有oracle方面的基础。培...