Oracle数据库知识整理
2017-09-28 11:29
330 查看
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.然后在指定目录上就会出现该报告
创建流程:
--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.然后在指定目录上就会出现该报告
相关文章推荐
- Oracle数据库知识整理
- oracle数据库知识整理
- oracle数据库知识整理
- HCIE知识整理:ospf 的 virtual-link 有哪些用途,在用的时候可能会有什么问题,解决方案是 什么?
- tcp/ip协议详解及重点知识整理
- C#基础知识整理 基础知识(16) IList接口——非泛型
- 杂乱知识整理
- Python 学习(2)---基本知识整理
- 超全整理!Python数据分析知识体系
- Android开发基础知识整理之多线程与网络技术
- [心得] HTTP权威指南知识整理
- JavaScript中原型链知识的整理
- XMPP 相关知识整理
- javascript基础知识整理
- SQL知识整理一:触发器、存储过程、表变量、临时表
- Java知识整理(二十三)之json
- Maven知识整理
- HTTP网络连接相关知识整理(一):http连接与Socket连接
- String、StringBuffer、StringBuidler 知识整理