oracle创建数据库及数据备份

目录:

  1.oracle创建表空间及用户

  2.oracle删除用户、数据、表空间及物理文件

  3.oracle数据导出、导出

  4.oracle查看表空间信息

  5.oracle配置远程连接 

1.oracle创建表空间及用户

1、创建表空间  

    create tablespace ams
    logging
    datafile 'D:\Java\Databases\oradata\ams.dbf'
    size 50m
    autoextend on
    next 50m maxsize 20480m
    extent management local; 

2、创建用户并指定表空间:  

create user ams identified by ams
default tablespace ams;

3、用户授权  

grant connect,resource,dba to ams;

2.oracle删除用户、数据、表空间及物理文件

1、删除用户  

drop user test cascade;

 2、删除tablespace  

drop tablespace test including contents and datafiles;

 3、物理文件test.dbf手动删除

3.oracle数据导出、导出

1、oracle导出用户下全部数据 

 imp导入xx.DMP

 2、exp导出角色下的整个库  

exp user/passwd@orcl

 4.oracle查看表空间信息(表空间名必须是大写的)

1、查看所有表空间
    select * from sys.dba_tablespaces;

2、查询用户所使用表空间
    select * from sys.dba_users  where   username =  'SCOTT'

3、查看当前用户的用户及表空间
    select username,default_tablespace from user_users;

4、查看表空间下的表
    select table_name from dba_all_tables where tablespace_name ='WWLROOTUSER';

5、查看当前用户连接
    select * from v$Session

6、查询用户的默认表空间及临时表空间
    select username,default_tablespace,temporary_tablespace from dba_users  where username='SYSTEM'

5.oracle配置远程连接    

1、利用oracle中的net manager进行网络配置(net manager的作用就是添加需要监听的ip、port,提供程序或软件连接远程数据库)
    1.在服务命名添加新的服务名并配置ip、port(这个服务名就是连接数据库时的数据库名)
    2.在”监听程序“下的LISTENER中添加需要监听的ip、port(本地连接使用主机名字不可使用127.0.0.1)
    xhost +      root用户下如果可以使用界面则显示成功
    netca        添加监听器
    
2、使用PL/SQL直接就可以连接@服务名
    windows、linux下使用
    lsnrctl status    查询监听器
    lsnrctl start    启动监听器
    lsnrctl stop     停止监听器
    netca            添加监听器服务
    shutdown immediate    关闭数据库
    startup                启动数据库
3、导出用户下的数据库
    exp user/passwd@orcl
4、PL/SQL创建连接指定连接的TNS配置文件

[oracle@localhost ~]$ imp Import: Release 11.2.0.1.0 - Production on Fri Sep 26 16:17:48 2014 Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved. Username: opr001 Password: Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options Import data only (yes/no): no >【回车】-----选择默认的意思 Import file: expdat.dmp > tachiai.dmp IMP-00002: failed to open tachiai.dmp for read -----这里出了个错误,于是我指定了绝对路径 Import file: expdat.dmp > /opt/oracle/tachiai.dmp Enter insert buffer size (minimum is 8192) 30720>【回车】-----选择默认的意思 Export file created by EXPORT:V11.02.00 via conventional path import done in US7ASCII character set and AL16UTF16 NCHAR character set import server uses JA16SJIS character set (possible charset conversion) List contents of import file only (yes/no): no >【回车】-----选择默认的意思 Ignore create error due to object existence (yes/no): no >【回车】-----选择默认的意思 Import grants (yes/no): yes >【回车】-----选择默认的意思 Import table data (yes/no): yes >【回车】-----选择默认的意思 Import entire export file (yes/no): no > 【回车】-----选择默认的意思 Username: opr001 Enter table(T) or partition(T:P) names. Null list means all tables for user Enter table(T) or partition(T:P) name or . if done:【回车】-----选择默认的意思
posted @ 2014-11-24 10:50  W&L  阅读(543)  评论(0)    收藏  举报