ORACLE数据库的基本语法集锦

文章作者 100test 发表时间 2007:09:25 13:24:39
来源 100Test.Com百考试题网


-- 表
create table test (names varchar2(12),
dates date,
num int,
dou double).
-- 视图
create or replace view vi_test as
0select * from test.

-- 同义词
create or replace synonym aa
for dbusrcard001.aa.

-- 存储过程
create or replace produce dd(v_id in employee.empoy_id%type)
as
begin

end
dd.

-- 函数
create or replace function ee(v_id in employee%rowtype) return varchar(15)
is
var_test varchar2(15).
begin
return var_test.
exception when others then

end

-- 三种触发器的定义
create or replace trigger ff
alter 0delete
on test
for each row
declare
begin
0delete from test.
if sql%rowcount < 0 or sql%rowcount is null then
rais_replaction_err(-20004,"错误")
end if
end


create or replace trigger gg
alter insert
on test
for each row
declare
begin
if :old.names = :new.names then
raise_replaction_err(-2003,"编码重复").
end if
end


create or replace trigger hh
for 0update
on test
for each row
declare
begin
if updating then
if :old.names <> :new.names then
reaise_replaction_err(-2002,"关键字不能修改")
end if
end if
end

-- 定义游标
declare
cursor aa is
0select names,num from test.
begin
for bb in aa
loop
if bb.names = "ORACLE" then

end if
end loop.

end

-- 速度优化,前一语句不后一语句的速度快几十倍
0select names,dates
from test,b
where test.names = b.names( ) and
b.names is null and
b.dates > date(2003-01-01,yyyy-mm-dd)


0select names,dates
from test
where names not in ( 0select names
from b
where dates > to_date(2003-01-01,yyyy-mm-dd))

-- 查找重复记录
0select names,num
from test
where rowid != (0select max(rowid)
from test b
where b.names = test.names and
b.num = test.num)


-- 查找表TEST中时间最新的前10条记录
0select * from (0select * from test order by dates desc) where rownum < 11

-- 序列号的产生
create sequence row_id
minvalue 1
maxvalue 9999999999999999999999
start with 1
increment by 1

insert into test values(row_id.nextval,....)



相关文章


Cisco路由器或交换机上配置 MP
IGRP,EIGRP不等值路由负载
详解数据库Oracle11g的基本安装
oracle存储过程的基本语法
ORACLE数据库的基本语法集锦
内置ORACLE数据库接口的使用方法
Oracle9iLogMiner工具使用说明
Linux操作系统下的集群工作原理及实战经历[1]
Linux操作系统下常用压缩文件的解压方式[1]
澳大利亚华人论坛
考好网
日本华人论坛
华人移民留学论坛
英国华人论坛