Linux 下 Oracle 控制台操作备忘
来源:互联网 发布:天幻汉化组 知乎 编辑:程序博客网 时间:2024/05/17 03:40
1. 切换到Oracle 帐户
su - oracle
2. 起/停 监听器
lsnrctl
>start
>stop
3. 起/停数据库
登录: sqlplus "/as sysdba"
>startup
>shutdown
4. 创建新用户
先登录,然后:
>create user knityster identified by passwd
default tablespace TSIPP_D
temporary tablespace TSIPP_T;
赋权:
>grant connect,resource,dba to knityster
注意:
Oracle 密码可以由英文字母,数字,#,下划线(_),美元字符($)构成,
密码的最大长度为 30 字符;
Oracle 密码不能以"$","#","_"或任何数字开头;
密码不能包含像"SELECT","DELETE","CREATE"这类的 Oracle/SQL 关键字。
5. 删除用户
>drop user knityster cascade;
6. 表空间
a. 查看指定用户使用的表空间使用的情况:
select username,default_tablespace,temporary_tablespace
from dba_users
where username='SYSTEM'
b.创建临时表空间
create temporary tablespace test_temp
tempfile 'E:/oracle/product/10.2.0/oradata/testserver/test_temp01.dbf'
size 32m
autoextend on
next 32m maxsize 2048m
extent management local;
c.创建数据表空间
create tablespace test_data
logging
datafile 'E:/oracle/product/10.2.0/oradata/testserver/test_data01.dbf'
size 32m
autoextend on
next 32m maxsize 2048m
extent management local;
d.创建用户并指定表空间
create user testserver_user identified by testserver_user
default tablespace test_data
temporary tablespace test_temp;
查看所有表空间信息:
select * from dba_tablespaces --where TABLESPACE_NAME = '表空间名';
---------------------------------------------------------------------------------------------------------------------
以下内容参考:http://zhutong7758.blogbus.com/logs/35080521.html
e. 查看当前表空间信息
select
a.a1 表空间名称,
c.c2 类型,
c.c3 区管理,
b.b2/1024/1024 表空间大小M,
(b.b2-a.a2)/1024/1024 已使用M,
substr((b.b2-a.a2)/b.b2*100,1,5) 利用率
from
(select tablespace_name a1, sum(nvl(bytes,0)) a2 from dba_free_space group by tablespace_name) a,
(select tablespace_name b1,sum(bytes) b2 from dba_data_files group by tablespace_name) b,
(select tablespace_name c1,contents c2,extent_management c3 from dba_tablespaces) c
where a.a1=b.b1 and c.c1=b.b1;
f. 查看Oracle数据文件信息
select
b.file_name 物理文件名,
b.tablespace_name 表空间,
b.bytes/1024/1024 大小M,
(b.bytes-sum(nvl(a.bytes,0)))/1024/1024 已使用M,
substr((b.bytes-sum(nvl(a.bytes,0)))/(b.bytes)*100,1,5) 利用率
from dba_free_space a,dba_data_files b
where a.file_id=b.file_id
group by b.tablespace_name,b.file_name,b.bytes
order by b.tablespace_name
g. 查看临时表空间和数据库文件的方法
select
a.tablespace_name 表空间名称,
b.bytes 大小bytes,
b.file_name 数据文件名
from dba_tablespaces a, dba_data_files b
where a.tablespace_name=b.tablespace_name --and a.contents='TEMPORARY';
---------------------------------------------------------------------------------------------------------------------
7. 导入导出
> exp bbs/password file=/home/oracle/bbs.dmp owner=bbs;
> imp bbs/password file=/home/oracle/bbs.dmp fromuser=bbs;
出现错误:failed to open ......for write/reader
原因: oracle 账户没有对指定目录的读/写权限
解决办法: 更换到Oracle有读写权限的相关目录
- Linux 下 Oracle 控制台操作备忘
- Linux 下 Oracle 控制台操作备忘
- Linux下磁带机操作备忘
- linux下开启oracle的EM控制台
- Linux下Oracle的em控制台启动
- linux下oracle操作。
- linux下oracle 操作
- linux下Oracle操作
- linux下Oracle操作
- linux 操作备忘3
- Linux平台下启动oracle 11g EM控制台
- Linux下的Oracle操作
- Linux下的Oracle操作
- linux下oracle相关操作
- Linux下连接、操作Oracle
- linux下常用命令备忘
- github备忘(linux下)
- Oracle 基本操作备忘[2]
- 奇怪的脑子
- 工作以来所读书目
- PHP模拟SMTP发送邮件的类
- 常量和变量在code中以及运行时的存储区别
- H.264备忘
- Linux 下 Oracle 控制台操作备忘
- PHP向一个字符串随机添加文字
- C++与C#之间共享内存的问题
- (转)探索C++的秘密之详解extern
- unix/linux部分常用命令
- Braun概念垃圾箱设计
- JAVA 生成随机数数组,并排序输出
- smarty 实用技巧
- Oracle扩展PL/SQL简介(二)