按天创建分区表
来源:互联网 发布:互联网金融数据 编辑:程序博客网 时间:2024/04/29 14:14
1、先创建分区表,建立第一个分区
create table cmp
(
transaction_id number primary key,
item_id number(8) not null,
item_description varchar2(300),
transaction_date date not null
)
partition by range (transaction_id,transaction_date)
(
partition part_01 values less than('20120101',to_date('2012-01-01','yyyy-mm-dd')) tablespace CNTV_MSS_DATA,
select to_char(to_date('2017-01-01','yyyy-mm-dd')-to_date('2011-09-08','yyyy-mm-dd')-1) from dual;
3、使用spool打印出执行脚本
set serveroutput on
set linesize 1500
spool d:\sp.sql
declare
a varchar2(20000);
b varchar2(20000):='alter table &tablename add partition PARTITION_MAXVALUE values less than (MAXVALUE,MAXVALUE)';
i int:=1;
begin
for i in 1..1095
loop
select 'alter table &tablename add partition PARTITION_' ||
to_char(to_date('20120101','yyyy-MM-dd') + i, 'yyyy_mm_dd') ||
' values less than (20120101,TO_DATE(''' || ' ' ||
to_char(to_date('20120101','yyyy-MM-dd') + i+1, 'yyyy_mm_dd') || ' ' || '00:00:00''' || ',' ||
' ''' || 'SYYYY-MM-DD HH24:MI:SS''' || ',' || '''' ||
'NLS_CALENDAR=GREGORIAN''' || '))' || ';'
into a from dual;
dbms_output.enable(200000);
dbms_output.put_line(a);
end loop;
dbms_output.put_line(b);
end;
/
spool off
create table cmp
(
transaction_id number primary key,
item_id number(8) not null,
item_description varchar2(300),
transaction_date date not null
)
partition by range (transaction_id,transaction_date)
(
partition part_01 values less than('20120101',to_date('2012-01-01','yyyy-mm-dd')) tablespace CNTV_MSS_DATA,
);
select to_char(to_date('2017-01-01','yyyy-mm-dd')-to_date('2011-09-08','yyyy-mm-dd')-1) from dual;
3、使用spool打印出执行脚本
set serveroutput on
set linesize 1500
spool d:\sp.sql
declare
a varchar2(20000);
b varchar2(20000):='alter table &tablename add partition PARTITION_MAXVALUE values less than (MAXVALUE,MAXVALUE)';
i int:=1;
begin
for i in 1..1095
loop
select 'alter table &tablename add partition PARTITION_' ||
to_char(to_date('20120101','yyyy-MM-dd') + i, 'yyyy_mm_dd') ||
' values less than (20120101,TO_DATE(''' || ' ' ||
to_char(to_date('20120101','yyyy-MM-dd') + i+1, 'yyyy_mm_dd') || ' ' || '00:00:00''' || ',' ||
' ''' || 'SYYYY-MM-DD HH24:MI:SS''' || ',' || '''' ||
'NLS_CALENDAR=GREGORIAN''' || '))' || ';'
into a from dual;
dbms_output.enable(200000);
dbms_output.put_line(a);
end loop;
dbms_output.put_line(b);
end;
/
spool off
- 按天创建分区表
- 创建分区表
- 创建分区表
- 创建分区表
- 创建分区表
- 创建分区表
- 实战分区表—创建分区表
- Oracle 创建分区表
- oracle创建分区表
- sql2005创建,删除分区表
- 创建分区表过程
- mysql 分区表 的创建
- sql创建分区表
- MySql创建分区表
- hive创建分区表问题
- hive创建分区表问题
- oracle分区表创建
- ORACLE 创建分区表
- __I、 __O 、__IO是什么意思?
- imx6 audmux 与ssi配置
- linux设备上的Onvif 实现8:编写媒体信息获取程序
- 取经之道,取而用之(中文乱码(编码解码)问题)
- C/C++ ceil和floor函数
- 按天创建分区表
- linux设备上的Onvif 实现7:编写设备能力获取程序
- SQL建表语句
- hibernate 中的count和distinct同时使用
- WP设备翻身仗:跃升拉美市场第二大移动平台
- 在java web项目中调用c++程序简单案例
- linux设备上的Onvif 实现6:获取摄像头的流媒体地址完整流程
- 六大设计原则之一_单一职责原则(SRP)
- 按月创建分区表