ORACLE数据库的导入与导出,以及触发器的用法
来源:互联网 发布:济宁网络问政平台育才 编辑:程序博客网 时间:2024/05/17 03:21
一、导出数据
1、实例:导出scott用户emp表和dept表中的数据到d盘
exp <user_name>/<password>@<db_name> table=(<table1>,<table2>...) file=<path>exp scott/a@yc tables=(emp,dept) file=D:\scott_back_table.dmp;
二、导入数据
imp userid=scott/a@yc tables=(emp) fileD:\scott_back_tables.dmp ignore=y;
注意:没有添加ignore 那么一旦出错则立即终止
imp userid=scott/a@yc tables=(dept) file=D:\scott_back_tables.dmp;
三、触发器
公式:
create [or replace] trigger <tri_name> after|before|instand of [insert or update[of coiumn_name] or delete] on <table_name> [referncing OLD as old/NEW as new] [for each row] [when (condition)] pl/sql block
实例:
create table test1( tid varchar2(20) primary key, tname varchar2(100));create sequence seq_test1_tid start with 10001;create or replace trigger tri_test1_tidbefore insert on test1for each row--行级触发,执行语句每影响一行触发一次--默认是语句级触发 执行完语句后触发一次,不管这条语句会影响多少行,都只触发一次begin select 'T'||substr(seq_test1_tid.nextval1,2)into :new.tid from dual;end;
四、修改主外键
实例1:修改dept表中的deptno,将20改为60
update dept set deptno=60 where deptno=20;
实例2:当用户修改dept表中的主键列时,用触发器自动修改emp表中的外键
create or replace trigger tri_updatebefore update on deptfor each rowbegin update emp set daptno=:new.deptno where deptno=:old.deptno;end;
五、安全校验
实例:
当前用户修改emp表中的sal时,如果修改后的工资<3000,则自动设为3000,否则不做操作
create or replace trigger tri_emp_checkbefore update on empfor each rowwhen(new.sal<3000)begin :new.sal:=3000;--PL/SQL两种给变量赋值的方式 select .. into ..end;update emp set sal=2000 where empno=7499;
0 0
- ORACLE数据库的导入与导出,以及触发器的用法
- oracle数据库数据的导出以及导入
- Oracle数据库的导出以及导入
- oracle数据库的导出与导入
- oracle数据库的导入与导出
- oracle的数据库导入与导出
- Oracle数据库的导入与导出问题
- Oracle数据库的导入与导出
- oracle数据库的导出与导入备忘
- Oracle数据库数据的导入导出以及备份
- Oracle数据库导入和导出以及出现的问题
- oracle数据库的导入导出
- oracle 数据库的导入/导出
- Oracle数据库的导入导出
- oracle数据库的导入导出
- oracle数据库的导出/导入
- oracle数据库的导入导出
- Oracle数据库的导入导出
- 【oj进阶之路】各大oj题目分类,集合整理,各处转载
- ios开发 UI高级 图形上下文
- CSRF (Cross Site Request Forgery)
- BGRABitmap图像操作6:开放线头,即一头为突出,另一头为凹进
- medsci
- ORACLE数据库的导入与导出,以及触发器的用法
- STL笔记之hashtable
- 【学习笔记】CSS的基本语法(一)
- CVTE笔试题
- Android 重要的文件目录和文件分析
- 【精】POJ 2151Check the difficulty of problems(概率dp+数学知识)
- codeforces454CLittle Pony and Expected Maximum+数学期望
- java包含继承的类中 给各项成员的加载顺序
- PHP endif、endwhile、endfor、冒号、switch、foreach使用介绍