Chinaunix
标题:
[oracle] oracle工作中常用命令
[打印本页]
作者:
三里屯摇滚
时间:
2011-12-10 22:05
标题:
[oracle] oracle工作中常用命令
[oracle] oracle工作中常用命令
工作中经常用的一些命令记录下来。慢慢更新,自己做个备份。。。1.查看表空间名称,物理路径,大小,实用状况
01.select a.tablespace_name,a.bytes/1024/1024||'M' total,b.bytes/1024/1024||'M' used,c.bytes/1024/1024||'M' free,d.file_name,
02.(b.bytes*100)/a.bytes ||'%'"used",(c.bytes*100)/a.bytes||'%' " free"
03.from sys.sm$ts_avail a,sys.sm$ts_used b,sys.sm$ts_free c,dba_data_files d
04.where a.tablespace_name=b.tablespace_name and
05.a.tablespace_name=c.tablespace_name and a.tablespace_name=d.tablespace_name
06.order by tablespace_name desc ;
复制代码
复制代码
2.查看lock
01.select b.username,b.sid,b.serial#,b.logon_time,b.osuser
02.from v$locked_object a,v$session b
03.where a.session_id = b.sid order by b.logon_time;
复制代码
复制代码
3.创建表空间
01.create tablespace test
02.datafile 'c:\test.dbf' size 100m
03.autoextend on next 64m;
复制代码
复制代码
4.创建临时表空间
01.CREATE TEMPORARY TABLESPACE test_temp
02. TEMPFILE 'C:\oracle\product\10.1.0\oradata\orcl\test_temp01.dbf'
03. SIZE 64M
04. AUTOEXTEND ON
05. NEXT 32M MAXSIZE 2048M
06. EXTENT MANAGEMENT LOCAL;
复制代码
复制代码
5.创建用户
01.create user test identified test123
02.default tablespace test
03.temporary tablespace test_temp;
复制代码
复制代码
6.授权
01.grant connect,resource to test;
复制代码7.杀死某个会话
01.Alter system kill session ‘sid,serial#’;
复制代码
复制代码
8.移动数据库位置
01.使表空间离线
02.alter tablespace test offline;
03.移动数据库位置
04.修改控制文件
05.alter tablespace test
06.rename 'c:\test.dbf' to ‘d:\test.dbf';
07.使数据库在线
08.alter tablespace test online
复制代码
复制代码
9.查看用户的默认表空间
01.select username,user_id,account_status,default_tablespace,TEMPORARY_TABLESP
02.from dba_users
03.order by desc;
复制代码
复制代码
10.设置时间格式
01. alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
复制代码
复制代码
作者:
小忻黑夜
时间:
2011-12-22 18:53
学习鸟 谢谢分享
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2