Oracle中空的user表空間有多大。如何刪除表空間中所有表的資料,只保留表結構

時間 2021-10-14 22:24:14

1樓:笹緗

如果你沒有給某使用者指定預設表空間,那麼那個使用者的表空間使用的是系統表空間,系統表空間的檔案肯定不能全部刪的,一個表空間可以對應多個使用者,如果是自建的表空間,只需在指定其為預設表空間的每個使用者下執行一個函式即可。附函式(我用的遊標)

declare

vsql varchar2(200);

cursor c1 is

select 'truncate' || table_name ||  v_name

from user_tables;

begin

for i in c1 loop

vsql := i.v_name;

execute immediate vsql;

end loop;

end;

2樓:匿名使用者

1、users表空間預設一般最大都是32g,

2、如果你建立使用者沒有指定表空間,預設一般都會存在users表空間

select username, default_tablespace from dba_users where username='user01';

alter user user01 default tablespace ts01;

3、查詢表佔用空間大小select segment_name,sum(bytes)/1024/1024 x from user_extents group by segment_name order by x;

4、查詢表空間佔用大小select tablespace_name,sum(bytes)/1024/1024 from dba_segments group by tablespace_name;

5、清空表資料

select * from tab;查詢所有表

truncate table 表名;

delete from table1 where 1=1;

create table2 as select * from table1 where 1=2;

oracle怎麼將表空間中所有的表的資料刪光?

3樓:匿名使用者

truncate table;在不改變表結構的基礎上,一次性快速刪除所有資料,且不可恢復;

較危險慎用!

在oracle中如何刪除一個使用者下所有該使用者所建的表?

4樓:匿名使用者

1、如果有plsql客戶端,則可以使用該使用者登入,選中所有表 右鍵drop即可。

2、如果有刪除使用者的許可權,則可以:

drop user user_name cascade;

加了cascade就可以把使用者連帶的資料全部刪掉。

--建立使用者 create user 使用者名稱 profile default identified by 密碼 default tablespace 表空間名稱 temporary tablespace temp account unlock;

--授權

grant dba to 使用者名稱;

grant connect,resource to 使用者名稱;

3、如果沒有刪除使用者的許可權,則可以執行:

select 'drop table '||table_name||';' from cat where table_type='table'

將得到的結果全部複製貼上到另一個sql視窗,執行。

5樓:匿名使用者

刪除使用者的語法是 drop user user_name

如果要刪除該使用者模式的包含物件(比如表)就要在要刪除得使用者名稱後面加上cascade

drop user user_name cascade;

oracle怎麼刪除表空間下所有的表

6樓:匿名使用者

1、建立兩個測試表,指定表空間temp;

create table test_ts_1(id number) tablespace temp;

create table test_ts_2(id number) tablespace temp;

2、查詢表空間下的表;可以發現剛建的兩張表;

select * from user_tables t where tablespace_name = 'temp';

3、編寫指令碼,刪除temp表空間下的所有表;

begin

for v_cur in (select distinct t.table_name from user_tables t where tablespace_name = 'temp') loop

execute immediate 'drop table '||v_cur.table_name||' purge';

end loop;

end;

4、再次查詢,可以發現temp表空間下的表,已經被刪除;

select * from user_tables t where tablespace_name = 'temp'

7樓:匿名使用者

select 'drop table ' || s.segment_name || ' purge; ' from dba_segments s where s.segment_type='table' and s.

tablespace_name = '***xx'

執行查詢出來的結果

注意 9i以下的版本不需要 purge 選項

8樓:大話殘劍

select 'drop table ' || table_name || ' cascade constraints' v_name

from dba_tables

where tablespace_name = 'users';

按照表空間名查詢所有包含的表,並根據表名拼接刪除語句。

執行上面查詢語句生成的語句,即可刪除所有表。

9樓:請叫我召哥

select 'drop table '||table_name||';' from dba_tables t where t.tablespace_name='表空間名字';

把執行結果copy出來,執行一下就行了,如果想一次執行,就寫個遊標,執行動態sql

oracle清空表內的資料

行走的皮卡丘呀 用truncate delete都可以,比如要清空一個名為abc的表,就這樣寫sql truncate table abc 或者 delete from abc oracle 查版本號,oracle怎樣查版本,具體步驟如下 1 首先進入sqlplus,cmd plsql,登陸我們的使...

oracle表空間名字的字尾ora和 dbf有什麼不同

沒什麼區別,主要是好分辨用途,oracle8i之前資料檔案的字尾名為.ora,之後為.dbf 無論.ora或.dbf,實際使用沒任何區別,也可以不用副檔名或指定任意副檔名 dbf 資料檔案 tmp 臨時檔案 log 重作日誌檔案 redo log file ctl 控制檔案 ora 引數檔案 dat...

c中怎麼讀取oracle資料庫裡的表

string connstr provider msdaora data source dbname user id user name password sa unicode true dbname是你的資料庫名 user name是你的資料庫登陸名 sa是密碼 string sqlstr sel...