刪除分割槽表
alter table [表名稱] drop partition [分割槽表的名稱] ;
select * from user_tab_partitions d where d.table_name='bmp_customer_interaction';
-- user_tab_partitions 當前的使用者。所以不用使用者table_owner=user 和 dba_tab_partitions 而它存在授權的問題一般不用這個。這個不同要用table_owner=user
下面是用來檢測是否有分割槽。如果有就顯現出來 我在pl/sql test window執行的
select * from dba_tab_partitions p where p.table_owner=user and p.table_name='bmp_customer_interaction' and p.partition_name='brand_actos'
「bmp_customer_interaction」 是表的名稱一定要大寫如果小寫『bmp_customer_interaction』 檢索不到資料的
table_owner=user 是你的登陸的用
-- created on 2/17/2011 by administrator
對下面的對應的三張表進行分割槽
declare
v_tablespace varchar2(80) := null; 表空間
v_brand varchar2(20) := 'actos';-- 品牌的名稱 按品牌來分割槽
v_company varchar2(80) := null; 公司的名稱
v_sql varchar2(4000) := null;
v_count number := 0;
begin
if user = 'bmp' then
v_tablespace := 'tablespace bmp_data_a';
end if;
如果沒有記錄時:
select count(1)
into v_count
from bmp_brand b
where b.brd_brand = v_brand;
if v_count > 0
then
select b.brd_company
into v_company
from bmp_brand b
where b.brd_brand = v_brand;
end if;
v_sql := 'select count(1) from user_tab_partitions p where p.table_name=''bmp_customer_interaction'' and p.partition_name=''brand_'||v_brand||'''';
dbms_output.put_line(v_sql);
execute immediate (v_sql) into v_count;
dbms_output.put_line(v_count);
v_sql := 'alter table bmp_customer_interaction split partition brand_default values (''' ||
v_brand || ''') into (partition brand_' || v_brand ||
v_tablespace || ', partition brand_default' || v_tablespace || ')';
-- 進行判斷當前使用者是否進行分割槽,如果有分割槽的 v_count =1否側v_count =0;為0進行分割槽;
if v_count = 0 then
dbms_output.put_line(v_sql);
execute immediate (v_sql);-- 就執行這個語句;
end if;
v_sql := 'select count(1) from user_tab_partitions p where p.table_name=''bmp_tx_response'' and p.partition_name=''brand_'||v_brand||'''';
dbms_output.put_line(v_sql);
execute immediate (v_sql) into v_count;
v_sql := 'alter table bmp_tx_response add partition brand_' || v_brand ||
' values (''' || v_brand || ''')' || v_tablespace;
dbms_output.put_line(v_sql);
if v_count = 0 then
execute immediate (v_sql);
end if;
v_sql := 'select count(1) from user_tab_partitions p where p.table_name=''bmp_customer'' and p.partition_name=''company_'||v_company||'''';
dbms_output.put_line(v_sql);
execute immediate (v_sql)into v_count;
v_sql := 'alter table bmp_customer add partition company_' || v_company ||
' values (''' || v_company || ''')' || v_tablespace;
dbms_output.put_line(v_sql);
if v_count = 0 then
execute immediate (v_sql);
end if;
end;
Oracle對錶中字段進行處理
一 將歷史表的字段增加乙個或者多個的sql語句。1 增加乙個字段 增加欄位時,只能排在已有欄位的後面,不能插到已有字段之間 alter table 表名 add 欄位名稱 字段型別 2 增加兩個字段 alter table 表名 add 欄位名稱 字段型別,欄位名稱 字段型別 二 修改乙個字段 cr...
oracle對錶空間進行操作
1.更改資料檔案大小 alter database datafile filename resize 大小 2.向表空間新增資料檔案 alter tablespace 表空間名 add datafile filename size 10 autoextend on 3.表空間唯讀 alter tab...
Oracle對錶進行的修改操作
oracle對錶進行的修改操作,這裡以user表為例 修改表名 rename 舊表名 to 新錶名 rename user to newuser 修改表 新增新字段 alter table 表名 add 欄位名 字段型別 預設值 是否為空 alter table user add age numbe...