oracle数据库管理

上传人:第*** 文档编号:30997357 上传时间:2018-02-03 格式:DOCX 页数:21 大小:36.13KB
返回 下载 相关 举报
oracle数据库管理_第1页
第1页 / 共21页
oracle数据库管理_第2页
第2页 / 共21页
oracle数据库管理_第3页
第3页 / 共21页
oracle数据库管理_第4页
第4页 / 共21页
oracle数据库管理_第5页
第5页 / 共21页
点击查看更多>>
资源描述

《oracle数据库管理》由会员分享,可在线阅读,更多相关《oracle数据库管理(21页珍藏版)》请在金锄头文库上搜索。

1、1Oracle 数据库基础管理2017-10-11概述帐户01,sys( 超级管理员 ) 的角色是 sysdba。数据库内很多重要的东西(数据字典表、内置包、静态数据字典视图等)都属于这个用户,sys 用户必须以 sysdba 身份登录。02,system(谱通管理员) 的角色是 sysoper。手工创建的任何用户在被授予 dba 角色后都跟这个用户差不多。02,sys 具有 create database 的权限; system 没有该权限03,YSDBA 不是权限,当用户以 SYSDBA 身份登陆数据库时,登陆用户都会变成 SYS。 04,system 用户以 sysdba 身份登录时就是

2、 sys,准确地说,任何用户以 sysdba 身份登录时都是 sys,登陆后执行show user 可以验证。sys:拥有 dba、 sysdba、sysoper(系统操作员 )角色或权限,是 Oracle 权限最高的用户,只能以 sysdba 或 sysoper 登录,不能以 normal 形式登录。System:拥有 dba、sysdba 权限或角色,可以以普通用户的身份登录。sysdba、sysoper、DBA 区别Sysdba 用户: 可以改变字符集、创建删除数据库、登录之后用户是 SYS(shutdown、startup)Sysoper:用户不可改变字符集、不能创、删数据库、登陆之后

3、用户是 PUBLIC (shutdown、startup)DBA 用户:只有在启动数据库后才能执行各种管理工作。Sysdba Sysoper普通的 DBAsys; /系统管理员,拥有最高权限system; /本地管理员,次高权限2scott; /普通用户,密码默认为 tiger,默认未解锁一,Oracle 登录1,SQL Plus 命令登录sqlplus / as sysdba /按 2 次回车(登陆 sys 帐户)sqlplus sys as sysdba; /同上sqlplus scott/tiger; /登陆普通用户 scott在 CMD 命令窗口中输入:sqlplus 用户名/密码 数

4、据库本地服务名 as sysdba;(如:sqlplus scott/1234oracle1 as sysdba;)set oracle_sid=orcl sqlplus / as sysdba 2,查看数据库名show parameter db_name3,创建表空间create tablespace hudata logging datafileD:appAdministratororadbscottpthudata.dbf size 50m autoextend on next 50m maxsize 20480m extent management local; 4,查询表空间sele

5、ct * from dba_tablespaces;select tablespace_name from dba_tablespaces;5,删除表空间drop tablesplace scottptdata including contents and datafiles;36,创建用户并分配表空间create user scott identified by bkc123456; alter user scott default tablespace hudata quota unlimited on hudata; alter user scott quota unlimited on

6、 hudata; alter user scott temporary tablespace temp; grant create trigger to scott; grant create session to scott; grant create sequence to scott; grant create synonym to scott; grant create table to scott; grant create view to scott; grant create procedure to scott; grant alter session to scott; gr

7、ant create job to scott; grant dba to scott; exit 7,查看用户select * from all_users;select username from dba_users;8,删除用户drop user scott cascade;ora-01940 无法删除当前已连接用户解决方法:? 查看用户的连接状况 select username,sid,serial# from v$session4? 找到要删除用户的 sid,和 serial,并删除 alter system kill session532,4562;? 删除用户 drop user

8、 ts cascade9,同版本数据库备份和迁移导出数据库导出某用户下的所有文件:exp userid=scott/bkc123456scott buffer=64000 file=C:qianyibckyun.dmp log=C:qianyitest.log full=y在系统用户下导出用户的对象:exp userid=sys/bkc12345scottxdj buffer=64000 file=D:cmpdmpbckyunxdj.dmp log=D: cmpdmptest.log owner=scott在系统用户下导出某个用户的表信息:exp userid=sys/bkc12345scot

9、txdj buffer=64000 tables=(easpectra) file=D:cmpdmpbckyunxdj.dmp log=D: cmpdmptest.log 用超级用户导出整个数据库exp userid=sys/bkc12345scottxdj as sysdba file=D:cmpdmpbckyunxdj.dmp log=D: cmpdmptest.log full=y只导出数据库的表结构:exp userid=scott/bkc123456scott buffer=64000 file=C:qianyibckyun.dmp log=C:qianyitest.log owne

10、r=scott rows=n compress=n(rows=n 表示不带数据,rows=y 表示带数据)导入数据库完全:imp userid=sys/bkc12345scottxdj buttfer=64000 file=D:cmpdmpbckyunxdj.dmp log=D:cmpdmptest.log ignore=y commit=y full=y(表示每个数据缓冲满了之后提交一次,而不是导完一张表提交一次.这样会大大减少对系统回滚段等资源的消耗,对顺利完成导入是有益)按用户:Imp userid=scott/bkc12345scottxdj buttfer=64000 file=D:

11、cmpdmpbckyunxdj.dmp log=D: cmpdmptest.log fromuser=scott touser=scott按表:imp userid=scott/bkc12345scottxdj buttfer=64000 tables=(easpectra) file=D:cmpdmpbckyunxdj.dmp log=D: cmpdmptest.log5导入表结构但过滤重复表imp userid=scott/bkc12345scottxdj buttfer=64000 file=D:cmpdmpbckyunxdj.dmp log=C:qianyitest.log full=

12、y(ignore=y 表示参数对已存在的表中没有的记录进行更新但已存在的记录不会进行覆盖,不使用 ignore=y 表示对已存在的表就不会进行导入)10,从高版本到低版本的备份和迁移导出数据库:sqlplus sys/bkc12345scottxdj as sysdbacreate directory imp_dir as d:qianyi;grant read,write on directory imp_dir to scott;exitexpdp scott/maximoscott directory=exp_dir dumpfile=scott.dmp logfile=scott.lo

13、g version=10.2.0.4.0(content=all 表示导出所有,Date_only 表示只导出对象,Metadata_only 表示只导出数据)导入数据库:sqlplus sys/bkc12345scottxdj as sysdbacreate user weihai identified by bkc123 default tablespace weihai;alter user weihai default tablespace weihai;grant connect,resource to weihai;grant unlimited tablespace to wei

14、hai;grant create database link to weihai;grant select any sequence,create materialized view to weihai;grant create session to weihai;create directory exp_dir as E:qianyi ;grant read,write on directory exp_dir to weihai;grant dba to weihai;exitimpdp weihai/bkc123scottpt directory=exp_dir dumpfile=EXP

15、_33_SCOTTWH_2017_09_12_10_23_56.dmp remap_schema=导出用户名: 导入6用户名 remap_tablespace=导出表空间名:导入表空间名 PARALLEL=8 version=10.2.0.4.011,数据库恢复alter table FACILITYHEALTH enable row movement;flashback table FACILITYHEALTH to timestamp to_timestamp(2016-03-22 00:20:00,yyyy-mm-dd hh24:mi:ss);12,查看数据库版本select * fro

16、m V$version;13,删除数据库中的所有数据set oracle_sid=scottxdjsqlplus /as sysdbashow parameter instance_namedrop user scott cascade;14,查看 directory 目录select * from dba_directories;15,删除 directory 目录drop directory 目录名;16,关闭数据库Shutdown immediate;17,开启数据库startup;7数据库开启报错解决方案:ora-01219:数据库未打开alter database open;ora-16014:日志未归档ora-00312:联机日志sqlplus/nologconnect / as sys

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 办公文档 > 其它办公文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号