A table space moving method, device, equipment and storage medium
By constructing an intermediate table identical to the target table for data dictionary exchange, the problems of low efficiency and high complexity in tablespace movement in existing technologies are solved, achieving efficient tablespace movement and data migration.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHANGHAI DAMENG DATABASE
- Filing Date
- 2022-10-19
- Publication Date
- 2026-05-08
AI Technical Summary
Existing technologies have problems such as query difficulties due to changes in new object IDs, UNIQUE constraint conflicts, and high data transfer complexity when moving database tables or partitions.
By constructing an intermediate table identical to the target table, exchanging data dictionaries, and migrating the data to the target tablespace, the data dictionary exchange between the target table and the intermediate table is achieved.
It improves the efficiency of tablespace movement, reduces movement complexity, and ensures the continuity of data queries and data integrity.
Smart Images

Figure CN115510068B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of database technology, and in particular to a method, apparatus, device and storage medium for moving tablespaces. Background Technology
[0002] In a database system, data is stored in data tables, and data tables are stored in tablespaces.
[0003] In real-world applications, data management sometimes necessitates moving an entire table or a partition of a table to a designated tablespace.
[0004] In existing technologies, the common approach is to create a new table or add a new partition in a new tablespace, and then transfer the data to the new table or partition. However, this approach has the following problems:
[0005] Creating a new object directly cannot result in the same name as the original object; a renaming operation must be performed subsequently.
[0006] The ID of the newly created object has changed. If you query the system table using the ID as a condition, you will not be able to see the original data table.
[0007] If it is a moving partition, when creating a new partition to transfer data, inserting data from the original partition into the new partition may trigger a UNIQUE constraint conflict on the main table. In this case, if you want to transfer data normally, you need to perform an additional data query and insertion operation using an intermediate table. Summary of the Invention
[0008] This invention provides a tablespace movement method, apparatus, device, and storage medium. By moving tablespaces based on data dictionary exchange, the above-mentioned problems can be solved, thereby improving the efficiency of tablespace movement and reducing its complexity.
[0009] According to one aspect of the present invention, a method for moving a tablespace is provided, comprising:
[0010] Obtain the tablespace move statement input by the user, wherein the tablespace statement is a database statement that moves the target table to the target tablespace;
[0011] An intermediate table is constructed in the target tablespace based on the target table, wherein the intermediate table has the same definition as the dependent objects of the target table, and the intermediate table has the same structure as the target table;
[0012] Exchange the data dictionary between the target table and the intermediate table;
[0013] Migrate the data from the intermediate table after the data dictionary exchange to the target table after the data dictionary exchange.
[0014] According to another aspect of the present invention, a table space moving device is provided, the table space moving device comprising:
[0015] The acquisition module is used to acquire the tablespace movement statement input by the user, wherein the tablespace statement is a database statement that moves the target table to the target tablespace;
[0016] A construction module is used to construct an intermediate table in the target tablespace based on the target table, wherein the intermediate table has the same definition as the dependent objects of the target table, and the intermediate table has the same structure as the target table;
[0017] An exchange module is used to exchange data dictionaries between the target table and the intermediate table.
[0018] The migration module is used to migrate data from the intermediate table after data dictionary exchange to the target table after data dictionary exchange.
[0019] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0020] At least one processor; and
[0021] A memory communicatively connected to the at least one processor; wherein,
[0022] The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the tablespace movement method according to any embodiment of the present invention.
[0023] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions for causing a processor to execute and implement the tablespace movement method according to any embodiment of the present invention.
[0024] This invention improves the efficiency and reduces the complexity of tablespace movement by acquiring a user-inputted tablespace movement statement, wherein the tablespace movement statement is a database statement that moves a target table to a target tablespace; constructing an intermediate table in the target tablespace based on the target table, wherein the intermediate table has the same definition of dependent objects as the target table and the same structure as the target table; exchanging data dictionaries between the target table and the intermediate table; and migrating the data from the intermediate table after data dictionary exchange to the target table after data dictionary exchange.
[0025] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description
[0026] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0027] Figure 1 This is a flowchart of a tablespace movement method according to an embodiment of the present invention;
[0028] Figure 2 This is a schematic diagram illustrating the construction of an intermediate table in an embodiment of the present invention;
[0029] Figure 3 This is a diagram illustrating the data dictionary exchange between the target table and the intermediate table in an embodiment of the present invention;
[0030] Figure 4 This is a schematic diagram of the structure of a surface space moving device according to an embodiment of the present invention;
[0031] Figure 5 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present invention. Detailed Implementation
[0032] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0033] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0034] Example 1
[0035] Figure 1 This is a flowchart illustrating a tablespace movement method provided in an embodiment of the present invention. This embodiment is applicable to tablespace movement scenarios. The method can be executed by the tablespace movement device in this embodiment, which can be implemented in software and / or hardware, such as... Figure 1 As shown, the method specifically includes the following steps:
[0036] S110, retrieve the tablespace move statement input by the user.
[0037] The tablespace statement is a database statement that moves the target table to the target tablespace.
[0038] The target table can be a partitioned table or a non-partitioned table. The target tablespace is used to store the target table.
[0039] S120, construct an intermediate table in the target tablespace according to the target table.
[0040] The intermediate table shares the same definitions for its dependent objects as the target table. For example, the intermediate table may have the same definitions for its index objects, constraint objects, and trigger objects as the target table. The intermediate table and the target table also share the same structure.
[0041] The intermediate table has the same structure as the target table. For example, if the target table is a partitioned table, then the intermediate table is a partitioned table; if the target table is not a partitioned table, then the intermediate table is not a partitioned table.
[0042] The intermediate table and the target table have identical definitions for their index objects, constraint objects, and trigger objects. In other words, if the target table has index objects, constraint objects, and trigger objects, then the intermediate table also has index objects, constraint objects, and trigger objects. Each index object, constraint object, and trigger object in the intermediate table corresponds one-to-one with the objects in the target table.
[0043] Specifically, the method for constructing intermediate tables in the target tablespace based on the target table can be as follows: If the target table includes a table to be moved, and the table to be moved has no sub-tables, then the intermediate tables are constructed based on the structure of the table to be moved and the definitions of its index objects, constraint objects, and trigger objects. Alternatively, if the target table includes a table to be moved and its sub-tables, then a first table corresponding to the table to be moved is constructed based on the structure of the table to be moved and the definitions of its index objects, constraint objects, and trigger objects; and a second table corresponding to the sub-tables of the table to be moved is constructed based on the structure of the sub-tables and the definitions of their index objects, constraint objects, and trigger objects. It should be noted that if the target table is a partitioned table, it may have many layers. In this case, it is necessary to obtain the intermediate tables corresponding to the partitioned tables, as well as the intermediate tables corresponding to each layer. For example, if the target table has three layers, then the intermediate tables also have three layers.
[0044] In a specific example, whether the created intermediate table is a regular table or a partitioned table depends on whether the target table includes sub-tables. Specifically, if the target table is a regular table (a non-partitioned table) or a leaf partition of a partitioned table, then the constructed intermediate table will also be a regular table. If the target table is an entire partitioned table or an intermediate partition of a partitioned table, then the constructed intermediate table will also be a partitioned table, with its partition type, partition columns, and partition range values consistent with the moved object. In addition to the table structure, the index objects, constraint objects, and trigger objects on the intermediate table should also correspond one-to-one with the objects on the target table.
[0045] S130, the target table and the intermediate table are exchanged using data dictionaries.
[0046] Database objects include tables, views, indexes, triggers, etc. Each database object contains two parts: dictionary information and data. The dictionary information is the metadata of the database object, which describes the database object. The database metadata is stored in system tables, and this metadata describes information such as the name, attributes, structure, and dependencies between database objects.
[0047] If the entire table is moved, all dictionary information related to that table needs to be exchanged. If a partition of a partitioned table is moved, only the dictionary information related to that partition needs to be exchanged. If indexes, constraints, triggers, etc., on a table are moved, only the dictionary information related to those indexes, constraints, triggers, etc., needs to be exchanged. The latter two types are referred to as partial metadata below because they exchange only a portion of the total dictionary information of the database object.
[0048] The following sections describe the exchange of data dictionaries when using indexes and index-organized tables.
[0049] For index objects, the index metadata describes information such as the index name, key, index type, root address of the index's data pages, and the parent object ID of the index.
[0050] Data dictionary exchange involves swapping partial metadata (only index-related metadata) between two database objects to allow one object to replace the other. For example, given tables T1 and T2, with index I1 on T1 and index I2 on T2, if we swap the names and parent object IDs of indexes I1 and I2 while keeping the root address information of the corresponding data pages unchanged, then after the swap, accessing index I1 in table T1 will return accessing the data page originally corresponding to index I2.
[0051] For index-organized tables, if all indexes on one table are swapped with the corresponding indexes on another table, then the data in those tables is essentially swapped. A single dictionary swap of all indexes on an entire table appears to be a swap of data and storage attributes between the two tables.
[0052] Specifically, the data dictionary exchange between the target table and the intermediate table can be performed as follows: If the target table includes a table to be moved and sub-tables of the table to be moved, and the intermediate table includes a first table corresponding to the table to be moved and a second table corresponding to the sub-tables of the table to be moved, then the data dictionary exchange is performed between the table to be moved and the first table; and the data dictionary exchange is performed between the sub-tables of the table to be moved and the second table. Alternatively, if the target table does not include sub-tables, then the indexes in the target table and the indexes in the intermediate table are exchanged using data dictionaries.
[0053] S140, migrate the data from the intermediate table after data dictionary exchange to the target table after data dictionary exchange.
[0054] Specifically, the method for migrating data from the intermediate table after data dictionary exchange to the target table after data dictionary exchange can be as follows: query the intermediate table after data dictionary exchange to obtain the query result; insert the query result into the target table after data dictionary exchange.
[0055] Optionally, constructing an intermediate table in the target tablespace based on the target table includes:
[0056] If both the target table and the target tablespace exist, and the type of the target table is not the target type, then an intermediate table is constructed in the target tablespace based on the target table.
[0057] It should be noted that after receiving the tablespace move statement input by the user, a validity check needs to be performed on the tablespace move statement. If the tablespace move statement does not support movement, an error should be reported and the process should exit. For example, if any of the following conditions are met, it can be determined that the tablespace move statement does not support movement:
[0058] The target table does not exist;
[0059] The target tablespace does not exist;
[0060] The target table type is target type.
[0061] The target type can be a preset table type. For example, if the target table is a system table or a temporary table, then the tablespace move statement is determined to be non-supported for moving.
[0062] Optionally, the target table includes: a table to be moved and a sub-table of the table to be moved, and the intermediate table includes: a first table corresponding to the table to be moved and a second table corresponding to the sub-table of the table to be moved;
[0063] The data dictionary is exchanged between the target table and the intermediate table, including:
[0064] Exchange the data dictionary between the table to be moved and the first table;
[0065] The data dictionary of the sub-table of the table to be moved and the second table are exchanged.
[0066] The first table is an intermediate table constructed based on the table to be moved, and the second table is an intermediate table constructed based on the sub-table of the table to be moved.
[0067] In a specific example, such as Figure 2 As shown, if the target table is partition table P2 of partition table T1, then intermediate tables are constructed based on table P2 and its sub-tables (tables S2 and S3). These intermediate tables include: table tmp, table S2_tmp, and table S3_tmp. Figure 3 As shown, the data dictionary of table P2 and table tmp is swapped, the data dictionary of table S2 and table S2_tmp is swapped, and the data dictionary of table S3 and table S3_tmp is swapped.
[0068] Optionally, the target table and the intermediate table are subjected to data dictionary exchange, including:
[0069] The indexes in the target table are exchanged with the indexes in the intermediate table using a data dictionary.
[0070] It should be noted that the method for exchanging the data dictionary of the indexes in the target table and the indexes in the intermediate table can be as follows: the names and parent object IDs of all indexes in the target table are exchanged with the names and parent object IDs of all indexes in the intermediate table, while the data page root address information corresponding to all indexes in the target table and the data page root address information corresponding to all indexes in the intermediate table remain unchanged.
[0071] Optionally, the indexes in the target table and the indexes in the intermediate table are exchanged using a data dictionary, including:
[0072] The name and parent object ID of the index in the target table are swapped with the name and parent object ID of the index in the intermediate table. The data page root address information corresponding to the index in the target table and the data page root address information corresponding to the index in the intermediate table remain unchanged.
[0073] In a specific example, if table P2 has indexes I1 and I2, and table tmp has indexes I3 and I4, then the names and parent object IDs of indexes I1 and I3 are swapped, while the corresponding data page and address information remain unchanged; similarly, the names and parent object IDs of indexes I2 and I4 are swapped, while the corresponding data page and address information remains unchanged. Similarly, if table S2 has indexes I5 and I6, and table S2_tmp has indexes I7 and I8, then the names and parent object IDs of indexes I5 and I7 are swapped, while the corresponding data page and address information remains unchanged; similarly, the names and parent object IDs of indexes I6 and I8 are swapped, while the corresponding data page and address information remains unchanged. If table S3 has indexes I9 and I10, and table S3_tmp has indexes I11 and I12, then swap the index names and parent object IDs of indexes I9 and I11, while keeping the corresponding data page and address information unchanged; swap the index names and parent object IDs of indexes I10 and I12, while keeping the corresponding data page and address information unchanged.
[0074] Optionally, data from the intermediate table after data dictionary exchange can be migrated to the target table after data dictionary exchange, including:
[0075] Query the intermediate table after the data dictionary exchange to obtain the query results;
[0076] The query results are then inserted into the target table after the data dictionary exchange.
[0077] It's important to note that after the data dictionary exchange in the previous step, all data in the target table becomes data belonging to the intermediate table, while the target table after the data dictionary exchange becomes an empty table in the target tablespace. At this point, performing a single query and insert from the intermediate table (after the data dictionary exchange) to the target table (after the data dictionary exchange) completes the data migration in the target tablespace.
[0078] Optional, also includes:
[0079] Delete the intermediate table after the data dictionary swap.
[0080] In a specific example, moving a table or a partition of a table to a designated tablespace in this embodiment of the invention includes the following steps:
[0081] Step 1. Perform a validity check on the user-input tablespace move statement. If the move is not supported, exit with an error message; otherwise, proceed to Step 2. Step 2. Construct an isomorphic intermediate table `tmp` in the target tablespace based on the target table. If creation fails due to insufficient memory or other reasons, exit with an error message; otherwise, proceed to Step 3. Step 3. Perform data dictionary swaps one by one between the target table and the corresponding objects in the intermediate table. Table names do not need to be swapped, as only the indexes are changed. If execution fails, exit with an error message; otherwise, proceed to Step 4. Step 4. Data move. Specifically, perform a query-insert operation from the intermediate table (after data dictionary swap) to the target table (after data dictionary swap), i.e., retrieve data from the intermediate table (after data dictionary swap) and insert it into the target table (after data dictionary swap). If execution fails, exit with an error message; otherwise, proceed to Step 5. Step 5. Delete the intermediate table `tmp` (after data dictionary swap), completing the migration.
[0082] The technical solution of this embodiment improves the efficiency of tablespace movement and reduces its complexity by acquiring a tablespace movement statement input by the user, wherein the tablespace statement is a database statement that moves a target table to a target tablespace; constructing an intermediate table in the target tablespace based on the target table, wherein the intermediate table and the target table have the same definitions of their dependent objects and the same structure; and exchanging data dictionaries between the target table and the intermediate table.
[0083] Example 2
[0084] Figure 4 This is a schematic diagram of a tablespace movement device provided in an embodiment of the present invention. This embodiment is applicable to tablespace movement applications. The device can be implemented using software and / or hardware, and can be integrated into any device that provides tablespace movement functionality, such as… Figure 4As shown, the tablespace moving device specifically includes: an acquisition module 210, a construction module 220, an exchange module 230, and a migration module 240.
[0085] The acquisition module is used to acquire the tablespace movement statement input by the user, wherein the tablespace statement is a database statement that moves the target table to the target tablespace.
[0086] A construction module is used to construct an intermediate table in the target tablespace based on the target table, wherein the definitions of the dependent objects of the intermediate table and the target table are the same, and the structure of the intermediate table and the target table are the same.
[0087] An exchange module is used to exchange data dictionaries between the target table and the intermediate table.
[0088] The migration module is used to migrate data from the intermediate table after data dictionary exchange to the target table after data dictionary exchange.
[0089] Optionally, the construction module is specifically used for:
[0090] If both the target table and the target tablespace exist, and the type of the target table is not the target type, then an intermediate table is constructed in the target tablespace based on the target table.
[0091] Optionally, the target table includes: a table to be moved and a sub-table of the table to be moved, and the intermediate table includes: a first table corresponding to the table to be moved and a second table corresponding to the sub-table of the table to be moved;
[0092] The switching module is specifically used for:
[0093] Exchange the data dictionary between the table to be moved and the first table;
[0094] The data dictionary of the sub-table of the table to be moved and the second table are exchanged.
[0095] Optionally, the switching module is specifically used for:
[0096] The indexes in the target table are exchanged with the indexes in the intermediate table using a data dictionary.
[0097] Optionally, the switching module is specifically used for:
[0098] The name and parent object ID of the index in the target table are swapped with the name and parent object ID of the index in the intermediate table. The data page root address information corresponding to the index in the target table and the data page root address information corresponding to the index in the intermediate table remain unchanged.
[0099] Optionally, the migration module is specifically used for:
[0100] Query the intermediate table after the data dictionary exchange to obtain the query results;
[0101] The query results are then inserted into the target table after the data dictionary exchange.
[0102] Optional, also includes:
[0103] The delete module is used to delete intermediate tables after data dictionary exchange.
[0104] The above-described products can perform the methods provided in any embodiment of the present invention, and have the corresponding functional modules and beneficial effects for performing the methods.
[0105] Example 3
[0106] Figure 5 A schematic diagram of an electronic device 10 that can be used to implement embodiments of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0107] like Figure 5 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 may also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0108] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0109] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as the tablespace movement method.
[0110] In some embodiments, the tablespace movement method may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or mounted on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the tablespace movement method described above may be performed. Alternatively, in other embodiments, processor 11 may be configured to perform the tablespace movement method by any other suitable means (e.g., by means of firmware).
[0111] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0112] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0113] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0114] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0115] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or computing systems that include middleware components (e.g., application servers), or computing systems that include frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.
[0116] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.
[0117] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.
[0118] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A method for moving objects within a tablespace, characterized in that, include: Obtain the tablespace move statement input by the user, wherein the tablespace statement is a database statement that moves the target table to the target tablespace; An intermediate table is constructed in the target tablespace based on the target table, wherein the intermediate table has the same definition as the dependent objects of the target table, and the intermediate table has the same structure as the target table; Exchange the data dictionary between the target table and the intermediate table; Migrate the data from the intermediate table after data dictionary exchange to the target table after data dictionary exchange; The step of exchanging data dictionaries between the target table and the intermediate table includes: The indexes in the target table and the indexes in the intermediate table are exchanged using a data dictionary. The step of exchanging the data dictionary between the indexes in the target table and the indexes in the intermediate table includes: The names and parent object IDs of the indexes in the target table are exchanged with the names and parent object IDs of the indexes in the intermediate table. The root address information of the data page corresponding to the index in the target table and the root address information of the data page corresponding to the index in the intermediate table remain unchanged. During the data dictionary exchange process, the name of the target table remains unchanged.
2. The method according to claim 1, characterized in that, Constructing an intermediate table in the target tablespace based on the target table includes: If both the target table and the target tablespace exist, and the type of the target table is not the target type, then an intermediate table is constructed in the target tablespace based on the target table.
3. The method according to claim 1, characterized in that, The target table includes: a table to be moved and a sub-table of the table to be moved; the intermediate table includes: a first table corresponding to the table to be moved and a second table corresponding to the sub-table of the table to be moved. The data dictionary is exchanged between the target table and the intermediate table, including: Exchange the data dictionary between the table to be moved and the first table; The data dictionary of the sub-table of the table to be moved and the second table are exchanged.
4. The method according to claim 1, characterized in that, Migrate data from the intermediate table after data dictionary exchange to the target table after data dictionary exchange, including: Query the intermediate table after the data dictionary exchange to obtain the query results; The query results are then inserted into the target table after the data dictionary exchange.
5. The method according to claim 1, characterized in that, Also includes: Delete the intermediate table after the data dictionary swap.
6. A surface space moving device, characterized in that, include: The acquisition module is used to acquire the tablespace movement statement input by the user, wherein the tablespace statement is a database statement that moves the target table to the target tablespace; A construction module is used to construct an intermediate table in the target tablespace based on the target table, wherein the intermediate table has the same definition as the dependent objects of the target table, and the intermediate table has the same structure as the target table; An exchange module is used to exchange data dictionaries between the target table and the intermediate table. The migration module is used to migrate data from the intermediate table after data dictionary exchange to the target table after data dictionary exchange. The switching module is specifically used for: The indexes in the target table and the indexes in the intermediate table are exchanged using a data dictionary. The step of exchanging the data dictionary between the indexes in the target table and the indexes in the intermediate table includes: The names and parent object IDs of the indexes in the target table are exchanged with the names and parent object IDs of the indexes in the intermediate table. The root address information of the data page corresponding to the index in the target table and the root address information of the data page corresponding to the index in the intermediate table remain unchanged. During the data dictionary exchange process, the name of the target table remains unchanged.
7. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor to enable the at least one processor to perform the tablespace movement method according to any one of claims 1-5.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that cause a processor to execute the tablespace movement method according to any one of claims 1-5.
Citation Information
Patent Citations
Data migration method and device, computer equipment and storage medium
CN110413593A