oracle 10g表分区

阅读更多
Select Segment_Name,segment_type,Sum(bytes)/1024/1024 sizeName_M From User_Extents Group By Segment_Name,segment_type order by sizeName_M desc
select * from user_operation_log_p
Select Count(1) From user_operation_log

Select Count(1) From alarm_events
Select * From platform_alarm_events_process

--数据主要来源于触发器,登录数据来源程序写入
select * from T_MEGA_LOG_REPORT where log_desc='登录系统' order by create_time desc
Select Count(1) From T_MEGA_LOG_REPORT
select log_desc from T_MEGA_LOG_REPORT group by log_desc

-- Create table
create table T_MEGA_LOG_REPORT_P
(
  id          CHAR(31) not null,
  user_id     CHAR(31),
  user_name   VARCHAR2(255),
  device_id   CHAR(31),
  device_type VARCHAR2(255),
  log_desc    VARCHAR2(255),
  log_type    VARCHAR2(255),
  create_time DATE,
  status      NUMBER(1),
  is_upload   NUMBER(1),
  organ_id    CHAR(31),
  event_id    VARCHAR2(255)
)
partition by range (create_time)
(
  partition P_MEGALOG_201601 values less than (to_date('2016-02-01', 'yyyy-mm-dd')),
  partition P_MEGALOG_201602 values less than (to_date('2016-03-01', 'yyyy-mm-dd')),
  partition P_MEGALOG_201603 values less than (to_date('2016-04-01', 'yyyy-mm-dd')),
  partition P_MEGALOG_201604 values less than (to_date('2016-05-01', 'yyyy-mm-dd')),
  partition P_MEGALOG_201605 values less than (to_date('2016-06-01', 'yyyy-mm-dd')),
  partition P_MEGALOG_201606 values less than (to_date('2016-07-01', 'yyyy-mm-dd')),
  partition P_MEGALOG_201607 values less than (to_date('2016-08-01', 'yyyy-mm-dd')),
  partition P_MEGALOG_201608 values less than (to_date('2016-09-01', 'yyyy-mm-dd')),
  partition P_MEGALOG_201609 values less than (to_date('2016-10-01', 'yyyy-mm-dd')),
  partition P_MEGALOG_201610 values less than (to_date('2016-11-01', 'yyyy-mm-dd')),
  partition P_MEGALOG_201611 values less than (to_date('2016-12-01', 'yyyy-mm-dd')),
  partition P_MEGALOG_201612 values less than (to_date('2017-01-01', 'yyyy-mm-dd')),
  partition P_MEGALOG_201701 values less than (to_date('2017-02-01', 'yyyy-mm-dd')),
  partition P_MEGALOG_201702 values less than (to_date('2017-03-01', 'yyyy-mm-dd')),
  partition P_MEGALOG_201703 values less than (to_date('2017-04-01', 'yyyy-mm-dd')),
  partition P_MEGALOG_201704 values less than (to_date('2017-05-01', 'yyyy-mm-dd')),
  partition P_MEGALOG_201705 values less than (to_date('2017-06-01', 'yyyy-mm-dd')),
  partition P_MEGALOG_201706 values less than (to_date('2017-07-01', 'yyyy-mm-dd')),
  partition P_MEGALOG_201707 values less than (to_date('2017-08-01', 'yyyy-mm-dd')),
  partition P_MEGALOG_201708 values less than (to_date('2017-09-01', 'yyyy-mm-dd')),
  partition P_MEGALOG_201709 values less than (to_date('2017-10-01', 'yyyy-mm-dd')),
  partition P_MEGALOG_201710 values less than (to_date('2017-11-01', 'yyyy-mm-dd')),
  partition P_MEGALOG_201711 values less than (to_date('2017-12-01', 'yyyy-mm-dd')),
  partition P_MEGALOG_201712 values less than (to_date('2018-01-01', 'yyyy-mm-dd'))
);
-- Create/Recreate indexes
create index IDX_CREATE_TIME_LOG on T_MEGA_LOG_REPORT (CREATE_TIME);
create index IDX_EVENT_ID on T_MEGA_LOG_REPORT (EVENT_ID);
-- Create/Recreate primary, unique and foreign key constraints
alter table T_MEGA_LOG_REPORT add constraint PK_T_MEGA_LOG_REPORT primary key (ID);
 
create table USER_OPERATION_LOG_P
(
  id              VARCHAR2(31) not null,
  optimistic_lock NUMBER(19) not null,
  user_id         VARCHAR2(255) not null,
  user_name       VARCHAR2(255),
  user_session_id VARCHAR2(255) not null,
  f_time          NUMBER(19) not null,
  target_type     VARCHAR2(255) not null,
  target_id       VARCHAR2(255) not null,
  target_name     VARCHAR2(255) not null,
  operation_id    VARCHAR2(255) not null,
  operation_name  VARCHAR2(255) not null,
  effect_id       VARCHAR2(255) not null,
  effect_name     VARCHAR2(255) not null,
  ip              VARCHAR2(16)
)
partition by range (F_TIME)
(
  partition P_USEROPERLOG_201501 values less than (1422720000000),
  partition P_USEROPERLOG_201502 values less than (1425139200000),
  partition P_USEROPERLOG_201503 values less than (1427817600000),
  partition P_USEROPERLOG_201504 values less than (1430409600000),
  partition P_USEROPERLOG_201505 values less than (1433088000000),
  partition P_USEROPERLOG_201506 values less than (1435680000000),
  partition P_USEROPERLOG_201507 values less than (1438358400000),
  partition P_USEROPERLOG_201508 values less than (1441036800000),
  partition P_USEROPERLOG_201509 values less than (1443628800000),
  partition P_USEROPERLOG_201510 values less than (1446307200000),
  partition P_USEROPERLOG_201511 values less than (1448899200000),
  partition P_USEROPERLOG_201512 values less than (1451577600000),
  partition P_USEROPERLOG_201601 values less than (1454256000000),
  partition P_USEROPERLOG_201602 values less than (1456761600000),
  partition P_USEROPERLOG_201603 values less than (1459440000000),
  partition P_USEROPERLOG_201604 values less than (1462032000000),
  partition P_USEROPERLOG_201605 values less than (1464710400000),
  partition P_USEROPERLOG_201606 values less than (1467302400000),
  partition P_USEROPERLOG_201607 values less than (1469980800000),
  partition P_USEROPERLOG_201608 values less than (1472659200000),
  partition P_USEROPERLOG_201609 values less than (1475251200000),
  partition P_USEROPERLOG_201610 values less than (1477929600000),
  partition P_USEROPERLOG_201611 values less than (1480521600000),
  partition P_USEROPERLOG_201612 values less than (1483200000000),
  partition P_USEROPERLOG_201701 values less than (1485878400000),
  partition P_USEROPERLOG_201702 values less than (1488297600000),
  partition P_USEROPERLOG_201703 values less than (1490976000000),
  partition P_USEROPERLOG_201704 values less than (1493568000000),
  partition P_USEROPERLOG_201705 values less than (1496246400000),
  partition P_USEROPERLOG_201706 values less than (1498838400000),
  partition P_USEROPERLOG_201707 values less than (1501516800000),
  partition P_USEROPERLOG_201708 values less than (1504195200000),
  partition P_USEROPERLOG_201709 values less than (1506787200000),
  partition P_USEROPERLOG_201710 values less than (1509465600000),
  partition P_USEROPERLOG_201711 values less than (1512057600000),
  partition P_USEROPERLOG_201712 values less than (1514736000000),
  partition P_USEROPERLOG_OTHER values less than (maxvalue)
);
-- Create/Recreate indexes
create index F_TIME_INDEX on USER_OPERATION_LOG (F_TIME);
create index USER_ID_INDEX on USER_OPERATION_LOG (USER_ID);
-- Create/Recreate primary, unique and foreign key constraints
alter table USER_OPERATION_LOG add constraint PK_T_USER_OPERATION_LOG primary key (ID);

drop table USER_OPERATION_LOG_p;
--添加分区
ALTER TABLE SALES ADD PARTITION P3 VALUES LESS THAN(TO_DATE('2003-06-01','YYYY-MM-DD')); 
ALTER TABLE SALES MODIFY PARTITION P3 ADD SUBPARTITION P3SUB1 VALUES('COMPLETE'); 
--怎样查询出oracle数据库中所有的的分区表 
select * from user_tables a where a.partitioned='YES' 
--显示当前用户所有分区表的子分区列信息: 
select * from USER_SUBPART_KEY_COLUMNS
--显示数据库所有分区表的信息: 
select * from DBA_PART_TABLES

你可能感兴趣的:(oracle)