Database table space change method and apparatus
Patent Information
- Application Number
- CN202211445771.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-18
- Publication Date
- 2026-09-15
- Estimated Expiration
- 2042-11-18
AI Technical Summary
[0003]现有技术中,为满足上述要求,表空间的变更操作通常需要人工进行变更操作前的条件评估并实施变更步骤,人工操作贯穿整个变更流程,使整个变更过程变得繁琐,效率低,没有自动实施变更操作并识别操作风险的能力
[0046]In the embodiments provided by this invention, during the process of changing a database tablespace, a set of change parameters and the change type input by the user are obtained. When the set of change parameters meets the preset verification conditions, a preset tablespace change script is executed to perform the operation of creating or expanding the tablespace according to the change type. If the change type is to create a new tablespace, and the tablespace corresponding to the set of change parameters does not exist and the available disk space value corresponding to the disk parameters is not less than the expected tablespace value in the set of change parameters, then according to the expected tablespace value, each data file corresponding to the tablespace parameters is added to the disk corresponding to the disk parameters to create the tablespace corresponding to the tablespace parameters. If the change type is to expand the tablespace, and the tablespace corresponding to the set of change parameters exists and the available disk space value is not less than the expanded tablespace value in the set of change parameters, then according to the expanded tablespace value, the space value of each data file corresponding to the tablespace parameters is increased, or after the space value of each data file corresponding to the tablespace parameters has reached the preset file space threshold, one or more data files are added to the disk to expand the tablespace.
Smart Images

Figure CN115905230B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of databases, and in particular to a method and apparatus for modifying database tablespaces. Background Technology
[0002] With the development of information technology, various industries rely heavily on databases for data access and processing in their operations. Databases also require continuous maintenance and updates to adapt to changing business needs and ensure timely data retrieval during business processes. Creating and expanding database tablespaces are common operations during database maintenance. To ensure database security, risk monitoring is necessary during these operations to mitigate the risk of failures due to insufficient disk space or data file exceeding limits.
[0003] In the prior art, in order to meet the above requirements, tablespace change operations usually require manual assessment of conditions before the change operation and implementation of change steps. Manual operation runs through the entire change process, making the entire change process cumbersome and inefficient, and there is no ability to automatically implement change operations and identify operational risks. Summary of the Invention
[0004] In view of this, the present invention provides a method for changing database tablespaces, which automates the process of changing database tablespaces, thereby simplifying the process, reducing manual operations, and improving implementation efficiency.
[0005] The present invention also provides a database tablespace modification device to ensure the implementation and application of the above method in practice.
[0006] The first aspect of this invention provides a method for modifying a database tablespace, comprising:
[0007] Obtain the set of change parameters and change type input by the user. The set of change parameters includes tablespace parameters, disk parameters, and expected values for the corresponding change type.
[0008] When the set of changed parameters meets the pre-set verification conditions, the pre-set tablespace change script is executed to perform the operation of creating or expanding the tablespace according to the change type.
[0009] If the change type is to create a new tablespace, the expected value is the expected tablespace value. When the tablespace corresponding to the change parameter set does not exist and the available disk space value corresponding to the disk parameter is not less than the expected tablespace value, according to the expected tablespace value, each data file corresponding to the tablespace parameter is added to the disk corresponding to the disk parameter to create the tablespace corresponding to the tablespace parameter.
[0010] If the change type is to expand the tablespace, and the expected value is the expanded tablespace value, when the tablespace corresponding to the set of change parameters exists and the available disk space value is not less than the expanded tablespace value, then according to the expanded tablespace value, the space value of each data file corresponding to the tablespace parameter is increased, or, based on the fact that the space value of each data file corresponding to the tablespace parameter has reached the preset file space threshold, one or more data files are added to the disk to expand the tablespace.
[0011] Optionally, determining whether the set of changed parameters meets pre-set verification conditions includes:
[0012] Execute the pre-set inspection script, read each parameter in the set of changed parameters, and count the number of parameters in the set of changed parameters;
[0013] When the number of parameters in the set of changed parameters and the number of instances corresponding to the set of changed parameters meet the preset first verification condition, it is determined whether the disk information corresponding to the disk parameters in the set of changed parameters meets the preset second verification condition.
[0014] If the disk information meets the second verification condition, then it is determined whether the tablespace information corresponding to the tablespace parameter in the set of changed parameters meets the preset third verification condition. If the tablespace information meets the third verification condition, then the set of changed parameters meets the preset verification condition.
[0015] The first verification condition is that the number of parameters meets the preset parameter number requirement and the number of instances corresponding to the changed parameter set is one.
[0016] The second verification condition is that the available disk space value indicated by the disk information meets the requirements;
[0017] The third verification condition is that the expected value indicated by the tablespace information and the number of data files meet the requirements.
[0018] Optionally, based on the expected tablespace value, add the respective data files corresponding to the tablespace parameters to the disk corresponding to the disk parameters, including:
[0019] Based on the expected tablespace value and the file space threshold, the size of the data file to be added to the disk is calculated sequentially.
[0020] If the size of each data file is not less than 1G and the total number of data files in the current database does not exceed the preset file number threshold, then the calculated data file of the corresponding size is created and added to the disk corresponding to the disk parameter until the expected tablespace value is reached.
[0021] Optionally, based on the expanded tablespace value, the space value of each data file corresponding to the tablespace parameter is increased, or, after the space value of each data file corresponding to the tablespace parameter has reached a preset file space threshold, one or more data files are added to the disk, including:
[0022] Based on the expanded tablespace value, the space value of each data file corresponding to the tablespace parameter is increased sequentially, and the total increase in tablespace value is calculated based on the increased space value of each data file.
[0023] If the space value of each data file reaches the file space threshold and the total increase in table space does not reach the expanded table space value, then the size of the data file to be added to the disk is calculated sequentially based on the total increase in table space, the expanded table space value, and the file space threshold. If the size of each data file is not less than 1G and the total number of data files in the current database does not exceed the preset file number threshold, then the data file of the calculated corresponding size is added to the disk corresponding to the disk parameter until the expanded table space value is reached.
[0024] Optional, also includes:
[0025] Execute the pre-set result verification script, read the set of changed parameters, and output the tablespace information, disk information, and data file information corresponding to the set of changed parameters.
[0026] A second aspect of this invention discloses a database tablespace modification device, comprising:
[0027] The parameter acquisition unit is used to acquire the set of change parameters and change type input by the user. The set of change parameters includes tablespace parameters, disk parameters and expected values for the corresponding change type.
[0028] The parameter verification unit is used to determine whether the set of changed parameters meets the preset verification conditions. If it does not meet the conditions, a prompt will be given to avoid continuing the operation. If it meets the conditions, the preset tablespace change script can be executed to perform the operation process of creating or expanding the tablespace according to the change type.
[0029] A new tablespace unit is used to add each data file corresponding to the tablespace parameter to the disk corresponding to the disk parameter according to the expected tablespace value if the change type is new tablespace, the expected value is the expected tablespace value, and the tablespace corresponding to the change parameter set does not exist and the available disk space value corresponding to the disk parameter is not less than the expected tablespace value.
[0030] The tablespace expansion unit is used to, if the change type is tablespace expansion, the expected value is tablespace expansion value, and the tablespace corresponding to the change parameter set exists and the available disk space value is not less than the tablespace expansion value in the change parameter set, then, based on the tablespace expansion value, increase the space value of each data file corresponding to the tablespace parameter, or, on the basis that the space values of each data file corresponding to the tablespace parameter have all reached a preset file space threshold, continue to add one or more data files on the disk to expand the tablespace.
[0031] Optionally, the parameter verification unit includes:
[0032] The sub-unit is used to execute a pre-set inspection script, read each parameter in the set of changed parameters, and count the number of parameters in the set of changed parameters.
[0033] The first verification subunit is used to determine whether the disk information corresponding to the disk parameters in the changed parameter set meets a preset second verification condition when the number of parameters in the changed parameter set and the number of instances corresponding to the changed parameter set meet a preset first verification condition; the first verification condition is that the number of parameters meets a preset parameter number requirement and the number of instances corresponding to the changed parameter set is one; the second verification condition is that the available disk space value indicated by the disk information meets the requirements.
[0034] The second verification subunit is used to determine whether the tablespace information corresponding to the tablespace parameters in the set of changed parameters meets the preset third verification condition if the disk information meets the second verification condition. If the tablespace information meets the third verification condition, then the set of changed parameters meets the preset verification condition. The third verification condition is that the expected value indicated by the tablespace information and the number of data files meet the requirements.
[0035] Optionally, the newly created tablespace unit includes:
[0036] The first calculation subunit calculates the size of the data file to be added to the disk in sequence based on the expected tablespace value and the file space threshold.
[0037] The first execution subunit is used to create and add the calculated data file of the corresponding size to the disk corresponding to the disk parameter if the size of each data file is not less than 1G and the total number of data files in the current database does not exceed the preset file number threshold, until the expected tablespace value is reached.
[0038] Optionally, the expanded tablespace unit includes:
[0039] The second calculation subunit is used to sequentially increase the space value of each data file corresponding to the tablespace parameter according to the expanded tablespace value, and to calculate the total increase in tablespace value based on the increased space value of each data file.
[0040] The second execution subunit is configured to, if the space value of each of the data files reaches the file space threshold and the total increase in table space does not reach the expanded table space value, calculate the size of the data files to be added to the disk in sequence based on the total increase in table space, the expanded table space value, and the file space threshold. If the size of each data file is not less than 1G and the total number of data files in the current database does not exceed the preset number of files threshold, then add the data file of the calculated corresponding size to the disk corresponding to the disk parameter until the expanded table space value is reached.
[0041] Optional, also includes:
[0042] The result verification unit is used to execute a pre-set result verification script, read the set of changed parameters, and output the tablespace information, disk information, and data file information corresponding to the set of changed parameters.
[0043] A third aspect of the present invention provides a storage medium including stored instructions, wherein the execution of the instructions controls the device where the storage medium is located to execute the above-described database tablespace modification method.
[0044] A fourth aspect of the present invention provides an electronic device, including a memory and one or more instructions, wherein one or more instructions are stored in the memory and configured to be executed by one or more processors using the database tablespace modification method described above.
[0045] Compared with the prior art, the present invention has the following advantages:
[0046] In the embodiments provided by this invention, during the process of changing a database tablespace, a set of change parameters and the change type input by the user are obtained. When the set of change parameters meets the preset verification conditions, a preset tablespace change script is executed to perform the operation of creating or expanding the tablespace according to the change type. If the change type is to create a new tablespace, and the tablespace corresponding to the set of change parameters does not exist and the available disk space value corresponding to the disk parameters is not less than the expected tablespace value in the set of change parameters, then according to the expected tablespace value, each data file corresponding to the tablespace parameters is added to the disk corresponding to the disk parameters to create the tablespace corresponding to the tablespace parameters. If the change type is to expand the tablespace, and the tablespace corresponding to the set of change parameters exists and the available disk space value is not less than the expanded tablespace value in the set of change parameters, then according to the expanded tablespace value, the space value of each data file corresponding to the tablespace parameters is increased, or after the space value of each data file corresponding to the tablespace parameters has reached the preset file space threshold, one or more data files are added to the disk to expand the tablespace.
[0047] By applying the embodiments provided by this invention, tablespaces can be automatically created or expanded based on a set of change parameters using a tablespace change script. This simplifies the change operation process and automatically identifies potential risks during the change process, thereby reducing the risks associated with manual operations and improving the efficiency of tablespace change implementation. Attached Figure Description
[0048] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0049] Figure 1 A flowchart of a database tablespace modification method provided in an embodiment of the present invention;
[0050] Figure 2 This is another method flowchart of a database tablespace modification method provided in an embodiment of the present invention;
[0051] Figure 3 A flowchart illustrating another method for modifying a database tablespace, as provided in an embodiment of the present invention.
[0052] Figure 4 A flowchart illustrating the parameter verification process for creating a new tablespace in a database tablespace modification method provided in this embodiment of the invention;
[0053] Figure 5A flowchart illustrating the process of creating a new tablespace in a database tablespace modification method provided in this embodiment of the invention;
[0054] Figure 6 A flowchart illustrating the parameter verification process for expanding a database tablespace, provided in an embodiment of the present invention.
[0055] Figure 7 A flowchart illustrating the expansion tablespace modification method provided in this embodiment of the invention.
[0056] Figure 8 A structural diagram of a database tablespace modification device provided in an embodiment of the present invention;
[0057] Figure 9 This is a schematic diagram of an electronic device structure provided in an embodiment of the present invention. Detailed Implementation
[0058] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. 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 are within the scope of protection of the present invention.
[0059] In this application, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. The terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0060] This invention can be used in a wide variety of general-purpose or special-purpose computing environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor devices, distributed computing environments including any of the above devices, etc.
[0061] This invention provides a method for modifying database tablespaces. This method can be applied to various system platforms, and the executing entity can be a computer terminal. The flowchart of the method is shown below. Figure 1 As shown, it specifically includes:
[0062] S101: Obtain the set of change parameters and change type input by the user.
[0063] The set of change parameters includes tablespace parameters, disk parameters, and expected values for the corresponding change types. For example, if the change parameter type is to create a new tablespace, the expected value is the expected tablespace value. Similarly, if the change parameter type is to expand a tablespace, the expected value is the expanded tablespace value.
[0064] In the embodiments provided by this invention, reading one set of change parameters results in the creation or expansion of the corresponding database tablespace. If there are multiple sets of change parameters, they are read sequentially, and the corresponding creation or expansion processes are performed until all change parameter sets have been read.
[0065] S102: When the set of changed parameters meets the pre-set verification conditions, execute the pre-set tablespace change script to perform the operation process of creating or expanding the tablespace according to the change type.
[0066] In the embodiments provided by this invention, the read set of changed parameters needs to be verified. This verification checks whether the number of parameters in the set, the number of instances corresponding to the set, disk information, and tablespace information meet pre-set verification conditions. Based on the verification results, it is estimated whether each parameter in the set poses a risk during the creation or expansion of a tablespace. If a risk exists, unreasonable parameter suggestions can be output; if no risk exists, i.e., the set of changed parameters meets the pre-set verification conditions, a pre-set tablespace change script can be executed. The tablespace change script includes scripts for creating and expanding tablespaces. The corresponding script for creating or expanding a tablespace is executed according to the change type to perform the process of creating or expanding a tablespace.
[0067] S103: If the change type is to create a new tablespace and the expected value is the expected tablespace value, when the tablespace corresponding to the change parameter set does not exist and the available disk space value corresponding to the disk parameter is not less than the expected tablespace value, then according to the expected tablespace value, each data file corresponding to the tablespace parameter is added to the disk corresponding to the disk parameter to create the tablespace corresponding to the tablespace parameter.
[0068] In this embodiment of the invention, if the change type is to create a new tablespace, it is determined whether the tablespace parameters exist. If the tablespace exists, the creation of a new tablespace cannot be performed, and the operation is prompted and exited. If the tablespace does not exist, a new tablespace can be constructed based on the set of change parameters. It is determined whether the available disk space corresponding to the disk parameters is sufficient to create a new tablespace. If the available disk space is not less than the expected tablespace value, the tablespace change script executes the process of creating a new tablespace. Based on the expected tablespace value, the number of data files required for the new tablespace parameters and the space value of each data file are estimated. The estimated data files corresponding to the tablespace parameters are sequentially added to the disk corresponding to the disk parameters to create the tablespace. At this time, the space value of all the data files corresponding to the tablespace parameters added to the disk is the total space value of the newly created tablespace.
[0069] S104: If the change type is tablespace expansion, the expected value is tablespace expansion value, and the tablespace corresponding to the change parameter set exists and the available disk space value is not less than the tablespace expansion value, then according to the tablespace expansion value, the space value of each data file corresponding to the tablespace parameter is increased, or, based on the fact that the space value of each data file corresponding to the tablespace parameter has reached the preset file space threshold, one or more data files are added to the disk to expand the tablespace.
[0070] In this embodiment of the invention, if the change type is tablespace expansion, it is determined whether the tablespace parameter exists. If the tablespace does not exist, expansion cannot be performed, and the operation is prompted and exited. If the tablespace parameter exists and the available disk space is not less than the tablespace expansion value, the tablespace change script executes the tablespace expansion process, which requires expanding the tablespace according to the parameter set. Based on the tablespace expansion value, the space value of each data file corresponding to the tablespace parameter is increased to expand the corresponding tablespace. If the space value of each data file corresponding to the tablespace parameter has reached the file space threshold, but the increased space value of the tablespace has not yet reached the tablespace expansion value, new data files are added to the disk corresponding to the disk parameter to continue expanding the tablespace until the increased tablespace value reaches the tablespace expansion value. The space values that need to be increased for each existing data file corresponding to the tablespace parameter, as well as the space values of the data files to be added to the disk, need to be estimated in advance based on the tablespace expansion value.
[0071] Understandably, the tablespace is expanded by executing a resize operation. Resize increases the size of existing data files. Only when resizing each existing data file to its maximum value, but the total tablespace size still doesn't reach the expected tablespace size, is S105 executed to add new data files. Therefore, if resize cannot meet the expected tablespace size, data files must be added until the total expansion size requirement is met.
[0072] It should be noted that when the data file corresponding to the tablespace is a bigfile, the tablespace is a large file tablespace and can only contain one data file. Therefore, during the expansion process, the space value of the bigfile is increased to expand the total tablespace size. When the space value of the bigfile increases to its maximum value, and the total tablespace size has not reached the expected tablespace size, the expansion process is terminated directly, and no new data file can be added to continue the expansion.
[0073] In the embodiments provided by this invention, during the process of changing a database tablespace, a set of change parameters and the change type input by the user are obtained. When the set of change parameters meets the preset verification conditions, a preset tablespace change script is executed to perform the operation of creating or expanding the tablespace according to the change type. If the change type is to create a new tablespace, and the tablespace corresponding to the set of change parameters does not exist and the available disk space value corresponding to the disk parameters is not less than the expected tablespace value in the set of change parameters, then according to the expected tablespace value, each data file corresponding to the tablespace parameters is added to the disk corresponding to the disk parameters to create the tablespace corresponding to the tablespace parameters. If the change type is to expand the tablespace, and the tablespace corresponding to the set of change parameters exists and the available disk space value is not less than the expanded tablespace value in the set of change parameters, then according to the expanded tablespace value, the space value of each data file corresponding to the tablespace parameters is increased, or after the space value of each data file corresponding to the tablespace parameters has reached the preset file space threshold, one or more data files are added to the disk to expand the tablespace.
[0074] By applying the embodiments provided by this invention, tablespaces can be automatically created or expanded based on a set of change parameters using a tablespace change script. This simplifies the change operation process and automatically identifies potential risks during the change process, thereby reducing the risks associated with manual operations and improving the efficiency of tablespace change implementation.
[0075] In the embodiments provided by the present invention, optionally, it is determined whether the set of changed parameters meets the preset verification conditions, such as... Figure 2 As shown, it includes:
[0076] S201: Execute the pre-set inspection script, read each parameter in the set of changed parameters, and count the number of parameters in the set of changed parameters.
[0077] In the embodiments provided by this invention, before performing a change operation, a verification script is used to check whether each parameter in the change parameter set meets the verification conditions. If it does, the change operation can continue. The change parameter set is input into the verification script, which reads each parameter in the change parameter set and counts the number of parameters read. If the change type of the tablespace change is to create a new tablespace, the parameters in the change parameter set must include tablespace parameters, disk parameters, and the expected tablespace value. If the change type is to expand a tablespace, the parameters in the change parameter set must include tablespace parameters, disk parameters, and the expanded tablespace value.
[0078] S202: Determine whether the number of parameters in the set of changed parameters and the number of instances corresponding to the set of changed parameters meet the preset first verification condition.
[0079] In this embodiment of the invention, the verification script first needs to determine the number of parameters in the changed parameter set and the number of instances corresponding to the changed parameter set. If the number of parameters in the changed parameter set and the number of instances corresponding to the changed parameter set do not meet the first verification condition, then S206 is executed to generate a prompt message and exit the parameter verification process.
[0080] If the number of parameters in the changed parameter set and the number of instances corresponding to the changed parameter set meet the first verification condition, then execute S203 to continue to determine whether the disk information corresponding to the disk parameters in the changed parameter set meets the preset second verification condition.
[0081] Since this invention only applies to single-instance databases, the first verification condition can be set to the number of parameters meeting the pre-set parameter number requirement and the number of instances corresponding to the changed parameter set being one.
[0082] If the change operation type to be performed by the parameter set is to create a new tablespace, then it is determined whether the number of parameters in the parameter set is a tablespace parameter, a disk parameter, or a expected tablespace value. If the number of parameters meets the condition, it is further determined whether the number of instances corresponding to the parameter set is 1. If the number of instances corresponding to the parameter set is 1, it is further determined whether the tablespace corresponding to the parameter set is being created for the first time and whether the tablespace corresponding to the parameter set exists. If the tablespace corresponding to the parameter set is being created for the first time and the tablespace corresponding to the parameter set does not exist, then the number of parameters in the parameter set corresponding to the tablespace to be created and the number of instances corresponding to the parameter set meet the preset first verification condition. If the number of parameters in the parameter set does not meet the condition or the number of instances corresponding to the parameter set is not 1, a prompt message is generated and the parameter verification process is exited.
[0083] S203: Determine whether the disk information corresponding to the disk parameters in the set of changed parameters meets the preset second verification condition.
[0084] In this embodiment of the invention, the second verification condition is to verify whether the disk information meets the requirements set by the conditions, that is, it can be to verify whether the available disk space value meets the expected tablespace value or the expanded tablespace value required for creating a new tablespace or expanding a tablespace.
[0085] Specifically, first, the disk information corresponding to the disk parameters is obtained, and then the space values corresponding to the existing tablespaces in the disk are read sequentially to obtain the available disk space value. When the change operation type to be performed by the change parameter set is to create a new tablespace, if the available disk space value is less than the expected tablespace value, or when the change operation type to be performed by the change parameter set is to expand a tablespace, if the available disk space value is less than the expanded tablespace value, then S206 is executed, a prompt message is generated, and the process exits; otherwise, S204 is executed, and the tablespace information corresponding to the tablespace parameters is read again to determine whether the tablespace information corresponding to the tablespace parameters in the change parameter set meets the preset third verification condition.
[0086] S204: Determine whether the tablespace information corresponding to the tablespace parameters in the set of changed parameters meets the preset third verification condition.
[0087] In this embodiment of the invention, the third verification condition is to verify whether the tablespace information meets the requirements set by the requirements. That is, the expected value indicated by the tablespace information and the number of data files meet the requirements. Specifically, it can be to verify that the expected tablespace value required for creating a new tablespace or expanding a tablespace exceeds the maximum tablespace value limit and that the number of data files corresponding to the tablespace parameters exceeds a predetermined file number threshold.
[0088] Specifically, based on the tablespace parameters, the tablespace information to be tested is obtained. It is determined whether the expected tablespace value corresponding to the tablespace information exceeds the maximum tablespace limit. If it does, step S206 is executed, a prompt message is generated, and the process exits. If it does not exceed the limit, the number of data files corresponding to the tablespace parameters is estimated based on the tablespace information and the expected or expanded tablespace value to determine if it exceeds a pre-defined file count threshold. If it does not exceed the threshold, it is concluded that the tablespace information corresponding to the tablespace parameters meets the third test condition, leading to the final conclusion S205: the changed parameter set meets the pre-set test conditions.
[0089] It should be noted that if the change operation type to be performed on the parameter set is to expand the tablespace, it is also necessary to check whether the data file corresponding to the tablespace parameter is a bigfile. If it is a bigfile, it is necessary to estimate whether the space value to be expanded of the bigfile file exceeds the limit of the bigfile file based on the expanded tablespace value. If it exceeds the limit, it is also necessary to execute S206, generate a prompt message and exit.
[0090] S205: The set of changed parameters meets the pre-set inspection conditions.
[0091] S206: Generate a prompt message and exit.
[0092] By applying the embodiments provided by this invention, the parameter verification script can automatically verify whether each parameter in the set of change parameters meets the conditions before changing the tablespace, thereby controlling the risks before the change operation is implemented, reducing manual intervention, and improving verification efficiency.
[0093] In the embodiments provided by the present invention, optionally, the step of adding each data file corresponding to the tablespace parameter to the disk corresponding to the disk parameter according to the expected tablespace value is as follows: Figure 3 As shown, it includes:
[0094] S301: Based on the expected tablespace value and the file space threshold, calculate the size of the data file to be added to the disk and determine whether the current number of data files exceeds the file number threshold.
[0095] Based on the expected tablespace value and file space threshold, estimate the size of the data files that need to be added to the disk. During the estimation process, the space value of the data files to be added to the disk can be initially set to the maximum space value of the data files, i.e., the file space threshold. It is then determined whether increasing the space exceeds the expected value. If it does, the value is adjusted until the expected tablespace value is met. If it does not exceed the expected value, it is determined whether the files are small (less than 1GB) and whether the total number of data files exceeds the file count threshold. If it does, a prompt is displayed and the operation is exited. If it does not exceed the threshold, the data files are directly added to the disk corresponding to the disk parameters, and the latest number of data files is counted.
[0096] S302: If the number of data files does not exceed the preset file number threshold, then according to the data file space value, the corresponding data file is added to the disk corresponding to the disk parameter until the expected table space value is reached.
[0097] Based on the total number of data files on the disk as counted by S301, it is determined whether the number of data files exceeds the preset file number threshold. If it does, a prompt is given and the operation is exited. If it does not exceed, the data files are added to the disk corresponding to the disk parameters according to the data file space value until the expected tablespace value is reached, thus completing the process of creating a new tablespace.
[0098] Similarly, during expansion, the step of increasing the space value of each data file corresponding to the tablespace parameter according to the expanded tablespace value, or adding one or more data files to the disk after the space values of each data file corresponding to the tablespace parameter have reached the preset file space threshold, includes:
[0099] Based on the expanded tablespace value, the space value of each data file corresponding to the tablespace parameter is increased sequentially, and the total increase in tablespace value is calculated based on the increased space value of each data file.
[0100] If the space value of each of the data files reaches the file space threshold and the total increase in table space does not reach the expanded table space value, then the space value of the data files to be added to the disk is calculated based on the total increase in table space and the expanded table space value, and the total number of data files is counted.
[0101] If the total number of data files does not exceed the preset file number threshold, then the data files are added to the disk corresponding to the disk parameter.
[0102] In the embodiments provided by this invention, during expansion, an estimation process is first performed. Based on the expanded tablespace value, the required additional space for each data file is estimated, and the number of data files is counted. First, the space value of the existing data files that need adjustment is estimated. Based on the expanded tablespace information, each data file whose corresponding tablespace parameter has not reached its maximum space value is adjusted to its maximum value. During the adjustment process, the total increase in tablespace is recorded. If the total increase in tablespace during the adjustment of existing data files has reached the expanded tablespace value, no further data files need to be added. The estimated value that each existing data file needs to be adjusted to is calculated, and each existing data file is adjusted to the estimated value, completing the tablespace expansion process.
[0103] If all the data files corresponding to all tablespace parameters have reached their maximum values, and the total increase in tablespace size still does not reach the value required to expand the tablespace, then new data files need to be added to continue expanding the tablespace.
[0104] The process of estimating the size of newly added data files and adding them to the corresponding disk includes: calculating the size of new data files that still need to be added to the disk based on the total increase value of the tablespace and the expansion value of the tablespace. As described in S301, during the estimation process, the space value of the new data files to be added to the disk can be set as the file space threshold first. It is then determined whether the increase exceeds the expected space value. If it does, the value is adjusted until the expected tablespace value is met. If it does not exceed, it is determined whether the file is a small file less than 1G and whether the total number of data files exceeds the file number threshold. If it exceeds, a prompt is given and the operation is exited. If it does not exceed, the data files are directly added to the disk corresponding to the disk parameters and the latest number of data files is counted.
[0105] Based on the estimated space values of each data file that need to be adjusted, adjust them to the file space threshold, and add each data file to the disk corresponding to the disk parameters as needed, thus completing the process of expanding the tablespace.
[0106] By applying the embodiments provided by this invention, the required number of data files or the increased space value of data files are estimated based on the expected tablespace value or the expanded tablespace value. Then, based on the estimation results, the data files corresponding to the tablespace parameters are added to the disk or the space value of each data file is adjusted. This ensures that the total space value of the newly added data files during the creation of a new tablespace reaches the expected tablespace value, or the total increase in tablespace value during the expansion of a tablespace reaches the expanded tablespace value. This guarantees a more standardized and flexible adjustment of the number of data files or the space value of data files.
[0107] In the process of executing the tablespace change script in the embodiments provided by the present invention, the main function is to execute a pre-set shell script to complete the setting of the operation environment variables and trigger the execution of a pre-set perl script.
[0108] The method proposed in this invention requires the deployment of scripts at the operating system level. Since shell scripting languages are good at handling operating system-related operations, and Perl is flexible in writing, has powerful regular expression support, and is very powerful in text processing, combined with the large amount of text content in the database, the shell program is used to set up the script to complete the acquisition and setting of operating system environment variables, the Perl program sets the script execution-related environment variables, and triggers the execution of the Perl script. The Perl script collects and formats the output of detailed tablespace information such as the name, size, number of data files, and usage rate of all current tablespaces, and performs tablespace changes and verification of the results after the changes.
[0109] This method enables the setting of environment variables for changing tablespaces and outputs existing tablespace information. This allows users to identify the parameters that need to be changed based on the existing tablespace information, perform the creation or expansion of tablespaces, and verify the change results.
[0110] In the embodiments provided by the present invention, optionally, it also includes:
[0111] Execute the pre-set result verification script, read the set of changed parameters, and output the tablespace information, disk information, and data file information corresponding to the set of changed parameters.
[0112] A shell / perl script is used to set up a result verification script to verify the execution results. This script monitors the current status of the tablespace, data files, and disk space after the tablespace change is completed, helping to determine whether the change was successful. At the same time, it filters out non-change information and only retains the change information for users to view.
[0113] The result verification script reads the set of changed parameters and, based on the set of changed parameters, outputs the information of the newly created or expanded tablespace corresponding to the tablespace parameters, the information of the data files corresponding to the tablespace parameters, and the disk usage list information corresponding to the disk parameters. Specifically, it determines whether the results of creating or expanding the tablespace meet expectations.
[0114] This method can automatically verify the results after changing a tablespace to determine whether the change was successful, reducing the need for manual verification and improving the efficiency of verifying the results of tablespace changes.
[0115] Based on the embodiments provided by the present invention, see [link / reference]. Figure 4 A parameter detection method for creating a new tablespace can be obtained to determine the operational risks before creating a new tablespace. The process includes preparing relevant check commands, reading each parameter in the set of change parameters, and generating a prompt message and exiting if the number of parameters in the set of change parameters does not meet the requirements, or if there is more than one instance corresponding to the set of change parameters, or if the tablespace corresponding to the set of change parameters is not being created for the first time but already exists.
[0116] If the set of changed parameters read meets the above conditions, then based on the set of changed parameters, obtain the size of the new tablespace that needs to be created, i.e. the expected tablespace value, and the disk space size corresponding to the disk parameters. Then, based on the tablespace parameters in the set of changed parameters, determine again whether the tablespace already exists. If the tablespace already exists, generate a prompt message and exit; otherwise, determine whether all the parameters in the set of changed parameters have been read.
[0117] If the data has been read completely, the disk group information for the new tablespace is obtained based on the disk parameters in the parameter set. The total value of existing tablespaces in the disk group is then read sequentially, and the available disk space is calculated. It is then determined whether the available disk space is sufficient to create the new tablespace to the expected value. If insufficient, a prompt message is generated and the process exits. Once the disk group information is read and the available disk space is sufficient, the new tablespace information, including the expected tablespace value, is obtained based on the parameter set. It is then determined whether the expected tablespace value exceeds the database's maximum tablespace limit. If it does, a prompt message is generated and the process exits. If the tablespace information is read completely and the expected tablespace value does not exceed the database's maximum tablespace limit, the number of data files corresponding to the new tablespace is estimated based on the tablespace information. It is then determined whether the estimated number of data files exceeds the specified limit. If it does, a prompt message is generated and the process exits. If it does not exceed the limit, the process exits normally, ending the parameter verification process. A normal exit indicates that there is no operational risk associated with any of the parameters in the parameter set corresponding to the new tablespace, and the tablespace corresponding to that parameter set can be created accordingly.
[0118] Based on the embodiments provided by the present invention, see [link / reference]. Figure 5 A method for creating a new tablespace can be derived. The process includes preparing relevant commands and performing the tablespace creation process, including: opening a log file and obtaining a set of change parameters; determining if the tablespace corresponding to the set of change parameters exists; if it exists, there is no need to create a new tablespace on the corresponding disk group based on the set of change parameters, and the tablespace creation process exits; if it does not exist, the obtained set of change parameters is written to the log file, and then it is determined whether the disk group space corresponding to the set of change parameters is sufficient, i.e., whether the available space value of the disk group is greater than or equal to the expected tablespace value for the new tablespace; if the disk space is insufficient, the execution status is written to the log file and the process exits; if the disk space is sufficient, it is determined whether the current tablespace value is less than expected; if it is not less than expected and all parameters have been read, the log is closed and the process exits; if the parameters have not been read completely, the process continues reading, and the next tablespace is created.
[0119] If the current tablespace value is less than expected, a maximum data file will be added, and it will be checked whether it exceeds the expected value. If it does, adjustments will be made, and it will be checked whether the newly added data file is less than 1GB. If it is less than 1GB, the process will exit without creating a data file smaller than 1GB. If it is not less than 1GB, it will be checked whether the total number of data files exceeds the limit. If it does, the process will exit. Otherwise, the tablespace existence status will be retrieved, the current time will be retrieved and written to the log, and it will be determined whether it is a temporary tablespace or a regular tablespace. It will also be checked whether the tablespace already exists. If it does not exist, the new tablespace command will be executed. If it already exists, it means that the tablespace has just been created, but the total space value does not meet the expectation, and it only needs to be expanded. The expansion command will be executed. After executing the new or expansion command, it will be checked whether the current data file is already at its maximum value. If it is, the data file size will be incremented by 1, and it will be checked whether it meets the expected space value. If not, it will directly check whether it meets the expected space value and start the next loop, that is, check whether the current tablespace value is less than the expected tablespace value. If it is not less than the expected tablespace value and all parameters have been read, the process of creating the new tablespace will end, the log will be closed, and the process will exit. If the value is less than the expected tablespace size, then based on the newly created tablespace, the process of expanding the tablespace is executed according to the expected tablespace size and the current tablespace size, until the expected tablespace size is reached. If the parameters are not fully read, the process continues, creating the next tablespace until all parameters are read.
[0120] Similarly, see Figure 6 A parameter verification method for expanding a tablespace can be obtained to control operational risks before expanding the tablespace. The process includes starting by running a Perl / shell script command to verify the parameters, reading each parameter in the set of changed parameters, and generating a prompt message and exiting if the number of parameters in the set of changed parameters does not meet the requirements or if there is more than one instance corresponding to the set of changed parameters.
[0121] If the set of changed parameters read meets the above conditions, then based on the set of changed parameters, the required expansion size of each tablespace and the available expansion size of each disk space corresponding to the disk parameters are obtained. It is then determined whether the available disk space value meets the total expansion value of each tablespace required for expansion. If not, a prompt message is generated and the process exits. If the available disk space value meets the expansion requirements, then based on the set of changed parameters, the information of each tablespace to be expanded and the expected tablespace value are obtained. If the data file corresponding to the expanded tablespace information is a bigfile, then it is determined whether the space value of the bigfile file has exceeded the maximum value limit of the bigfile file. If it has, a prompt message is generated and the process exits. If the data file corresponding to the expanded tablespace information is not a bigfile file, then based on the expanded tablespace information, it is determined whether the tablespace has exceeded the maximum tablespace value limit after expansion to the expected size. If it has, a prompt message is generated and the process exits. When all the above conditions are met, it is determined whether the total number of data files in each tablespace after expansion exceeds the limit specified by the data file. If it has, a prompt message is generated and the process exits. If it has not exceeded, the process exits normally, ending the parameter verification process. If the process exits normally, it means that there is no operational risk in the set of parameters corresponding to the tablespace being expanded, and the tablespace corresponding to the set of parameters can be expanded accordingly.
[0122] Similarly, based on the embodiments provided by the present invention, see [link to relevant documentation]. Figure 7 One method for expanding tablespaces can be derived, which expands tablespaces on demand while reassessing operational risks. The process includes preparing the necessary commands and running Perl / shell scripts to expand the tablespace, including: opening the log file and obtaining the set of changed parameters; determining whether the tablespace corresponding to the set of changed parameters exists; if it does not exist, exiting the tablespace expansion process; if it exists, writing the obtained set of changed parameters to the log file, and then determining whether the disk group space corresponding to the set of changed parameters is sufficient, i.e., whether the available space value of the disk group is greater than or equal to the expected tablespace size to be expanded.
[0123] If disk space is insufficient, the execution status is written to the log file and the process exits. If disk space is sufficient, the data files corresponding to the tablespace parameters are retrieved sequentially, and it is determined whether the disk group where the data file resides is the expected disk group corresponding to the disk parameters in the set of changed parameters. If not, the next data file is retrieved. If so, the data file is to be increased to the maximum limit value. If the limit is exceeded, adjustments are made, and the expansion information (time, command) is written to the log file. The command is executed to perform a resize operation, and it is determined whether the tablespace has been expanded to the expected size after resizing. If not, the next data file is read. If so, it is determined whether the total expansion capacity has reached the expected tablespace expansion value. If it has, the process exits. If all data files have been resized and the target size has not been reached, the process is determined to be... If the file is a bigfile, exit. If not, plan to add a new data file. First, determine if it is feasible to expand according to the maximum file size. If it is found that the expected expansion value is exceeded, adjust it to ensure that the expansion value does not exceed the expectation. After determining the size of the data file to be added, check if the data file size is less than 1G. If it is less than 1G, do not add the data file and exit directly to avoid small files. If it is not less than 1G, check if the number of data files will exceed the limit. If it will exceed the limit, write to the log and exit. Otherwise, increment the data file count variable by 1, write log information and execute the data file expansion command, and check again whether the total expansion capacity has reached the expected tablespace expansion value. Repeat the above process until the total expansion capacity reaches the expected tablespace expansion value and then exit.
[0124] This invention also integrates a data interaction interface, which can parse the input set of change parameters and output the results of each step in a formatted manner. It can be connected to an intelligent automation software platform to realize the process of automating each step of the change, thereby controlling the number of parameters and the rationality of their values, standardizing the size of data files, avoiding inconsistent data file sizes, restricting the standardized use of data disks, supporting ASM shared storage, and facilitating database management.
[0125] The code for the input module is as follows:
[0126]
[0127] The code for the output module is as follows:
[0128]
[0129]
[0130] The specific implementation processes and derivative methods of the above embodiments are all within the protection scope of this invention.
[0131] and Figure 8Corresponding to the method described above, this embodiment of the invention also provides a database tablespace modification device for modifying... Figure 1 The specific implementation of the method, the database tablespace modification device provided in this embodiment of the invention, can be applied in a computer terminal, and its structural diagram is shown below. Figure 8 As shown, it specifically includes:
[0132] The parameter acquisition unit 801 is used to acquire the set of change parameters and change type input by the user. The set of change parameters includes tablespace parameters, disk parameters and expected values for the corresponding change type.
[0133] The parameter verification unit 802 is used to execute a pre-set tablespace change script when the set of changed parameters meets the pre-set verification conditions, so as to perform the operation process of creating or expanding the tablespace according to the change type.
[0134] A new tablespace unit 803 is used to add each data file corresponding to the tablespace parameter to the disk corresponding to the disk parameter according to the expected tablespace value if the change type is a new tablespace, the expected value is the expected tablespace value, and the tablespace corresponding to the change parameter set does not exist and the available disk space value corresponding to the disk parameter is not less than the expected tablespace value, so as to create the tablespace corresponding to the tablespace parameter.
[0135] The tablespace expansion unit 804 is used to, if the change type is tablespace expansion and the expected value is tablespace expansion value, when the tablespace corresponding to the change parameter set exists and the available disk space value is not less than the tablespace expansion value, increase the space value of each data file corresponding to the tablespace parameter according to the tablespace expansion value, or continue to add one or more data files on the disk to expand the tablespace after the space values of each data file corresponding to the tablespace parameter have reached a preset file space threshold.
[0136] Based on the apparatus provided in this embodiment of the invention, during the process of changing a database tablespace, the parameter acquisition unit acquires the set of change parameters and the change type input by the user; when the set of change parameters meets the preset verification conditions, the parameter verification unit executes the preset tablespace change script to perform the operation of creating or expanding the tablespace according to the change type; if the change type is to create a new tablespace, and the tablespace corresponding to the set of change parameters does not exist and the available disk space value corresponding to the disk parameters is not less than the expected tablespace value in the set of change parameters, then the new tablespace unit adds each data file corresponding to the tablespace parameters to the disk corresponding to the disk parameters according to the expected tablespace value to create the tablespace corresponding to the tablespace parameters; if the change type is to expand the tablespace, and the tablespace corresponding to the set of change parameters exists and the available disk space value is not less than the expanded tablespace value in the set of change parameters, then the expanded tablespace unit increases the space value of each data file corresponding to the tablespace parameters according to the expanded tablespace value, or continues to add one or more data files to the disk after the space values of each data file corresponding to the tablespace parameters have reached the preset file space threshold to expand the tablespace.
[0137] The apparatus provided in this embodiment of the invention can automatically create or expand tablespaces based on a set of change parameters using a tablespace change script, simplifying the change operation process. It can also automatically identify potential risks during the change process, thereby reducing the risks associated with manual operations and improving the efficiency of tablespace change implementation.
[0138] Based on the apparatus provided in the embodiments of the present invention, optionally, the parameter verification unit 802 includes:
[0139] The sub-unit is used to execute a pre-set inspection script, read each parameter in the set of changed parameters, and count the number of parameters in the set of changed parameters.
[0140] The first verification subunit is used to determine whether the disk information corresponding to the disk parameters in the changed parameter set meets a preset second verification condition when the number of parameters in the changed parameter set and the number of instances corresponding to the changed parameter set meet a preset first verification condition; the first verification condition is that the number of parameters meets a preset parameter number requirement and the number of instances corresponding to the changed parameter set is one; the second verification condition is that the available disk space value indicated by the disk information meets the requirements.
[0141] The second verification subunit is used to determine whether the tablespace information corresponding to the tablespace parameters in the set of changed parameters meets the preset third verification condition if the disk information meets the second verification condition. If the tablespace information meets the third verification condition, then the set of changed parameters meets the preset verification condition. The third verification condition is that the expected value indicated by the tablespace information and the number of data files meet the requirements.
[0142] Optionally, based on the apparatus provided in the embodiments of the present invention, the newly created tablespace unit 803 includes:
[0143] The first calculation subunit is used to calculate the size of the data file to be added to the disk based on the expected tablespace value and the file space threshold;
[0144] The first execution subunit is used to create and add the calculated data file of the corresponding size to the disk corresponding to the disk parameter if the size of each data file is not less than 1G and the total number of data files in the current database does not exceed the preset file number threshold, until the expected tablespace value is reached.
[0145] Based on the apparatus provided in the embodiments of the present invention, optionally, the expanded table space unit 804 includes:
[0146] The second calculation subunit is used to sequentially increase the space value of each data file corresponding to the tablespace parameter according to the expanded tablespace value, and to calculate the total increase in tablespace value based on the increased space value of each data file.
[0147] The second execution subunit is used to calculate the size of the data file to be added to the disk in sequence based on the total increase in tablespace, the expanded tablespace value, and the file space threshold if the space value of each of the data files reaches the file space threshold and the total increase in tablespace does not reach the expanded tablespace value. If the size is not less than 1G and the total number of data files in the current database does not exceed the preset number of files threshold, the data file of the calculated size is added to the disk corresponding to the disk parameter until the expanded tablespace value is reached.
[0148] Optionally, the apparatus provided in the embodiments of the present invention may further include:
[0149] The result verification unit is used to execute a pre-set result verification script, read the set of changed parameters, and output the tablespace information, disk information, and data file information corresponding to the set of changed parameters.
[0150] The specific working process of each unit and subunit in the database tablespace changing device disclosed in the above embodiments of the present invention can be found in the corresponding content of the database tablespace changing method disclosed in the above embodiments of the present invention, and will not be repeated here.
[0151] This invention also provides a storage medium that includes stored instructions, wherein the execution of the instructions controls the device where the storage medium is located to execute the aforementioned database tablespace modification method.
[0152] This invention also provides an electronic device, the structural schematic of which is shown below. Figure 9 As shown, it specifically includes a memory 901 and one or more instructions 902, wherein one or more instructions 902 are stored in the memory 901 and configured to be executed by one or more processors 903 to perform the following operations:
[0153] Obtain the set of change parameters and change type input by the user. The set of change parameters includes tablespace parameters, disk parameters, and expected values for the corresponding change type.
[0154] When the set of changed parameters meets the pre-set verification conditions, the pre-set tablespace change script is executed to perform the operation of creating or expanding the tablespace according to the change type.
[0155] If the change type is creating a new tablespace, the expected value is the expected tablespace value, and the tablespace corresponding to the change parameter set does not exist and the available disk space value corresponding to the disk parameter is not less than the expected tablespace value, then according to the expected tablespace value, each data file corresponding to the tablespace parameter is added to the disk corresponding to the disk parameter to create the tablespace corresponding to the tablespace parameter; if the change type is expanding a tablespace, the expected value is the expanding tablespace value, and when the tablespace corresponding to the change parameter set exists and the available disk space value is not less than the expanding tablespace value in the change parameter set, then according to the expanding tablespace value, the space value of each data file corresponding to the tablespace parameter is increased, or, based on the space value of each data file corresponding to the tablespace parameter reaching a preset file space threshold, one or more data files are added to the disk to expand the tablespace.
[0156] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, for system or system embodiments, since they are basically similar to method embodiments, the description is relatively simple, and relevant parts can be referred to the descriptions in the method embodiments. The systems and system embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without creative effort.
[0157] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in connection with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both.
[0158] To clearly illustrate the interchangeability of hardware and software, the components and steps of each example have been generally described in terms of functionality above. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0159] The above description of the disclosed embodiments enables those skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for modifying a database tablespace, characterized in that, include: Obtain the set of change parameters and change type input by the user. The set of change parameters includes tablespace parameters, disk parameters, and expected values for the corresponding change type. When the set of changed parameters meets the pre-set verification conditions, the pre-set tablespace change script is executed to perform the operation of creating or expanding the tablespace according to the change type. The verification conditions include: the number of parameters in the set of changed parameters meets the requirements, the number of corresponding instances is one, the available disk space value corresponding to the disk parameters meets the requirements, and the expected value and number of data files indicated by the tablespace information corresponding to the tablespace parameters meet the requirements. If the change type is to create a new tablespace, the expected value is the expected tablespace value. When the tablespace corresponding to the change parameter set does not exist and the available disk space value corresponding to the disk parameter is not less than the expected tablespace value, according to the expected tablespace value, each data file corresponding to the tablespace parameter is added to the disk corresponding to the disk parameter to create the tablespace corresponding to the tablespace parameter. If the change type is to expand the tablespace, and the expected value is the expanded tablespace value, when the tablespace corresponding to the set of change parameters exists and the available disk space value is not less than the expanded tablespace value, then according to the expanded tablespace value, the space value of each data file corresponding to the tablespace parameter is increased, or, based on the fact that the space value of each data file corresponding to the tablespace parameter has reached the preset file space threshold, one or more data files are added to the disk to expand the tablespace.
2. The method according to claim 1, characterized in that, Determining whether the set of changed parameters meets the preset verification conditions includes: Execute the pre-set inspection script, read each parameter in the set of changed parameters, and count the number of parameters in the set of changed parameters; When the number of parameters in the set of changed parameters and the number of instances corresponding to the set of changed parameters meet the preset first verification condition, it is determined whether the disk information corresponding to the disk parameters in the set of changed parameters meets the preset second verification condition. If the disk information meets the second verification condition, then it is determined whether the tablespace information corresponding to the tablespace parameter in the set of changed parameters meets the preset third verification condition. If the tablespace information meets the third verification condition, then the set of changed parameters meets the preset verification condition. The first verification condition is that the number of parameters meets the preset parameter number requirement and the number of instances corresponding to the changed parameter set is one. The second verification condition is that the available disk space value indicated by the disk information meets the requirements; The third verification condition is that the expected value indicated by the tablespace information and the number of data files meet the requirements.
3. The method according to claim 1, characterized in that, Based on the expected tablespace value, add the respective data files corresponding to the tablespace parameters to the disk corresponding to the disk parameters, including: Based on the expected tablespace value and the file space threshold, the size of the data file to be added to the disk is calculated sequentially. If the size of each data file is not less than 1G and the total number of data files in the current database does not exceed the preset file number threshold, then the calculated data file of the corresponding size is created and added to the disk corresponding to the disk parameter until the expected tablespace value is reached.
4. The method according to claim 1, characterized in that, Based on the expanded tablespace value, increase the space value of each data file corresponding to the tablespace parameter, or, after the space values of each data file corresponding to the tablespace parameter have all reached the preset file space threshold, continue to add one or more data files to the disk, including: Based on the expanded tablespace value, the space value of each data file corresponding to the tablespace parameter is increased sequentially, and the total increase in tablespace value is calculated based on the increased space value of each data file. If the space value of each data file reaches the file space threshold and the total increase in table space does not reach the expanded table space value, then the size of the data file to be added to the disk is calculated sequentially based on the total increase in table space, the expanded table space value, and the file space threshold. If the size of each data file is not less than 1G and the total number of data files in the current database does not exceed the preset file number threshold, then the data file of the calculated corresponding size is added to the disk corresponding to the disk parameter until the expanded table space value is reached.
5. The method according to claim 1, characterized in that, Also includes: Execute the pre-set result verification script, read the set of changed parameters, and output the tablespace information, disk information, and data file information corresponding to the set of changed parameters.
6. A database tablespace modification device, characterized in that, include: The parameter acquisition unit is used to acquire the set of change parameters and change type input by the user. The set of change parameters includes tablespace parameters, disk parameters and expected values for the corresponding change type. The parameter verification unit is used to determine whether the set of changed parameters meets the preset verification conditions. If it does not meet the conditions, a prompt will be given to avoid continuing the operation. If it meets the conditions, the preset tablespace change script can be executed to perform the operation process of creating or expanding the tablespace according to the change type. The verification conditions include: the number of parameters in the set of changed parameters meets the requirements, the number of corresponding instances is one, the available disk space value corresponding to the disk parameters meets the requirements, and the expected value and number of data files indicated by the tablespace information corresponding to the tablespace parameters meet the requirements. A new tablespace unit is used to add each data file corresponding to the tablespace parameter to the disk corresponding to the disk parameter according to the expected tablespace value if the change type is new tablespace, the expected value is the expected tablespace value, and the tablespace corresponding to the change parameter set does not exist and the available disk space value corresponding to the disk parameter is not less than the expected tablespace value. The tablespace expansion unit is used to, if the change type is tablespace expansion, the expected value is tablespace expansion value, and the tablespace corresponding to the change parameter set exists and the available disk space value is not less than the tablespace expansion value in the change parameter set, then, based on the tablespace expansion value, increase the space value of each data file corresponding to the tablespace parameter, or, on the basis that the space values of each data file corresponding to the tablespace parameter have all reached a preset file space threshold, continue to add one or more data files on the disk to expand the tablespace.
7. The apparatus according to claim 6, characterized in that, The parameter verification unit includes: The sub-unit is used to execute a pre-set inspection script, read each parameter in the set of changed parameters, and count the number of parameters in the set of changed parameters. The first verification subunit is used to determine whether the disk information corresponding to the disk parameters in the changed parameter set meets a preset second verification condition when the number of parameters in the changed parameter set and the number of instances corresponding to the changed parameter set meet a preset first verification condition; the first verification condition is that the number of parameters meets a preset parameter number requirement and the number of instances corresponding to the changed parameter set is one; the second verification condition is that the available disk space value indicated by the disk information meets the requirements. The second verification subunit is used to determine whether the tablespace information corresponding to the tablespace parameters in the set of changed parameters meets the preset third verification condition if the disk information meets the second verification condition. If the tablespace information meets the third verification condition, then the set of changed parameters meets the preset verification condition. The third verification condition is that the expected value indicated by the tablespace information and the number of data files meet the requirements.
8. The apparatus according to claim 6, characterized in that, The newly created tablespace unit includes: The first calculation subunit calculates the size of the data file to be added to the disk in sequence based on the expected tablespace value and the file space threshold. The first execution subunit is used to create and add the calculated data file of the corresponding size to the disk corresponding to the disk parameter if the size of each data file is not less than 1G and the total number of data files in the current database does not exceed the preset file number threshold, until the expected tablespace value is reached.
9. The apparatus according to claim 6, characterized in that, The expanded tablespace unit includes: The second calculation subunit is used to sequentially increase the space value of each data file corresponding to the tablespace parameter according to the expanded tablespace value, and to calculate the total increase in tablespace value based on the increased space value of each data file. The second execution subunit is configured to, if the space value of each of the data files reaches the file space threshold and the total increase in table space does not reach the expanded table space value, calculate the size of the data files to be added to the disk in sequence based on the total increase in table space, the expanded table space value, and the file space threshold. If the size of each data file is not less than 1G and the total number of data files in the current database does not exceed the preset number of files threshold, then add the data file of the calculated corresponding size to the disk corresponding to the disk parameter until the expanded table space value is reached.
10. The apparatus according to claim 6, characterized in that, Also includes: The result verification unit is used to execute a pre-set result verification script, read the set of changed parameters, and output the tablespace information, disk information, and data file information corresponding to the set of changed parameters.
Citation Information
Patent Citations
Method and device for changing tables in database
CN110633284A
File system capacity expansion method and device, electronic equipment and storage medium
CN113190503A