各位高手,小弟写了一sql语句:alter table sm.push_real_url move tablespace users用来释放表占用空间,想把它放在job中,每天定时执行一次,可总是报错,但我在plsql的sql窗口中可以成功执行,请哪位高手不吝指教.

解决方案 »

  1.   

    可能是做的过程中,表被别的用户占用了,建议用:
    alter table xxx deallocate unusedmove后,需要重建索引。
      

  2.   

    CREATE OR REPLACE PROCEDURE PRO_PUSHREAL_CLEAR
    AS
    BEGIN
    delete from sm.push_real_url where months_between(sysdate,push_date)>=2;
    --alter table sm.push_real_url move tablespace users;
    alter table sm.push_real_url deallocat unused;
    --alter table xxx deallocate unused
    END PRO_PUSHREAL_CLEAR;
    这样写后编译:出现下面错误
    错误:PLS-00103: 出现符号 "ALTER"在需要下列之一时:
    begin case declare end
              exception exit for goto if loop mod null pragma raise return
              select update while with <an identifier>
              <a double-quoted delimited-identifier> <a bind variable> <<
              close current delete fetch lock insert open rollback
              savepoint set sql execute commit forall merge
              <a single-quoted SQL string> pipe
           符号 "lock在 "ALTER" 继续之前已插入。
    行:7
    文本:alter table sm.push_real_url deallocat unused;错误:PLS-00103: 出现符号 "UNUSED"在需要下列之一时:
            , in
    行:7
    文本:alter table sm.push_real_url deallocat unused;
      

  3.   

    create or replace procedure p_release_table
    as
    begin
    delete from test where id=2;
    execute immediate 'alter table test move tablespace system';
    end;