使用ALTER TABLE ... MERGE PARTITION语句将两个分区的内容合并到一个分区。原来的两个分区将会被删除,相关的本地索引也会被删除
合并分区
使用ALTER TABLE ... MERGE PARTITION语句将两个分区的内容合并到一个分区。原来的两个分区将会被删除,相关的本地索引也会被删除。对于哈希分区表或者复合哈希分区表的哈希子分区,你不能使用这个语句。
对于引用分区表,你不能合并分区。相反,父表的合并操作会级联到所有子表。尽管如此,当你在父表执行合并分区或者子分区操作时,你也可以使用DEPENDENT TABLES子句来为相关表设置特定属性。
如果涉及到的分区或者子分区包含数据,那么索引可能被标识为UNUSABLE,如下表所述:
表类型
索引操作
普通表(堆表)
除非你在ALTER TABLE语句中指定UPDATE INDEXES字句:
l 数据库将生成的所有相关本地索引分区或者子分区标识为UNUSABLE。
l 全局索引,或者分区全局索引的所有分区,被标识为UNUSABLE,必须重建。
索引组织表
l 生成的所有相关本地索引分区标识为UNUSABLE。
l 所有全局索引保持可用。
合并范围分区
你可以将两个相邻的范围分区的内容合并到一个分区。不相邻的范围分区不能合并。合并生成的分区继承了这两个合并分区中更高的上限。
合并范围分区的一个原因是保持在线历史数据在较大的分区。例如,你可以有每日分区,然后将最旧的分区聚合为周分区,进而周分区可以聚合为月分区,等等。
例
合并间隔分区你可以将两个相邻的间隔分区的内容合并到一个分区。不相邻的间隔分区不能合并。第一个间隔分区也能喝最高的范围分区进行合并。合并生成的分区继承了这两个合并分区中更高的上限。
合并间隔分区总是导致转换点移动到这两个合并分区中更高的上限。结果是间隔分区表的范围分区扩展到这两个合并分区中更高的上限。任何边界低于新合并生成分区的物化间隔分区,都会自动转化到范围分区,并且使用它们的间隔分区上限定义作为范围分区上限。
例如,虑一下间隔分区transactions:
接下来,合并两个相邻的间隔分区。新分区会再有一个系统生成的名称。
合并列表分区当你合并列表分区时,本合并的分区可以是任意两个分区。它们不必像范围分区那样必须是相邻的,因为列表分区默认是没有顺序的。生成的分区由原来两个分区的数据组成。如果你将默认分区和其他分区进行合并,那么新生成的分区是默认分区。
下面的语句合并了一个列表分区表的两个分区,新生成的分区继承了所有表级别的默认属性。语句指定了MAXEXTENTS子句。
合并复合哈希分区当你合并复合哈希分区时,子分区会根据哈希函数重新分布到由SUBPARTITIONS n或者SUBPARTITIONS子句指定数量的分区。如果两个都没有指定,那么就使用表级别的默认值。
需要注意的是,分割一个复合哈希分区(在“分割一个复合哈希分区”章节讨论)和合并两个复合哈希分区,在属性的继承方面是不一样的。当一个分区被分割时,新的分区可以继承原分区的属性,因为只有一个父节点。但是,当合并分区时,必须继承表级别属性。
对于间隔哈希分区表,你只能合并两个相邻的间隔分区,或者时最高范围分区和第一个间隔分区。如“合并间隔分区”所述,当你在间隔哈希分区表合并分区时,转换点时会移动的。
下面的例子合并了两个范围哈希分区:
点击(此处)折叠或打开
合并复合列表分区
你可以在分区级别合并分区,也可以在列表子分区级别合并子分区。
在一个复合列表分区表中合并分区在复合列表分区表中合并分区如前面所论述的“合并范围分区”。但是,当你合并两个复合列表分区时,生成的新分区将继承子分区模版的子分区描述,前提是该模版存在。如果不存在子分区模版,,那么将为新分区创建一个默认子分区。
对于间隔哈希分区表,你只能合并两个相邻的间隔分区,或者时最高范围分区和第一个间隔分区。如“合并间隔分区”所述,当你在间隔哈希分区表合并分区时,转换点时会移动的。
下面的语句合并了范围列表分区表stripe_regional_sales的两个分区。该表存在一个子分区模版。
新生成分区的数据由两个分区的数据组成。但是,可能存在数据库返回错误的情况。这个之所以会发生,可能是因为当同时满足下列条件时,数据可能会映射到新分区之外:
合并后子分区的一些值可能并不属于子分区模版。
子分区模版不包含默认分区定义。
我们可以通过在默认子分区模版中指定一个默认分区来消除这个错误条件。
在一个复合列表分区表中合并子分区你可以合并同一分区中的任意两个列表子分区的内容。由此生成的子分区值列表描述包括所有被合并分区的值。
下面的语句合并了范围列表分区表的两个子分区,并将新生成的子分区保存到表空间ts4:
原始的两个分区的值列表如下:
子分区q1_1999_northwest被描述为('WA','OR')
子分区q1_1999_southwest被描述为('AZ','NM','UT')
新生成子分区的值列表由上述两个子分区值列表的合集构成:
子分区q1_1999_west被描述为('WA','OR','AZ','NM','UT')
新生成子分区的存储表空间以及子分区属性都由分区级别的默认属性决定,除非你显式地指定。
如果任何现有地子分区名称被重复使用,那么新生成子分区将会继承名称被重复使用子分区的属性。
合并复合范围分区你可以在区级别合并分区,也可以在范围子分区级别合并子分区。
在一个复合范围分区表中合并分区
InnoDBBufferPool reduces disk I/O by caching data and indexing pages, improving database performance. Its working principle includes: 1. Data reading: Read data from BufferPool; 2. Data writing: After modifying the data, write to BufferPool and refresh it to disk regularly; 3. Cache management: Use the LRU algorithm to manage cache pages; 4. Reading mechanism: Load adjacent data pages in advance. By sizing the BufferPool and using multiple instances, database performance can be optimized.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

MySQL is worth learning because it is a powerful open source database management system suitable for data storage, management and analysis. 1) MySQL is a relational database that uses SQL to operate data and is suitable for structured data management. 2) The SQL language is the key to interacting with MySQL and supports CRUD operations. 3) The working principle of MySQL includes client/server architecture, storage engine and query optimizer. 4) Basic usage includes creating databases and tables, and advanced usage involves joining tables using JOIN. 5) Common errors include syntax errors and permission issues, and debugging skills include checking syntax and using EXPLAIN commands. 6) Performance optimization involves the use of indexes, optimization of SQL statements and regular maintenance of databases.

MySQL is suitable for beginners to learn database skills. 1. Install MySQL server and client tools. 2. Understand basic SQL queries, such as SELECT. 3. Master data operations: create tables, insert, update, and delete data. 4. Learn advanced skills: subquery and window functions. 5. Debugging and optimization: Check syntax, use indexes, avoid SELECT*, and use LIMIT.

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.

MySQL is an open source relational database management system that is widely used in Web development. Its key features include: 1. Supports multiple storage engines, such as InnoDB and MyISAM, suitable for different scenarios; 2. Provides master-slave replication functions to facilitate load balancing and data backup; 3. Improve query efficiency through query optimization and index use.

SQL is used to interact with MySQL database to realize data addition, deletion, modification, inspection and database design. 1) SQL performs data operations through SELECT, INSERT, UPDATE, DELETE statements; 2) Use CREATE, ALTER, DROP statements for database design and management; 3) Complex queries and data analysis are implemented through SQL to improve business decision-making efficiency.

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA


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

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Atom editor mac version download
The most popular open source editor

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Zend Studio 13.0.1
Powerful PHP integrated development environment