Oracle 常见初始化参数
间隔分区是范围分区的一个拓展,当插入的数据超过了现有的所有分区时,数据库会按照指定的间隔自动创建分区。Oracle支持创建单一
间隔分区是范围分区的一个拓展,当插入的数据超过了现有的所有分区时,数据库会按照指定的间隔自动创建分区。Oracle支持创建单一的间隔分区表也可以创建interval-range、interval-hash和interval-list三种组合分区表。
使用间隔分区的场景:
1.使用间隔分区最大的好处就是不用再提前手工的创建分区,只要后续创建的分区的分区间隔是统一的,就可以考虑使用间隔分区。并且,在后续创建的分区中还能通过store in 选项以循环复用的方式来将分区存放到不同的表空间里。
2.如果某张表是范围分区,则很容易的将该表转换成间隔分区表,例如sh用户下的sales表,可通过如下语句来修改:
SH@ORA11GR2 > ALTER TABLE sales SET INTERVAL (NUMTOYMINTERVAL(1,'MONTH'));
Table altered.
注意,如果范围分区存在最大分区MAXVALUE时,无法通过命令直接改为间隔分区。
例如,先创建表interval_test
create table interval_test (id number, name varchar2(20))
partition by range(id)
(partition p1 values less than (100),
partition p2 values less than (200),
partition p3 values less than(MAXVALUE));
接着尝试将该表修改为间隔分区表
SH@ORA11GR2 > alter table interval_test set interval (200);
alter table interval_test set interval (200)
*
ERROR at line 1:
ORA-14759: SET INTERVAL is not legal on this table.
使用oerr查看报错信息
[oracle@oracle11g ~]$ oerr ora 14759
14759, 00000, "SET INTERVAL is not legal on this table."
// *Cause: SET INTERVAL clause was specified. ALTER TABLE SET INTERVAL is
// only legal on a range partitioned table with a single partitioning
// column. Additionally, this table cannot have a maxvalue partition
// and cannot be the parent table for any reference partitioned tables.
// *Action: Use SET INTERVAL only on a valid table.
3.如果某张表为间隔分区表,则无法手工的对该表手动新增分区。所以如果决定将某张表修改为间隔分区,要考虑修改相关的应用程序或者存储过程。
SH@ORA11GR2 > alter table interval_sales add partition p4 values less than (to_date('20150101','yyyymmdd'));
alter table interval_sales add partition p4 values less than (to_date('20150101','yyyymmdd'))
*
ERROR at line 1:
ORA-14760: ADD PARTITION is not permitted on Interval partitioned objects
使用间隔分区的限制:
1.只能指定一个分区键,,并且键值类型只能为number或date。
2.间隔分区不支持索引组织表。
3.不能在间隔分区上创建域索引(domain index)
管理间隔分区:
1.创建间隔分区:
CREATE TABLE interval_sales
( prod_id NUMBER(6)
, cust_id NUMBER
, time_id DATE
, channel_id CHAR(1)
, promo_id NUMBER(6)
, quantity_sold NUMBER(3)
, amount_sold NUMBER(10,2)
)
PARTITION BY RANGE (time_id)
INTERVAL(NUMTOYMINTERVAL(1, 'MONTH'))
STORE IN (interv1, interv2)
( PARTITION p0 VALUES LESS THAN (TO_DATE('1-1-2008', 'DD-MM-YYYY')),
PARTITION p1 VALUES LESS THAN (TO_DATE('1-1-2009', 'DD-MM-YYYY')),
PARTITION p2 VALUES LESS THAN (TO_DATE('1-7-2009', 'DD-MM-YYYY')),
PARTITION p3 VALUES LESS THAN (TO_DATE('1-1-2010', 'DD-MM-YYYY')) );
2.禁用间隔分区
SH@ORA11GR2 > alter table interval_sales set interval ();
Table altered.
3.修改间隔分区interval值
SH@ORA11GR2 > alter table interval_sales set interval (NUMTOYMINTERVAL(1,'YEAR'));
Table altered.
4.删除间隔分区
SH@ORA11GR2 > ALTER TABLE interval_sales DROP PARTITION FOR(TO_DATE(' 2008-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'));
Table altered.
5.Merge间隔分区
首先插入两条数据,让系统自动生成两个间隔分区
SH@ORA11GR2 > insert into interval_sales values (1,2,to_date('20150101','yyyymmdd'),3,3,3,3);
1 row created.
SH@ORA11GR2 > commit;
Commit complete.
SH@ORA11GR2 > insert into interval_sales values (1,2,to_date('20150201','yyyymmdd'),3,3,3,3);
1 row created.
SH@ORA11GR2 > commit;
接着,执行命令,合并两个分区
SH@ORA11GR2 > alter table interval_sales merge partitions for ( to_date('20150101','yyyymmdd')) , for(to_date('20150201','yyyymmdd'));
Table altered.
注意,合并的两个分区需要前后相连,否则报错,无法合并!
本文永久更新链接地址:

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Go language is an efficient, concise and easy-to-learn programming language. It is favored by developers because of its advantages in concurrent programming and network programming. In actual development, database operations are an indispensable part. This article will introduce how to use Go language to implement database addition, deletion, modification and query operations. In Go language, we usually use third-party libraries to operate databases, such as commonly used sql packages, gorm, etc. Here we take the sql package as an example to introduce how to implement the addition, deletion, modification and query operations of the database. Assume we are using a MySQL database.

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

Hibernate polymorphic mapping can map inherited classes to the database and provides the following mapping types: joined-subclass: Create a separate table for the subclass, including all columns of the parent class. table-per-class: Create a separate table for subclasses, containing only subclass-specific columns. union-subclass: similar to joined-subclass, but the parent class table unions all subclass columns.

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())

To handle database connection errors in PHP, you can use the following steps: Use mysqli_connect_errno() to obtain the error code. Use mysqli_connect_error() to get the error message. By capturing and logging these error messages, database connection issues can be easily identified and resolved, ensuring the smooth running of your application.

HTML cannot read the database directly, but it can be achieved through JavaScript and AJAX. The steps include establishing a database connection, sending a query, processing the response, and updating the page. This article provides a practical example of using JavaScript, AJAX and PHP to read data from a MySQL database, showing how to dynamically display query results in an HTML page. This example uses XMLHttpRequest to establish a database connection, send a query and process the response, thereby filling data into page elements and realizing the function of HTML reading the database.

PHP is a back-end programming language widely used in website development. It has powerful database operation functions and is often used to interact with databases such as MySQL. However, due to the complexity of Chinese character encoding, problems often arise when dealing with Chinese garbled characters in the database. This article will introduce the skills and practices of PHP in handling Chinese garbled characters in databases, including common causes of garbled characters, solutions and specific code examples. Common reasons for garbled characters are incorrect database character set settings: the correct character set needs to be selected when creating the database, such as utf8 or u

Through the Go standard library database/sql package, you can connect to remote databases such as MySQL, PostgreSQL or SQLite: create a connection string containing database connection information. Use the sql.Open() function to open a database connection. Perform database operations such as SQL queries and insert operations. Use defer to close the database connection to release resources.
