因为执行了错误的SQL语句,TEMP01.DBF文件一下子增大了很多G,把磁盘空间都占用了。怎么办呢?

解决方案 »

  1.   

    建立新的临时表空间,
    将TEMP01.DBF的临时表空间不使用(在对应的用户中剔除出来),然后删除。
      

  2.   

    If no temporary tablespace is defined for the user, then the default temporary
    tablespace is the SYSTEM tablespace. The default storage characteristics of the
    containing tablespace determine those of the extents of the temporary segment. Oracle drops temporary segments when the statement completes.
      

  3.   

    如果操作系统允许创建临时文件,则会稀疏地创建
    即语句
    create temporary tablespace tmp_space1 tempfile '/d01/temp/tmp_space1' size 2048m
    会生成一个看起来2G大小,实际上只占用128kb的存储空间楼主如果用的Linux,那么可以完全不理这回事原文如下:
    One of the nuances of true temp files is that if the OS permits it, the temporary files will
    be created sparse—that is, they will not actually consume disk storage until they need to.
    ......Apparently it took only 128KB of storage to hold that file. But if we ls it it appears to be a normal 2GB file, but it is in fact only consuming some 128KB of storage.在windows系统下楼上二位说法都是可行的
      

  4.   

    完全不用理会,因为实际可能根本没有占用那么多。
    如果楼主是个完美主义者,实在看不惯OEM里面显示的那么高的使用率的话,可以重启一遍数据库。
      

  5.   

    执行大记录集的 order by 或 join 操作,会使临时表空间增加很快,但不会自动收缩。可以修改临时表空间 tempfile 的文件大小alter database datafile '<full_file_name>' resize <size>M;