Oracle数据库知识整理

本文详细介绍了Oracle数据库的创建流程,包括建立表空间、创建用户并赋权、系统权限设置。同时,还讲解了如何连接数据库、启动和关闭数据库监听,以及数据的导入导出方法,包括SQL文件执行、dmp文件的导入导出。此外,还涵盖了生成AWR报告的步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Oracle数据库命令整理:


创建流程:
--1.建立表空间  
建立表空间(一般建N个存数据的表空间和一个索引空间):  
create tablespace 表空间名  datafile ' 路径(要先建好路径)\***_01.dbf' size 1024M  autoextend on next 5M maxsize 3000M;  ##autoextend on是自动增长的意思
alter tablespace 表空间名 add datafile '路径(要先建好路径)\***_02.dbf'  size 1024M autoextend ON next 100M maxsize 5120M ;


--2.建用户
create user 用户名 identified by 密码
  default tablespace 表空间名
  temporary tablespace temp
  profile DEFAULT;
 
--3.赋权
grant connect to 表空间名;
grant resource to 表空间名;
grant dba to 表空间名;
grant create any sequence to 表空间名;
grant create any table to 表空间名;
grant delete any table to 表空间名;
grant insert any table to 表空间名;
grant select any table to 表空间名;
--4. 系统权限
grant unlimited tablespace to 表空间名;
grant execute any procedure to 表空间名;
grant update any table to 表空间名;
grant create any view to 表空间名;








连接Oracle数据库:
1.首先查看编码方式是否符合要求
.bash_profile文件(一般情况在/home/oracle路径下)
在里面将字符集修改为你所需要的字符集
然后退出。
source .bash_profile生效。


2.连接Oracle  
sqlplus / as sysdba    
(sqlplus 账号/密码 as sysdba)
3.数据库监听
lsnrctl status  
lsnrctl start  启动数据库监听
lsnrctl stop  关闭数据库监听


3.启动数据库
startup


4.关闭数据库
shutdown immediate








数据库的数据导入导出
1.导入SQL文件
比如是C:/a.sql,那么就执行@C:/a.sql


2.Oracle下导入dmp文件。
命令:imp 用户名/密码 file=/home/oracle/test.dmp ignore=y full=y


3.导出dmp文件
将数据库TEST完全导出,用户名system 密码manager 导出到D:\daochu.dmp中
   exp system/manager@TEST file=d:\daochu.dmp full=y




   
   
awr报告
1.选择一个路径,
cd test


2. 调用脚本,生成文件
@?/rdbms/admin/awrrpt.sql


3.AWR提供txt和html两种格式。需要确认生成格式,默认是html格式。
Specify the Report Type
~~~~~~~~~~~~~~~~~~~~~~~
Would you like an HTML report, or a plain text report?
Enter 'html' for an HTML report, or 'text' for plain text
Defaults to 'html'


4.默认情况下,AWR会将镜像信息保留一个月。手工生成的时候,需要确认生成AWR报告的时间范围。
Specify the number of days of snapshots to choose from
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Entering the number of days (n) will result in the most recent
(n) days of snapshots being listed. Pressing without
specifying a number lists all completed snapshots.
 
Enter value for num_days:3 


5.之后AWR生成代码会将天数范围内的snapshot镜像点列出,供输入选择
例如:
ora11g      ORA11G           1789 20 Jun 2011 13:01     1
                              1790 20 Jun 2011 14:00     1
                              1791 20 Jun 2011 15:00     1
                              1792 20 Jun 2011 16:00     1
                              (篇幅原因,有省略……)
                              1811 21 Jun 2011 11:00     1
                              1812 21 Jun 2011 12:00     1
                              1813 21 Jun 2011 13:00     1
6.输入开始和结束的snapshot编号
Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter value for begin_snap:1796
Begin Snapshot Id specified: 1796
 
Enter value for end_snap:1813 


7.确定报告名称
 
最后就是确定生成报告的名称。一般采用默认的名称就可以了。
Enter value for report_name:
8.然后在指定目录上就会出现该报告
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值