现在的位置: 首页 > 综合 > 正文

oracle10g 创建表空间、用户以及导入导出数据

2013年12月02日 ⁄ 综合 ⁄ 共 1790字 ⁄ 字号 评论关闭

---创建表空间

Create tablespace testuser datafile '/u/app/oracle/oradata/orcl/testuser.dbf' size 800M autoextend on next 100M maxsize unlimited;

----创建用户
Create user testuser identified by testuser Default tablespace testuser Temporary tablespace temp Quota unlimited on testuser ;

---给创建的用户授权
Grant connect,resource, dba to testuser ;

---导入数据

imp testuser/testuser@orcl file=/u/testuser.dmp fromuser=testuser touser=testuser ignore=y commit=y buffer=65536

 

 执行此导入命令时如果报如下错误:
Import: Release 10.1.0.2.0 - Production on 星期四 10月 25 17:57:04 2007

Copyright (c) 1982, 2004, Oracle.  All rights reserved.

IMP-00058: 遇到 ORACLE 错误 12560
ORA-12560: TNS: 协议适配器错误
IMP-00000: 未成功终止导入

 

解决办法:
运行命令:
set Oracle_SID=orcl                 {linux用命令: export Oracle_SID=orcl}

imp testuser/testuser full=y

Import: Release 10.1.0.2.0 - Production on 星期四 10月 25 17:59:11 2007

Copyright (c) 1982, 2004, Oracle.  All rights reserved.

连接到: Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production

导入文件: EXPDAT.DMP> /u/testuser.dmp就可以了。

--导出数据

exp testuser/testuser@orcl file=/u/testuser.dmp rows=y buffer=65536 indexes=y

 

   ◆Oracle查询用户表空间:select * from user_all_tables

  ◆Oracle查询所有函数和储存过程:select * from user_source

  ◆Oracle查询所有用户:select * from all_users.select * from dba_users

  ◆Oracle查看当前用户连接:select * from v$Session

  ◆Oracle查看当前用户权限:select * from session_privs

  ◆Oracle查看用户表空间使用情况:

  select a.file_id "FileNo",a.tablespace_name

  "Tablespace_name",

  a.bytes "Bytes",a.bytes-sum(nvl(b.bytes,0)) "Used",

  sum(nvl(b.bytes,0)) "Free",

  sum(nvl(b.bytes,0))/a.bytes*100 "%free"

  from dba_data_files a, dba_free_space b

  where a.file_id=b.file_id(+)

  group by a.tablespace_name ,

  a.file_id,a.bytes order by a.tablespace_name;

--//删除表空间
drop tablespace test_temp including CONTENTS and datafiles;
--//修改用户密码
alter user test identified by new_password;
--//删除用户
drop user 用户名 cascade; --//执行该语句请小心,会级联删除该用户下所有对象。

 

 

抱歉!评论已关闭.