Oracle数据库中系统管理员system如何删除某个表空间下的所有表,如何删除某个表空间下的一张表

解决方案 »

  1.   

    select table_name,tablespace_name from user_tables
    where tablespace_name = '表空间名';
    这是查询表空间下所有表的语句,你当然可以利用查询语句连接上你想写出的truncate或者drop table之类的sql语句。如 select  'DROP TABLE '||table_name||';' from user_tables
    where tablespace_name =  '表空间名';oracle同一个用户下不可能有两个相同名称的表 ~ 
      

  2.   

    #1 
    select 'DROP TABLE '||table_name||';' from user_tables
    where tablespace_name = '表空间名'; 
    能解释下详细代码么,初学Oracle,不太会
      

  3.   

    以SQL生成SQL,再批次执行是个好办法,学习了:
    SELECT 'DROP TABLE ' || table_name || ';'
      FROM user_tables
     WHERE tablespace_name = '表空间名';
      

  4.   


    create or replace
    procedure p_bat_drop_table(tablespacename in varchar2)
    is
    --tablespacename 传入参数
    --声明变量
    v_dropsql varchar2(1000);
    -- 定义游标
    cursor c_tablename is
    select ' drop table ' || table_name || ';'
    from user_tables
    where tablespace_name = tablespacename;
    begin
        --打开游标
        open c_tablename;
        --开始循环处理
        loop
        --循环赋值
        fetch c_tablename into v_dropsql;
        exit when c_tablename%notfound;
        --动态执行 v_dropsql
        execute immediate v_dropsql;
        --结束循环
        end loop;
        --关闭游标
        close v_dropsql;
        --提交
        commit;
    end;通过传入表空间名 来批量删除改表空间下的表的存储过程 有注释,楼主加油。
      

  5.   

    嘿嘿  看看基础知识吧~~ 
    我曾经和你一样,神马都很迷茫,不过多尝试会对你有帮助,记住tablespace_name 都是大写的 可以利用lower和upper之类的,省的这种小问题不注意也会纠结半天~