---
title: "oracle 以用户模式导入导出"
author: "ileson"
date: "2011-04-25T16:43:09Z"
tags: []
categories: ["数据库"]
slug: "oracle"
draft: false
lastmod: "2011-06-10T10:34:44Z"
id: 1017019
url: "https://ileson.iteye.com/blog/1017019"
---

①：查询该用户下的对象

```sql
select OBJECT_TYPE,COUNT(*) from all_objects where OWNER='用户名'
GROUP BY OBJECT_TYPE;
```
<span style="color:red">用户名处大写</span>
②：导出xining 用户下的所有对象（包括数据）

```CMD
C:\>exp xining/xining@ylx file=e:\data_xn.dmp log=e:\log_xn.log owner=xining
```

③：新建用户（xining/xining）
在新库上新建用户：（要用有dba权限的用户登陆）

```sql
create user xining
identified by xining
default tablespace USERS
temporary tablespace TEMP;
```

④：授权

```sql
grant dba to xining with admin option;
grant connect to xining with admin option;
grant resource to xining with admin option;
alter user xining default role dba,connect,resource;
```

⑤：导入

```CMD
C:\>imp xining/xining@orcl file=e:\data_xn.dmp log=e:\log_xn.log fromuser=xining touser=xining
```

⑥：重启服务（OS:windows）

```sql
c:\>lsnrctl stop/start --停止/启动 监听器
c:\>net stop/start oracleserivce"库名" --停止/启动 服务
```


⑦：删除该用户的所用对象
以非该用户且有管理员角色的用户登陆，然后再执行下列sql语句：
注：<span style="color:red">该语句慎用</span>

```sql
drop user xining cascade;
```



> 
> [url=http://orajc.blog.51cto.com/458434/112301]不错的资料[/url]
>