oracle创建表空间、用户 导入dmp文件

1.创建表空间

create tablespace test datafile 'E:\oracle\product\10.2.0\oradata\orcl\test.dbf' size 200m autoextend on next 10m maxsize unlimited;

2.设置表空间自动增长

alter database datafile 'E:\oracle\product\10.2.0\oradata\orcl\test.dbf' autoextend on;

3.创建临时表空间

create temporary tablespace test_temp tempfile 'E:\oracle\product\10.2.0\oradata\orcl\test_temp.dbf' size 50m autoextend on next 50m maxsize 20480m extent management local;

4.创建用户

create user test identified by test default tablespace test temporary tablespace test_temp;

5.给用户授予权限

-- Grant/Revoke role privileges

grant connect,resource to test;

grant exp_full_database to test;

grant imp_full_database to test;

-- Grant/Revoke system privileges

grant create procedure to test;

grant create trigger to test;

grant execute any procedure to test;

grant grant any privilege to test;

grant restricted session to test;

grant select any table to test;

grant unlimited tablespace to test;

grant create any view to test;

6.删除表空间

drop tablespace testdb INCLUDING CONTENTS;

7.PLSQL导入dmp文件

工具----导入表

选择oracle导入

在 “从用户”的下拉框中选择 dmp的导出用户

在 “导入到”的下拉框中选择 要导入用户

在 “导入文件”处选择要导入的 dmp文件

点击导入

8.命令提示行导入dmp文件

首先询问对方数据库的表空间名称和大小,然后在你的oracle中建立相应表空间,最后使用imp命令导入数据:

imp username/password@SID file=XXX.dmp fromuser=XXX touser=XXX tables=(XXX,XXX)

  其中,fromuser若为多个表空间的话,使用()将其括起来:fromuser=(a,b);

  touser参数仿fromuser参数;

  若只导入一部分表,使用tables参数,用()括起要导入的表;如果想全部导入,不需要指定tables参数

  补充:

  1.要新建一个数据库;

  2.若你的oracle安装在Unix/Linux上,直接在shell中使用imp;如果你的oracle安装在Windows上,随便在哪里开启一个CMD窗口就可以执行imp;

  3.username/password指的是你的数据库的登录用户名和密码;

  4.fromuser指对方数据库用户名,touser指你的数据库的用户名;

  5.使用oracle的管理端在“表空间”中即可创建;

  6.要导入所有的表最方便,不用写tables参数就成,不需要知道对方的表名。

原文地址:https://www.cnblogs.com/qlong8807/p/2959089.html