oracle 添加 删除列 修改表名字 ;加注释 异常解释

desc xujin;
alter table xujin add 字段名 字段类型;
alter table xujin modify cloumn 列名字 列类型;修改列名 ,列类型
alter table xujin drop cloumn 列名字 删除;
rename oldtablename to newtablename;

comment on column xujin.name
is 'name 的描述性语言';


sql隐式游标
%found %notfound %isopen %rowcount

sql
%found
insert update delte select into 有影响的记录 那么sql
%founnd 则为ture;

sql
%notfound
insert update delete select into 没有有影响的记录 那么sql
%founnd 则为ture;

%rowcount
insert update (select into 没有返回行是0) delete 所影响的记录


oracle 异常处理
begin
exception
when others then

when no_data_found then

when to_many_rows_then

end;


oracle 自定义异常

declare

exception_name exception;

begin
statmens;
raise exception_name ;
exception
when exception_name then

end;

----无聊写一些小例子

也巩固下自己知识点

----------------异常 自己定义的一场小例子
/*declare
exception_name exception;
begin
raise exception_name;
exception
when exception_name then
dbms_output.put_line('aaaaaaaaa');
end;
*/

-- 输出多行

/**declare
v_name varchar2(200);
begin
select name into v_name from xujin ;
exception
when too_many_rows then
dbms_output.put_line('aaaaaaaaaaaaaa');
end;
*/

--没有数据输出
/**
declare
v_name varchar2(200);
begin
select name into v_name from xujin where name='xujin';
exception
when no_data_found then
dbms_output.put_line('aaaaaaaaaaaaaa');
end;*
*/

---利用异常 输出
declare
v_name varchar2(
200);
begin
update xujin
set name='a' where rownum=1;
if sql%rowcount>=1 then
dbms_output.put_line(
'bbbbbbbb');
goto log;
end
if;
if sql%notfound then
dbms_output.put_line(
'cccccccc');
end
if;
dbms_output.put_line(
'cccccccc');
<<log>>
dbms_output.put_line(
'eeeeeeeeeeeeeee');
if sql%found then
dbms_output.put_line(
'ddddddddddddd');

end
if;

exception

when no_data_found then
dbms_output.put_line(
'aaaaaaaaaaaaaa');
dbms_output.put_line(sqlcode
+sqlerrm);--oralce 存储过程异常代码
commit;
end;

posted on 2011-05-12 21:56  石*3  阅读(150)  评论(0编辑  收藏  举报

导航