1. create sequence person_seq
  2. start with 1
  3. increment by 1
  4. order                     --按顺序
  5. nocycle                 --不循环不重复
  6. ;
  7. insert into person values(person_seq.nextval,null,'iteye);
  8. delete from person;
  9. update person set user_name ='zwllxs6' where id = 3;
  10. ---触发器
  11. create or replace trigger person_tr before insert or update or delete on person
  12. for each row
  13. Declare
  14. can_not_update_exception  EXCEPTION;
  15. begin
  16. dbms_output.put_line('testest');
  17. if inserting then
  18. dbms_output.put_line('inserting');
  19. end if;
  20. if updating then
  21. dbms_output.put_line('updating');
  22. dbms_output.put_line('old: '||:old.user_name);
  23. dbms_output.put_line('new: '||:new.user_name);
  24. if(:old.user_name<>:new.user_name) then
  25. dbms_output.put_line('不一样,不能更新');
  26. Raise_application_error(-20000,'不一样,不能更新');
  27. end if;
  28. end if;
  29. if deleting then
  30. dbms_output.put_line('deleting');
  31. end if;
  32. end;
  1. Class.forName("oracle.jdbc.driver.OracleDriver");
  2. Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:orcl", "scott", "******");
  3. // 创建状态
  4. Statement stmt = conn.createStatement();
  5. // 执行SQL语句,返回结果集
  6. ResultSet rs = stmt.executeQuery("SELECT * FROM person");
  7. while (rs.next()) {
  8. int id = rs.getInt("id");
  9. String userName = rs.getString("user_name");
  10. System.out.println("id: "+id);
  11. System.out.println("userName: "+userName);
  12. }
  13. int num=stmt.executeUpdate("update person set user_name ='zwllxs5' where id = 3");
  14. System.out.println("num: "+num);
 

最新文章

  1. C#图像处理笔记
  2. js设置鼠标悬停改变背景色
  3. 30秒懂SQL中的join(2幅图+30秒)
  4. 十二天 mysql操作
  5. [工作中的设计模式]迭代子模式Iterator
  6. class的使用
  7. 终于成功仿了一次Kalman滤波器
  8. cdoj 1253 阿里巴巴和n个大盗 博弈论
  9. textarea中的文字自动换行问题
  10. codeforces 652E Pursuit For Artifacts 边双连通分量
  11. SpringMVC 之文件上传 MultipartResolver
  12. android 广播分类
  13. hdu 5532 Almost Sorted Array(模拟)
  14. HTML-滚动字幕的源代码(可作滚动公告)
  15. 【复习】VueJS之内部指令
  16. Python“函数式编程”中常用的函数
  17. UVA10384-The Wall Pushers(迭代加深搜索)
  18. Java笔试面试题整理第一波
  19. java使用elasticsearch进行模糊查询之must使用-项目中实际使用
  20. page = new String(request.getQueryString().getBytes(&quot;ISO-8859-1&quot;),&quot;GBK&quot;);解决前台传后台乱码问题

热门文章

  1. Centos Odoo Service Config
  2. MySQL中引号的问题
  3. sbt %%
  4. Windows8.1自定义快捷方式添加到开始屏幕
  5. ZK tree使用mold
  6. hdu-acm steps 命运
  7. jquery暂停和中断循环
  8. []with[[]]
  9. jetBrains phpstorm/webstorm 编辑器使用诀窍
  10. php有效的过滤html标签,js代码,css样式标签