Oracle管理常用查询等命令语句

观察表空间的使用多少情况 select sum(bytes)/1024/1024 from data_free_space where tablespace_name = 'TBS_LJB' ;

  • 观察表空间的原始分配多少 select fum(bytes)/1024/1024 from dba_data_files where tablespace_name = 'TBS_LJB' ;
  • 手动增加数据文件扩大表空间 alter tablespace tbs_ljb add datafile 'E:\ORADATA\ORA10\DATAFILE\TBS_LJB_02.DBF' SIZE 100M;
  • 修改表空间TBS_LJB_02.DBF为自动扩展 alter database datafile 'E:\ORADATA\ORA10\DATAFILES\TBS_LJB_02.DBF' autoextend on;
  • 改变oracle中默认块大小8K,比如改成16K。设置SGA中数据缓存区db_16k_cache_size取值为非空。如:alter system set_db_16k_cache_size=100M;然后建表空间:create tablespace TBS_LJB_16k blocksize 16K datafile 'E:\oradata\ora10\datafile\tbs_ljb_16K_01.DBF'  size 100M autoextend extent management local segment space management auto;
  • 查询表空间信息: select tablespace_name,block_size from dba_tablespaces where tablespace_name in('TBS_LJB2','TBS_LJB_16K') ;
  • 查询回滚表信息: select tablespace_name ,status from dba_tablespaces where contents = 'UNDO' ;
  • 创建表空间TBS_LJB,并初始化为自动扩展模式(oracle10g 及以上版本可以取消extent management local 和 segment space management auto)

             drop tablespace TBS_LJB including contents and datafiles;

             create tablespace TBS_LJB datafile 'E:\ORADATA\ORA10\DATAFILE\TBS_LJB_01.DBF' size 100M autoextend on extent management local segment space management auto;

             create tablespace TBS_LJB3 datafile 'E:\ORADATA\ORA10\DATAFILE\TBS_LJB3_01.DBF' size 100M autoextend next64k maxisize 5G;(创建表时指定以64KB进行扩展,基本上等同于uniform 64K的功能,同时控制最大表空间尺寸,即最大不超过5G)

  • 分析表中产生行迁移的记录插入到chained_row表中,analyze table EMPLOYEES list chained rows into chained_rows;
  • 查看行迁移的记录数: select count(*)  from chained_rows where table_name = 'EMPLOYEES' ;
  • select a.name,b.value from v$statname a ,v$mystat b where a.statistic #=b.statistic# and a.name='redo size';
  • 创建查询redosize产生日志量视图:grant all on v_$statname to ljb; grant all on v_$statname to ljb;creat or replace view v_redo_size as select a.name,b.value from v$statname a ,v$mystat b where a.statistic #=b.statistic# and a.name='redo size';
  • 创建基于会话的临时表:create global temporary table T_TMP_session on commit preserve rowsas select * from dba_objects where 1=2;
  • 创建基于事务的临时表:create global temporary table T_TMP_transaction on commit delete rowsas select * from dba_objects where 1=2;
  • 查看索引状态:select index_name,status from user_indexes where index_name in('索引名1','索引名2')
  • 重建索引 alter index IDX_PART_TAB_DATE rebuild;
  • 查看提交次数过多的会话信息:select t1.sid,t1.value,t2.name from v$sesstat t1,v$statname t2 where t2.name like '%user commits%' and t1.STATISTIC#=t2.STATISTIC# and value >= 10000 order by value desc;
  • 查看会话中提交次数过多的SQL信息sql_id:select sid,username,t.PROGRAM,sql_id,t.PREV_SQL_ID from v$session t where sid in=991;
  • 根据SQL信息查看提交次数过多的SQL语句:select sql_text from v$sql where sql_id='avms342zm5k9u';

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值