`
jxpengtao
  • 浏览: 64613 次
  • 性别: Icon_minigender_1
  • 来自: 江西
社区版块
存档分类
最新评论

oracle创建数据库脚本

阅读更多
--1:导出数据库:
exp username/password@databasename file =d:\test.dmp
eg:exp jxpt/jxpt@jxpt file =d:\jxpt.dmp
注:databasename为oracle\ora92\network\admin\tnsnames.ora下的名字。

--2:创建数据库
开始菜单====>"oraHome92"===> "datebase configuration assistant"===>创建数据库jxpt

--3:启动服务
注意设置"管理工具"====>"服务"===>相应的数据库服务"OracleServiceJXPT"和监听"OracleOraHome92TNSListener"
为自动启动

--select * from dba_data_files
--4:创建表空间,  临时表空间可以不用创建了(本来自动会创建)
create tablespace tablespace1 datafile 'D:\ORACLE\ORADATA\JXPT\tablespace1.DBF' size 20M;
create temporary tablespace temp1 tempfile 'D:\ORACLE\ORADATA\JXPT\temp1.DBF' size 10M;

--5:创建用户

CREATE USER jxpt IDENTIFIED BY jxpt
DEFAULT TABLESPACE tablespace1
TEMPORARY TABLESPACE TEMP

--6:给用户权限

grant resource,connect to jxpt

--7:导入数据库
imp jxlt/jxlt@jxlt fromuser=jxpt touser=jxlt  file=d:\jxlt.dmp
    说明:当前用户名/密码@数据库名 fromuser=当初导出时的用户 touser=导入的新用户  file=d:\test.dmp

=====================================================
定时导出导入备份数据库
=====================================================
1、导出数据库1的数据
exp jxpt/jxpt@jxpt tables=(tb_inv_invoicecode,tb_inv_firwindetail) file=jxpt_copyData.dmp
2、执行删除表结构及数据的脚本
sqlplus outinvoice/psw@ORADB_192.168.2.94 @deltb.sql
3、导入数据到另外一个数据库
imp outinvoice/psw@ORADB_192.168.2.94 fromuser=zhengguan touser=outinvoice file=tb52.dmp ignore=y log=y
注:ignore=y 表示忽略表的创建
    log=y 日志文件为y.log
见附件

========生成随机名=====================================
1: windows2000 DOS下得到当前日期 c:\%date:~4,13%   如:2008-05-07
2: windowsXP DOS下得到当前日期 %date:0~10%
exp jxpt/jxpt@JXPT file=%date:~4,13%.dmp log=%date:~4,13%
======================================================
将数据库中的表table1中的字段filed1以"00"打头的数据导出
   exp system/manager@TEST file=d:\daochu.dmp tables=(table1) query=\" where filed1 like '00%'\"
   http://blog.sina.com.cn/s/blog_5719dd0501009fis.html


  • pt.rar (1.6 KB)
  • 描述: 定时导出导入备份数据库
  • 下载次数: 120
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics