加入收藏 | 设为首页 | 会员中心 | 我要投稿 湖南网 (https://www.hunanwang.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长百科 > 正文

oracle基础知识语法大全

发布时间:2021-01-14 11:40:42 所属栏目:站长百科 来源:网络整理
导读:ORACLE支持五种范例的完备性束缚 NOT NULL (非空)--防备NULL值进入指定的列,在单列基本上界说,默认环境下,ORACLE应承在任何列中有NULL值. CHECK (搜查)--搜查在束缚中指定的前提是否获得了满意. UNIQUE (独一)--担保在指定的列中没有一再值.在该表中每一个值

--体系非常
declare
rowD user_tbl%rowtype;
begin
select * into rowD from user_tbl;
dbms_output.put_line(rowD.id||‘‘||rowD.user_name||‘ ‘||rowD.password);
exception
when too_many_rows then
dbms_output.put_line(‘不能将多行赋予一个属性!‘);
end;
or
declare
rowD user_tbl%rowtype;
begin
select * into rowD from user_tbl where id=5;
dbms_output.put_line(rowD.id||‘ ‘||rowD.user_name||‘ ‘||rowD.password);
exception
when too_many_rows then
dbms_output.put_line(‘不能将多行赋予一个属性!‘);
when no_data_found then
dbms_output.put_line(‘没有您要查找的数据!‘);
end;

--自界说错误
declare
invalidError exception;
category varchar2(20);
begin
category:=‘&category‘;
if category not in(‘附件‘,‘顶盘‘,‘备件‘) then
raise invalidError;
else
dbms_output.put_line(‘您输入的种别是:‘||category);
end if;
exception
when invalidError then
dbms_output.put_line(‘无法识此外种别!‘);
end;

--激发应用措施非常
declare
app_exception exception;
grade user_tbl.grade%type;
begin
select grade into grade from user_tbl where id=&id;
if grade=‘A‘ then
raise app_exception;
else
dbms_output.put_line(‘查询的品级为:‘||grade);
end if;
exception
when app_exception then
raise_application_error(-20001,‘未知的品级!‘);
end;

(编辑:湖南网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

热点阅读