A method, apparatus, device, and storage medium for redefining
By using materialized view logs and replay mechanisms, and leveraging intermediate tables and materialized view auxiliary tables for table redefinition, the service interruption problem caused by blocking was resolved, enabling online redefinition and modification of partitioned tables.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHANGHAI DAMENG DATABASE
- Filing Date
- 2022-09-01
- Publication Date
- 2026-05-12
AI Technical Summary
Existing technologies require locking the original table throughout the redefinition process, preventing the table from providing services normally and failing to support special modification operations such as converting a regular table into a partitioned table.
By creating materialized view logs and a materialized view replay mechanism, table redefinition is performed using intermediate tables and materialized view auxiliary tables, reducing locking time and supporting the modification of ordinary tables into partitioned tables.
It reduces the time that external services cannot be provided during table definition modifications and supports special modification operations, such as changing a regular table into a partitioned table.
Smart Images

Figure CN115438231B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a redefinition method, apparatus, device and storage medium. Background Technology
[0002] In practical applications, it is often necessary to change the definition of a table.
[0003] Simple table definition modifications, such as adding or deleting columns, can be achieved using specific table modification statements provided by the database. However, for unsupported modification operations, such as converting a regular table to a partitioned table, a series of steps are required: creating a new partitioned table, transferring data (inserting data from the original regular table into the new partitioned table), deleting the original table, and renaming the new table to the original table's name.
[0004] Furthermore, whether it's directly modifying the table or creating a new table and then transferring the data, both methods require locking the original table throughout the process. The table cannot provide services to the outside world until the modification is complete. Summary of the Invention
[0005] This invention provides a redefinition method, apparatus, device, and storage medium that redefines tables based on materialized view logs and materialized view replay mechanisms. This reduces the time that external services cannot be provided during definition modification and also supports special modification operations such as changing ordinary tables into partitioned tables.
[0006] According to one aspect of the present invention, a redefinition method is provided, comprising:
[0007] Create a materialized view log based on the original table;
[0008] An intermediate table is created based on the target attribute information corresponding to the original table;
[0009] A first materialized view is created based on the original table and the intermediate table, wherein the intermediate table is a materialized view auxiliary table of the first materialized view;
[0010] Refresh the first materialized view and swap the names of the refreshed intermediate table and the original table.
[0011] According to another aspect of the present invention, a redefinition device is provided, the redefinition device comprising:
[0012] The first creation module is used to create materialized view logs based on the original table;
[0013] The second creation module is used to create an intermediate table based on the target attribute information corresponding to the original table.
[0014] The third creation module is used to create a first materialized view based on the original table and the intermediate table, wherein the intermediate table is a materialized view auxiliary table of the first materialized view;
[0015] The refresh module is used to refresh the first materialized view and swap the name of the refreshed intermediate table with the name of the original table.
[0016] Furthermore, the first creation module is specifically used for:
[0017] Retrieve the initial attribute information of the original table;
[0018] If the original table is determined to support online redefinition based on its initial attribute information, then a materialized view log is created based on the original table.
[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 redefinition 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 redefinition method described in any embodiment of the present invention.
[0024] This invention, through the following embodiments, creates a materialized view log based on the original table; creates an intermediate table based on the target attribute information corresponding to the original table; creates a first materialized view based on the original table and the intermediate table, wherein the intermediate table is a materialized view auxiliary table for the first materialized view; refreshes the first materialized view and swaps the names of the refreshed intermediate table and the original table. This solves the problem of locking the original table throughout the redefinition process, preventing the table from providing services normally until the modification is complete. It reduces the time that services cannot be provided during the definition modification period and also supports special modification operations such as changing ordinary tables into partitioned tables.
[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 schematic diagram illustrating the refresh of a materialized view in an embodiment of the present invention;
[0028] Figure 2 This is a flowchart of a redefinition method in an embodiment of the present invention;
[0029] Figure 3 This is a flowchart of another redefinition method in an embodiment of the present invention;
[0030] Figure 4 This is a schematic diagram of the structure of a redefinition 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 of the present invention. 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] This invention redefines tables based on materialized view logs and a materialized view replay mechanism. It's important to note that a materialized view is a database object that includes a query result, and its data is stored in a materialized view auxiliary table. All access to materialized view data ultimately translates into access to the materialized view auxiliary table. When data in the base table changes, the data stored in the materialized view auxiliary table becomes outdated, and users can synchronize the data by refreshing it.
[0036] Materialized view principle: When a materialized view is created, the database system generates two objects: a materialized view and a materialized view helper table. The former is an empty table with no data, while the latter is used to store the actual data queried by the view.
[0037] If the fast refresh option was selected when creating the materialized view, then you will need to manually create N auxiliary tables named "Materialized View Logs," where N is the number of base tables involved in the query in the materialized view definition statement. Each base table involved in the materialized view corresponds to one materialized view log.
[0038] like Figure 1 As shown, a materialized view physically stores the query results of a view in a materialized view auxiliary table. Queries on a materialized view are transformed into queries on this auxiliary table. Data in a materialized view is not real-time and requires a refresh operation to update.
[0039] Materialized view refreshes are categorized into two types: 1. Full refresh and 2. Quick refresh. You must choose one of these two. A full refresh clears all data stored in the original materialized view auxiliary table, re-executes the view query, and stores the results back in the materialized view auxiliary table. A quick refresh, after a full refresh, updates the materialized view data based on changes in the base tables during that period. This data change information is recorded in another auxiliary table called the materialized view log (if the materialized view involves queries on multiple base tables, a quick refresh operation requires a corresponding materialized view log for each table). The materialized view log records information such as the type and value of data changes in the base tables, and the time of the last refresh. This information allows the latest data to be reconstructed in the materialized view auxiliary table.
[0040] Figure 2 This is a flowchart of a redefinition method provided by an embodiment of the present invention. This embodiment is applicable to the case of redefining a table. The method can be executed by the redefinition device in this embodiment of the present invention, which can be implemented in software and / or hardware, such as... Figure 2 As shown, the method specifically includes the following steps:
[0041] S210, Create a materialized view log based on the original table.
[0042] It should be noted that creating a materialized view log is the basis for refreshing. The materialized view log can be created based on the creation function. This embodiment of the invention does not limit the specific method of creating the materialized view log.
[0043] S220, Create an intermediate table based on the target attribute information corresponding to the original table.
[0044] The target attribute information is the attribute information obtained by modifying the initial attribute information corresponding to the original table according to the redefinition content.
[0045] Specifically, the method for creating an intermediate table based on the target attribute information corresponding to the original table can be as follows: determine the target attribute information corresponding to the original table based on the redefined content and the initial attribute information corresponding to the original table, and create an intermediate table based on the target attribute information corresponding to the original table.
[0046] It should be noted that the original table and the intermediate table can have the same structure or different structures.
[0047] S230, create a first materialized view based on the original table and the intermediate table, wherein the intermediate table is a materialized view auxiliary table of the first materialized view.
[0048] Specifically, the method for creating a first materialized view based on the original table and the intermediate table can be as follows: generate a query instruction based on the mapping relationship between the original table and the intermediate table input by the user, and create the first materialized view based on the query instruction. Alternatively, the method can be as follows: generate a query instruction based on a pre-stored mapping relationship between the original table and the intermediate table, and create the first materialized view based on the query instruction. Furthermore, the method can be as follows: if the mapping relationship between the original table and the intermediate table input by the user is not obtained, generate a query instruction based on a pre-stored mapping relationship between the original table and the intermediate table, and create the first materialized view based on the query instruction.
[0049] Specifically, an intermediate table is designated as the auxiliary table for the materialized view of the first materialized view.
[0050] S240, refresh the first materialized view and swap the name of the refreshed intermediate table with the name of the original table.
[0051] Specifically, the method for refreshing the first materialized view can be as follows: first, perform a full refresh on the first materialized view, then perform at least one quick refresh on the first materialized view, and lock the original table before the last quick refresh to obtain the refreshed intermediate table.
[0052] Specifically, the method to swap the name of the refreshed intermediate table and the name of the original table can be: replace the name of the refreshed intermediate table with the name of the original table, and replace the name of the original table with the name of the intermediate table.
[0053] Optionally, create a materialized view log based on the original table, including:
[0054] Retrieve the initial attribute information of the original table;
[0055] If the original table is determined to support online redefinition based on its initial attribute information, then a materialized view log is created based on the original table.
[0056] The initial attribute information includes: the type information of the original table, and may also include at least one of: the size of the original table and the format information of the original table.
[0057] Specifically, the method for determining whether the original table supports online redefinition based on the initial attribute information of the original table can be as follows: determine the type of the original table based on the initial attribute information of the original table; if the type of the original table is the first type, then the original table is determined to support online definition; if the type of the original table is the second type, then the original table is determined not to support online definition. It should be noted that the second type can be a temporary table, a system-created table, etc., and this embodiment of the present invention does not impose any restrictions on this.
[0058] Optionally, if the original table is determined to support online redefinition based on its initial attribute information, a materialized view log is created based on the original table, including:
[0059] If the original table is determined to support online redefinition based on its initial attribute information, then the original table is locked.
[0060] Create a materialized view log based on the original table, and then unlock the original table after creating the materialized view log.
[0061] It should be noted that the original table needs to be locked during the creation of the materialized view log to prevent inaccuracies in the materialized view log due to changes to the original table.
[0062] Specifically, the original table can be locked by applying an X lock. An X lock stands for Exclusive Lock. As its name suggests, an X lock is exclusive; that is, a write lock will block other X locks and S locks.
[0063] Optionally, a first materialized view is created based on the original table and the intermediate table, including:
[0064] Obtain the mapping relationship between the original table and the intermediate table;
[0065] Generate query instructions based on the mapping relationship between the original table and the intermediate table;
[0066] Create a first materialized view based on the query command.
[0067] Specifically, the mapping relationship between the source table and the intermediate table can be obtained in several ways: First, obtain the mapping relationship between the source table and the intermediate table as input by the user. Second, obtain the mapping relationship between the source table and the intermediate table as pre-defined by the system. Third, if the mapping relationship between the source table and the intermediate table as input by the user is not obtained, obtain the mapping relationship pre-defined by the system.
[0068] Specifically, the method for creating the first materialized view according to the query instruction can be as follows: determine the query definition according to the query instruction, and create the first materialized view according to the query definition of the materialized view.
[0069] Optionally, the first materialized view is refreshed, and the names of the refreshed intermediate table and the original table are swapped, including:
[0070] After refreshing the first materialized view based on the first refresh mode, the original table is locked;
[0071] The first materialized view is refreshed based on the second refresh mode, and the names of the refreshed intermediate table and the original table are swapped, and the original table is unlocked.
[0072] Optionally, the first materialized view is refreshed, and the names of the refreshed intermediate table and the original table are swapped, including:
[0073] After refreshing the first materialized view based on the first refresh mode, refresh the first materialized view a preset number of times based on the second refresh mode;
[0074] Lock the original table, refresh the first materialized view based on the second refresh mode, swap the name of the refreshed intermediate table with the name of the original table, and unlock the original table.
[0075] It should be noted that you can perform a full refresh, lock the original table, and then perform a final quick refresh; or you can perform a full refresh, then perform multiple quick refreshes, and lock the original table before the last quick refresh.
[0076] The first refresh mode is a full refresh, and the second refresh mode is a quick refresh. A full refresh of the first materialized view involves clearing the data stored in the materialized view's auxiliary table, re-executing the view query, and storing the results back in the auxiliary table. A full refresh of the second materialized view involves updating the data in the materialized view based on changes to the base table after the full refresh. This data change information is recorded in another auxiliary table called the materialized view log. The materialized view log records information such as the type and value of the changes to the base table, and the time of the last refresh. Using this information, the latest data can be reconstructed in the materialized view's auxiliary table.
[0077] It should be noted that if the original table before the redefinition is no longer needed, the user can manually delete the current intermediate table Tm (the original table before the redefinition).
[0078] Optionally, a query instruction is generated based on the mapping relationship between the original table and the intermediate table, including:
[0079] If the column types in the original table are determined to be compatible with the corresponding columns in the intermediate table based on the mapping relationship between the original table and the intermediate table, then a query instruction is generated based on the mapping relationship between the original table and the intermediate table.
[0080] Specifically, if the mapping relationship between the original table and the intermediate table input by the user is not obtained, the mapping relationship between the original table and the intermediate table pre-set by the system is obtained. If the column types of the columns in the original table are compatible with the corresponding columns in the intermediate table, a query instruction is generated based on the mapping relationship between the original table and the intermediate table.
[0081] Specifically, the system's pre-defined mapping relationship between the original table and the intermediate table generates query commands that require the column types of the corresponding columns in the original table to be compatible with those in the intermediate table. The structures of the original and intermediate tables can be the same or different, and the number and names of the columns can also differ, but the column types must be compatible. For example, if the original table is Ty(A INT, B INT, C CHAR), and the original table is modified by deleting column C and renaming columns A and B to C1 and C2 respectively, with the data types changed to BIGINT and TINYINT, then the intermediate table can be defined as Tm(C1 BIGINT, C2 TINYINT). The column correspondences are also diverse, such as C1 = 3 * A, C2 = B + 1000, etc.
[0082] It should be noted that if the mapping relationship between the original table and the intermediate table input by the user is obtained, the query instruction will be generated directly based on the mapping relationship between the original table and the intermediate table.
[0083] In a specific example, such as Figure 3As shown, based on the materialized view log and the materialized view replay mechanism, this embodiment of the invention implements a series of methods for redefinition, enabling online table redefinition with the help of system functions. The specific steps are as follows:
[0084] 1. Call the judgment function to determine whether the original table (named Ty) supports online redefinition. If supported, proceed to step 2; otherwise (temporary tables and other special tables do not support redefinition), terminate directly.
[0085] 2. The user creates an intermediate table (named Tm) according to the desired definition. Tm and Ty can have the same or different structures. The definition of Tm is the redefined table definition.
[0086] 3. Establish the relationship between the original table Ty and the intermediate table Tm. In this embodiment of the invention, this relationship is established through materialized views. Specifically, this includes: creating a materialized view log (named Tlog) on the original table, creating an auxiliary materialized view (named Vy) using a query on the original table, and designating Tm as the auxiliary table for the materialized view of Vy. The columns of Tm correspond to the query items defined in the materialized view. Thus, Ty, Vy, Tm, and Tlog constitute the four objects required for the materialized view to activate the fast refresh function. A full refresh is performed, storing the data of the materialized view Vy on the intermediate table Tm. The purpose of this is that after the full refresh is completed, the fast refresh mechanism of the materialized view can be flexibly utilized in subsequent steps. When this materialized view is fast refreshed, the changes in the data on the original table will be promptly reproduced on the intermediate table Tm.
[0087] 4. Call the synchronization function to synchronize the data. This essentially involves a quick refresh of the materialized view created in step 3. Depending on the actual needs, several quick refreshes can be performed when the original table data changes frequently; if the original table data remains unchanged, this step can be skipped.
[0088] 5. Call the termination function to complete the redefinition. This process will acquire an X lock on the original table Ty, at which point the data on the table will no longer change. Then, a quick refresh of the materialized view completes the final data synchronization. Afterward, the table names of the two tables Ty and Tm are swapped, the X lock on Ty is released, and the redefinition is complete.
[0089] In this embodiment of the invention, during a redefinition process, the original table only needs to be locked during the creation of the materialized view log and before the last fast update. Most of the data synchronization time does not require locking the original table, reducing the time that the table cannot provide external services during table definition modification. It can also support special modification operations such as changing a regular table into a partitioned table.
[0090] The technical solution of this embodiment solves the problem of locking the original table throughout the redefinition process, preventing the table from providing services normally until the modification is completed. This reduces the time that the table cannot provide services during the definition modification period and also supports special modification operations such as changing ordinary tables to partitioned tables.
[0091] Example 2
[0092] Figure 4 This is a schematic diagram of a table redefinition device provided in an embodiment of the present invention. This embodiment is applicable to situations involving table redefinition. The device can be implemented using software and / or hardware, and can be integrated into any device that provides redefinition functionality, such as… Figure 4 As shown, the redefinition device specifically includes: a first creation module 410, a second creation module 420, a third creation module 430, and a refresh module 440.
[0093] The first creation module is used to create materialized view logs based on the original table.
[0094] The second creation module is used to create an intermediate table based on the target attribute information corresponding to the original table.
[0095] The third creation module is used to create a first materialized view based on the original table and the intermediate table, wherein the intermediate table is a materialized view auxiliary table of the first materialized view;
[0096] The refresh module is used to refresh the first materialized view and swap the name of the refreshed intermediate table with the name of the original table.
[0097] Optionally, the first creation module is specifically used for:
[0098] Retrieve the initial attribute information of the original table;
[0099] If the original table is determined to support online redefinition based on its initial attribute information, then a materialized view log is created based on the original table.
[0100] 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.
[0101] The technical solution of this embodiment solves the problem of locking the original table throughout the redefinition process, preventing the table from providing services normally until the modification is completed. This reduces the time that the table cannot provide services during the definition modification period and also supports special modification operations such as changing ordinary tables to partitioned tables.
[0102] Example 3
[0103] 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.
[0104] 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.
[0105] 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.
[0106] 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 redefining methods.
[0107] In some embodiments, the redefinition 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 redefinition method described above may be performed. Alternatively, in other embodiments, processor 11 may be configured to perform the redefinition method by any other suitable means (e.g., by means of firmware).
[0108] 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.
[0109] 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.
[0110] 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.
[0111] 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).
[0112] 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.
[0113] 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.
[0114] 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.
[0115] 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 redefinition method, characterized in that, include: A materialized view log is created based on the original table; wherein the original table is locked during the creation of the materialized view log, and the lock on the original table is released after the creation is completed; An intermediate table is created based on the target attribute information corresponding to the original table; wherein, the target attribute information is the attribute information obtained after modifying the initial attribute information of the original table according to the redefinition content; A first materialized view is created based on the original table and the intermediate table, wherein the intermediate table is a materialized view auxiliary table of the first materialized view; Refresh the first materialized view and swap the names of the refreshed intermediate table and the original table. The step of refreshing the first materialized view and exchanging the name of the refreshed intermediate table with the name of the original table includes: first performing a full refresh on the first materialized view, then performing at least one quick refresh on the first materialized view, and locking the original table before the last quick refresh to obtain the refreshed intermediate table; replacing the name of the refreshed intermediate table with the name of the original table, and unlocking the original table. Creating a first materialized view based on the original table and the intermediate table includes: Obtain the mapping relationship between the original table and the intermediate table; If the column types of the columns in the original table are determined to be compatible with the corresponding columns in the intermediate table based on the mapping relationship between the original table and the intermediate table, then a query instruction is generated based on the mapping relationship between the original table and the intermediate table. The query definition is determined based on the query instruction, and a first materialized view is created based on the query definition.
2. The method according to claim 1, characterized in that, Create a materialized view log based on the original table, including: Retrieve the initial attribute information of the original table; If the original table is determined to support online redefinition based on its initial attribute information, then a materialized view log is created based on the original table.
3. The method according to claim 2, characterized in that, If the original table is determined to support online redefinition based on its initial attribute information, then a materialized view log is created based on the original table, including: If the original table is determined to support online redefinition based on its initial attribute information, then the original table is locked. Create a materialized view log based on the original table, and then unlock the original table after creating the materialized view log.
4. A redefinition device, characterized in that, include: The first creation module is used to create a materialized view log based on the original table; wherein, the original table is locked during the creation of the materialized view log, and the lock on the original table is released after the creation is completed; The second creation module is used to create an intermediate table based on the target attribute information corresponding to the original table; wherein, the target attribute information is the attribute information obtained after modifying the initial attribute information of the original table according to the redefinition content; The third creation module is used to create a first materialized view based on the original table and the intermediate table, wherein the intermediate table is a materialized view auxiliary table of the first materialized view; The refresh module is used to refresh the first materialized view and swap the name of the refreshed intermediate table with the name of the original table. The refresh module is specifically used to first perform a full refresh on the first materialized view, then perform at least one fast refresh on the first materialized view, and lock the original table before the last fast refresh to obtain the refreshed intermediate table; replace the name of the refreshed intermediate table with the name of the original table, and unlock the original table. The third creation module is specifically used to obtain the mapping relationship between the original table and the intermediate table; if it is determined that the column types of the columns in the original table are compatible with the corresponding columns in the intermediate table based on the mapping relationship between the original table and the intermediate table, then a query instruction is generated based on the mapping relationship between the original table and the intermediate table; a query definition is determined based on the query instruction, and a first materialized view is created based on the query definition.
5. The apparatus according to claim 4, characterized in that, The first creation module is specifically used for: Retrieve the initial attribute information of the original table; If the original table is determined to support online redefinition based on its initial attribute information, then a materialized view log is created based on the original table.
6. 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, the computer program being executed by the at least one processor to enable the at least one processor to perform the redefinition method according to any one of claims 1-3.
7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that cause a processor to execute the redefinition method according to any one of claims 1-3.