数据导出导入
参考:http://www.cnblogs.com/jason_lb/archive/2007/02/09/645586.html
导出数据exp
1)将数据库TEST完全导出,用户名system 密码manager 导出到D:\daochu.dmp中
exp system/manager@TEST file=d:\daochu.dmp full=y
2)将数据库中system用户与sys用户的表导出
exp system/manager@TEST file=d:\daochu.dmp owner=(system,sys)
3)将数据库中的表inner_notify、notify_staff_relat导出
exp aichannel/aichannel@TESTDB2 file= d:\datanewsmgnt.dmp tables=(inner_notify,notify_staff_relat)
4)将数据库中的表table1中的字段filed1以"00"打头的数据导出
exp system/manager@TEST file=d:\daochu.dmp tables=(table1) query=" where filed1 like '00%'"
导入数据imp
1)将D:\daochu.dmp 中的数据导入 TEST数据库中。
imp system/manager@TEST file=d:\daochu.dmp
imp aichannel/aichannel@TEST full=y file=d:\datanewsmgnt.dmp ignore=y
上面可能有点问题,因为有的表已经存在,然后它就报错,对该表就不进行导入。
在后面加上ignore=y 就可以了
2)将d:daochu.dmp中的表table1 导入
imp system/manager@TEST file=d:\daochu.dmp tables=(table1)
创建表空间
create tablespace TBLSMS
datafile 'D:/oracle/product/10.2.0/oradata/shenhq/tblsms.dbf' size 5m reuse
AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED
EXTENT MANAGEMENT LOCAL AUTOALLOCATE
/
与操作系统有一些相关,因为涉及数据文件的指定:
create tablespace TBLSMS
datafile '/opt/app/oracle/oradata/stariboss/tblsms.dbf' size 5m reuse
AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED
EXTENT MANAGEMENT LOCAL AUTOALLOCATE
/
创建用户并配置权限
-- Create the user
create user [user_name]
identified by "[user_name]"
default tablespace [default_tablespace_name]
temporary tablespace [temp_tablespace_name]
profile DEFAULT;
-- Grant/Revoke role privileges
grant dba to [user_name];
-- Grant/Revoke system privileges
grant insert any table to [user_name];
grant select any table to [user_name];
grant update any table to [user_name];
grant unlimited tablespace to [user_name];
典型的存储过程编写
不会写PL/SQL不叫会用Oracle
存储过程
spool .[log_name].log
prompt
prompt Creating procedure [procedure_name]
prompt
create or replace procedure [procedure_name]
is
sql_code varchar2(50);
sql_errm varchar2(100);
cursor [cur_name] is
{select sql};
v_cnt number;
begin
v_cnt := 0;
for v_instanceservice in [cur_name] loop
begin
{some update sql};
v_cnt := v_cnt + 1;
if mod(v_cnt, 10000) = 0 then
commit;
end if;
exception
when others then
sql_code := sqlcode;
sql_errm := sqlerrm;
dbms_output.put_line(sql_code || ' ' || sql_errm ||
' at servicestr ' ||
v_instanceservice.servicestr);
end;
end loop;
commit;
dbms_output.put_line('Total is:' || v_cnt);
end;
/
spool off
函数
create or replace function [function_name]([parameters_name] [parameters_type])
return varchar2 IS
v_result varchar2(100);
{use parameters in sql as value}
begin
v_result := null;
{process nothing to say}
return v_result;
end [function_name];
修改表
增加字段
create or replace procedure ALTER_TABLE is
v_count number;
begin
select count(*)
into v_count
from user_tab_columns u
where u.TABLE_NAME = [表名]
and (u.COLUMN_NAME = [字段名,如果多个用OR拼接条件]);
if v_count < 1 then
execute immediate '[增加字段的ALTER脚本]';
end if;
commit;
end;
/
exec ALTER_TABLE;
DROP PROCEDURE ALTER_TABLE;
其他杂项
调整一批sequence的值
create or replace procedure adjust_seq_value_prc
is
sql_code varchar2(50);
sql_errm varchar2(100);
cursor cur_get_seq_info is
select us.sequence_name, us.last_number, us.increment_by, us.cache_size
from user_sequences us
where us.sequence_name not in
('[sequence_name]', '[sequence_name]', ......);
begin
for v_get_seq_info in cur_get_seq_info loop
begin
execute immediate 'alter sequence ' || v_get_seq_info.sequence_name ||
' increment by [number_want_to_add] nocache';
execute immediate 'select ' || v_get_seq_info.sequence_name ||
'.nextval from dual'
execute immediate 'alter sequence ' || v_get_seq_info.sequence_name ||
' increment by ' || v_get_seq_info.increment_by ||
' nocache';
exception
when others then
sql_code := sqlcode;
sql_errm := sqlerrm;
dbms_output.put_line(sql_code || ' ' || sql_errm);
end;
end loop;
end;
/
(有新知新得再补充,待续……)
分享到:
相关推荐
基于开放标准,Oracle Provider for OLE DB(oraoledb)允许访问 Oracle数据库。本文档描述了oraoledb特定于提供程序的 特性和属性。
正因为如此,当前国内oracle开发人员的岗位需求大幅度增加,投身oracle开发的人数也日益增多。 一个好的0racie开发人员不仅要知道一些基本语法和常见用法,还需要知道何时用、如何用、怎么避免相关误区、写出高...
本书详细介绍Oracle9i Web开发的完整信息,包括Oracle Web的体系结构,Web开发的核心概念,使用第三方模块来支持Apache服务器以及在Web...Oracle数据库开发人员以及涉及Oracle数据进行Web开发的人员都会从本书受益。
ORACLE 开发技术资料,适合应用程序卡发人员,初学者入门。
JSP+Oracle数据库开发与实例 张晓东,高鉴伟 清华大学出版社 ... 本书适用于使用JSP和Oracle开发动态网站的技术人员以及对相关技术感兴趣的读者,同时可以供使用SQL Server、MySQL等数据库开发网站的读者参考。
根据笔者多年使用ORACLE的工作经历,记录了ORACLE开发和管理中的技巧或要点,供开发人员参考使用
技术讲座:利用Oracle数据库11g简化您的应用开发 技术讲座:Oracle数据库11g的性能创新 技术讲座:使用 SQL Developer 从非Oracle数据库迁移到Oracle数据库 实战经验分享:Oracle数据库11g在大型OLTP系统上的...
本书揭示了Oracle数据库内部的核心信息,这些信息恰好是每个DBA 排除故障所必需的,不多不少。内容涉及Oracle 核心架构基础:多少开销是合理的?...《Oracle核心技术》适合DBA、QA、架构师、开发人员等人群阅读。
《舞动db2系列从oracle到db2开发—从容转身》目标读者群主要针对以下人员:从oracle向db2转型的技术人员;db2应用开发工程师;oracle应用开发工程师;数据库应用架构师;学习db2数据库开发技术的高校学生或者从事...
在进行 Oracle Web 开发的时候,程序员再也没有理由说自己找不到合适的开发工具了。 在过去几年中,出现了...款Oracle Web 开发工具,并分析目前的Web 应用趋势,希望能对广大数据库开发人员提 供一些参考和帮助。
详细描述了Oracle调优方法,如何查找性能低下的Sql语句,管理人员如何和开发人员一起协调进行性能调优。
正因为如此,当前国内Oracle开发人员的岗位需求大幅度增加,投身Oracle开发的人数也日益增多。 一个好的Oracle开发人员不仅要知道一些基本语法和常见用法,还需要知道何时用、如何用、怎么避免相关误区、写出高...
必看经典-作为开发人员了解oracle技术体系Oracle_9i_10g编程艺术:深入数据库体系
2月23日 广州 Oracle技术网(OTN)开发人员日 讲座资料
三思笔记之一步一步学Oracle》语言生动幽默,案例丰富,实践性强,在章节编排和内容组织方面,主要面向初次接触Oracle数据库的技术人员,以及对数据库操作感兴趣的开发人员,对于具有一定技术实力的中高级Oracle DBA...
正因为如此,当前国内Oracle开发人员的岗位需求大幅度增加,投身Oracle开发的人数也日益增多。 一个好的Oracle开发人员不仅要知道一些基本语法和常见用法,还需要知道何时用、如何用、怎么避免相关误区、写出高...
正因为如此,当前国内Oracle开发人员的岗位需求大幅度增加,投身Oracle开发的人数也日益增多。 一个好的Oracle开发人员不仅要知道一些基本语法和常见用法,还需要知道何时用、如何用、怎么避免相关误区、写出高...
应用程序开发人员可以在任何使用文本的Oracle数据库应用程序中充分利用Oracle Text搜索,应用范围可以是现有应用程序中可搜索的注释字段,也可是实现涉及多种文档格式和复杂搜索标准的大型文档管理系统。Oracle Text...
的入门书的补充,向中高级开发人员、架构师和管理员提供了对关键的Java EE 开发和部署技术 的深入讲解。本书跳过了基础内容,避免重复很容易从其他地方找到的信息,关注其他地方没有 提到的信息和技术。本书由Oracle...
这是第一本介绍使用...无论你是Oracle开发入门者、从WebDB升级的人员、需要掌握Portal 3.0强大新特性的资深Oracle Portal开发人员,还是Oracle 数据库管理员,本书都极具参考价值。本书的附带光盘中包含示例代码。