A data type storage method, device, equipment, medium and product

By using trigger statements in the database to checksum storage of ENUM and SET data types, the problem of lack of semantics in simple mapping is solved, and the accuracy of data type storage is improved.

CN119759886APending Publication Date: 2025-04-04WUHAN DAMENG DATABASE
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411842082.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-13
Publication Date
2025-04-04

AI Technical Summary

Technical Problem

The prior art, when compatible with ENUM and SET data types, simple mapping to CHAR(n) lacks semantic considerations for enums and sets, resulting in inaccurate storage.

Method used

By obtaining the data to be checked, the data is verified using the standard string information in the trigger statement. Only when the verification result is legal, the data is stored in the preset data type column in the standard string format.

Benefits of technology

Improves storage accuracy of enumeration types and collection types to ensure semantics retention during data type conversion.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119759886A_ABST
    Figure CN119759886A_ABST
Patent Text Reader

Abstract

The disclosed embodiments disclose a method, apparatus, device, medium and product for storing data types, including: obtaining data to be verified, wherein the data to be verified includes data of enumeration type and / or data of collection type; verifying the data to be verified using standard string information in a trigger statement to obtain a verification result; wherein the standard string information includes at least one standard string data, and the standard string data includes a comma separator; if the verification result is that the verification to be converted is legal, storing the data to be verified in a preset data type column in a standard string format. The technical party uses the standard string information in the trigger statement to verify the data to be verified, and if the verification is legal, stores the data to be verified in a preset data type column in a standard string format, thereby improving the accuracy of data type storage.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present disclosure relate to the field of database technology, and in particular, to a method, device, equipment, medium and product for storing data types. Background Art

[0002] In order to improve the flexibility of the system and reduce the difficulty of data migration and application transplantation, many database systems will provide compatibility support for third-party databases, and data type compatibility is an important part of database compatibility. In the process of data type compatibility, for the different data types between the two parties, first consider whether they can be mapped under certain conditions. For data types that cannot be directly mapped or have a large difference in actual functions after mapping, more in-depth compatibility is required. The essence of enumerated type (ENUM) and set type (SET) is string type, and its elements must be selected from a predefined set, which is defined when creating or modifying a table. For databases that do not support ENUM and SET data types, the most direct way to be compatible is to convert ENUM and SET mappings into fixed-length string types (Character Data Type with Length n, CHAR(n)), but such a simple mapping does not have the semantics of ENUM and SET types.

[0003] Generally speaking, the support and migration of data types are divided into native support and simple mapping. Native support requires corresponding processing in the grammatical stage, semantic stage, and subsequent execution stage, which involves more modules and a larger range of codes that need to be modified and maintained; simple mapping generally maps ENUM and SET data types to CHAR(n). This processing alone lacks consideration of the semantics of enumerations and sets and does not verify the data. Summary of the invention

[0004] The embodiments of the present disclosure provide a method, apparatus, device, medium and product for storing data types, which improve the accuracy of storing enumeration types and collection types.

[0005] In a first aspect, a method for storing a data type is provided, comprising:

[0006] Acquire data to be verified, where the data to be verified includes data of enumeration type and / or data of collection type;

[0007] Using the standard string information in the trigger statement to verify the data to be verified, and obtaining a verification result; wherein the standard string information includes at least one standard string data, and the standard string data includes a comma separator;

[0008] When the verification result shows that the data to be converted is legal, the data to be verified is stored in a preset data type column in a standard string format.

[0009] In a second aspect, a storage device for a data type is provided, comprising:

[0010] A data acquisition module, used to acquire data to be verified, wherein the data to be verified includes enumerated type data and / or set type data;

[0011] A verification module, used to verify the data to be verified using the standard string information in the trigger statement to obtain a verification result; wherein the standard string information includes at least one standard string data, and the standard string data includes a comma separator;

[0012] The storage module is used to store the data to be verified in a preset data type column in a standard string format when the verification result is that the data to be converted is legal.

[0013] In a third aspect, an electronic device is provided, including:

[0014] one or more processors;

[0015] a storage device for storing one or more programs,

[0016] When the one or more programs are executed by the one or more processors, the one or more processors implement the method for storing data types as described in the first aspect above.

[0017] In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, the method for storing data types as described in the first aspect above is implemented.

[0018] In a fifth aspect, a computer program product is provided, the computer program product comprising a computer program, wherein the computer program, when executed by a processor, implements the method for storing data types as described in the first aspect above.

[0019] The disclosed embodiments disclose a method, apparatus, device, medium and product for storing data types, including: obtaining data to be verified, wherein the data to be verified includes data of enumeration type and / or data of collection type; verifying the data to be verified using standard string information in a trigger statement to obtain a verification result; wherein the standard string information includes at least one standard string data, and the standard string data includes a comma separator; if the verification result is that the verification to be converted is legal, storing the data to be verified in a preset data type column in a standard string format. The technical party uses the standard string information in the trigger statement to verify the data to be verified, and if the verification is legal, stores the data to be verified in a preset data type column in a standard string format, thereby improving the accuracy of data type storage.

[0020] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the embodiments of the present disclosure. Other features of the embodiments of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0022] Figure 1 is a flowchart of a method for storing a data type provided in the first embodiment of the present disclosure;

[0023] Figure 2 It is a schematic diagram of the execution process of a trigger statement provided in the first embodiment of the present disclosure;

[0024] Figure 3 It is a schematic diagram of a process of storing data types based on preset data columns provided in the first embodiment of the present disclosure;

[0025] Figure 4 It is a schematic diagram of a process of performing data type storage conversion when inserting or updating table data, provided by the first embodiment of the present disclosure;

[0026] Figure 5 It is a structural diagram of a storage device of a data type provided in the second embodiment of the present disclosure;

[0027] Figure 6 It is a structural diagram of an electronic device provided in Embodiment 3 of the present disclosure. DETAILED DESCRIPTION

[0028] In order to enable those skilled in the art to better understand the solutions of the embodiments of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only embodiments of a part of the embodiments of the present disclosure, rather than all of the embodiments. Based on the embodiments in the embodiments of the present disclosure, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the embodiments of the present disclosure.

[0029] It should be noted that the terms "first", "second", etc. in the specification and claims of the embodiments of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product, or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products, or devices.

[0030] Embodiment 1

[0031] Figure 1 This is a flowchart of a method for storing a data type provided in the first embodiment of the present disclosure. This embodiment is applicable to the case of storing data types. The method can be executed by a storage device for the data type. The storage device for the data type can be implemented in the form of hardware and / or software. The storage device for the data type can be configured in an electronic device, including but not limited to computers, computers, terminals, servers and other devices with data processing capabilities. Figure 1 As shown, the method includes:

[0032] S110, obtaining data to be verified, where the data to be verified includes enumeration type data and / or set type data.

[0033] In this embodiment, data to be verified can be obtained, wherein the data to be verified may be data that needs to be stored in a data type, such as: the data to be verified may be data of an enumeration type and / or data of a collection type, wherein the enumeration type may allow the value of a column to be restricted to a value in a predefined enumeration set (standard string data), and the collection type may allow the value of a column to be a collection of multiple predefined enumeration values ​​(standard string data).

[0034] S120. Use the standard string information in the trigger statement to verify the data to be verified to obtain a verification result; wherein the standard string information includes at least one standard string data, and the standard string data includes a comma separator.

[0035] Specifically, after receiving the data to be verified, the standard string information in the trigger statement can be used to verify the data to be verified, such as: the verification of the data to be verified can be achieved by judging whether the content of the data to be verified is consistent with the standard string information. The data to be verified is verified by the standard string information, and then a verification result can be obtained. Among them, the standard string information includes at least one standard string data, and the standard string data includes a comma separator. The standard string data can be data used to verify the acquired data to be verified. Exemplary standard string data can be Yes, No, and the standard string data are separated by comma separators.

[0036] Among them, the trigger statement can be a special type of stored procedure in the database management system, which is automatically executed before or after a specific database operation. Triggers can be used to maintain data integrity, implement complex business rules, automatically fill in data, record data change history, etc. In this embodiment, the trigger statement can be used to determine whether the data to be converted conforms to the standard string information before insertion and update. Among them, the standard string information includes enumeration type standard string information and / or collection type standard string information, the standard string information includes at least one standard string data, and the standard string data includes a comma separator, such as: the enumeration type standard string information can be (Yes, No), and the collection type standard string information can be (Select, Insert, Update, Delete).

[0037] For example, the trigger statement may be CREATE TRIGGER T1_C1_TRION T1, where CREATETRIGGER is a SQL command for creating a new trigger, and T1_C1_TRI may be the name of the trigger, which may be automatically generated without user specification. In this example, the trigger is named T1_C1_TRI, and ON T1 specifies the table name T1 to which the trigger will be bound. This means that the trigger will react to operations performed on table T1.

[0038] S130. When the verification result shows that the data to be converted is legal, the data to be verified is stored in a preset data type column in a standard string format.

[0039] It can be known that the data to be verified is verified through the standard string information, the result to be verified is determined, and whether the data to be verified is legal is determined according to the result to be verified, wherein determining whether the data to be verified is legal can be understood as judging whether the data to be verified is consistent with the standard string information, and if it is consistent, it can be considered legal. Exemplary: whether the data to be converted is legal can be determined by judging whether the data to be verified is the same as the standard string data in the standard string information. When the data to be verified is legal, the data to be verified can be stored in a preset data type column in the format of the standard string. Among them, the preset data type can be a pre-set data type, such as: the preset data type can be CHAR(n), CHAR(n) can be used to define a column of a string type with a fixed length of n, and n can be a positive integer representing the number of characters that the column can store. When the length of the inserted string is less than n, the remaining space can be filled with spaces to ensure that the length of all values ​​in the column is consistent.

[0040] It should be noted that the data to be verified may include data of enumeration type and / or data of collection type, and the preset data type column needs to store data of the preset data type. In this embodiment, the preset data type may be CHAR(n). Therefore, the data of the enumeration type and / or collection type is stored in the CHAR(n) column and needs to be converted into CHAR type before storage. At this time, CHAR(n) does not include the semantics of the data to be verified, wherein the semantics may be the actual meaning of the data to be converted. Therefore, the process of verifying whether the data to be verified is legal based on the standard string information in the trigger statement can be understood as the process of determining the semantics of the data to be verified.

[0041] Exemplarily, when the data to be verified is legal, the semantics of the standard string data can be used as the semantics of the data to be verified stored in the preset data type column, such as: the definition of the enumeration type can be expressed as C1 ENUM ('Yes', 'No'), and the converted preset data type column can be expressed as C1CHAR (3). When the data to be verified is 'Yes', the legality of the data to be verified 'Yes' is determined by verifying the standard string information (Yes, No). The data to be verified 'Yes' can be stored in the preset data type column according to the "Yes" in the standard string format (Yes, No), and the semantics of the CHAR (3) column as ENUM ('Yes', 'No') can be maintained.

[0042] The present embodiment provides a method for storing data types, including: obtaining data to be verified, the data to be verified including data of enumeration type and / or data of collection type; verifying the data to be verified using standard string information in a trigger statement to obtain a verification result; wherein the standard string information includes at least one standard string data, and the standard string data includes a comma separator; if the verification result is that the verification to be converted is legal, storing the data to be verified in a preset data type column in the format of a standard string. The present technical party verifies the data to be verified using the standard string information in the trigger statement, and if the verification is legal, stores the data to be verified in a preset data type column in the format of a standard string, thereby improving the accuracy of data type storage.

[0043] As an optional implementation of this embodiment, the data to be verified may be of an enumeration type, and the method of verifying the data to be verified by using the standard string information in the trigger statement includes:

[0044] Determine whether the data type to be checked is the same as any standard string data in the standard string information when the data type is not case-sensitive, and if so, determine that the data type to be checked is legal;

[0045] Specifically, when the data to be verified is of an enumeration type, according to the characteristics of the enumeration type: that is, the enumeration type can allow the value of the column to be restricted to a value in the standard string data, it can be determined whether the data to be verified is the same as any standard string data in the standard string information without being case-sensitive. If they are the same, it can be determined that the data to be verified is legal.

[0046] For example, if the data of the enumerated type to be verified is Yes, and the standard string data in the standard string information is Yes, No, it can be considered that the data of the enumerated type is the same as any one (Yes) standard string data in the standard string information. If the data of the enumerated type to be verified is Yse, it can be considered that the data of the enumerated type is different from the standard string data in the standard string information.

[0047] As an optional implementation of this embodiment, the data to be verified may be of a set type; and verifying the data to be verified using the standard string information in the trigger statement includes:

[0048] Determine whether the data to be verified is a subset of the standard string data set in the standard string information when the data is not case-sensitive and not repeated; if so, determine that the data to be converted is legal;

[0049] Specifically, when the data to be verified is a set type of data, according to the characteristics of the set type: that is, the set type can allow the value of a column to be a set of multiple standard string data, when the data to be verified is a set type of data, the data to be verified can be determined by judging whether the set type of data to be verified is a subset of the standard string data set in the standard string information of the set type when it is not case sensitive and repetitive. If so, it can be determined that the set type of data to be verified is legal.

[0050] Exemplarily, the data of the set type to be verified is (Select, Insert), and the standard string data of the set type is (Select, Insert, Update, Delete). If the standard string data of the set type is regarded as a set, it can be confirmed that (Select, Insert) is a subset of the set, and then it can be determined that (Select, Insert) is legal; the data of the set type is (Select, Inse), and the standard string information is (Select, Insert, Update, Delete). It can be determined that (Select, Inse) is not a subset of the set, and then it can be determined that (Select, Inse) is illegal.

[0051] It should be noted that when the data to be verified is a set type of data, and contains multiple identical data, it is possible to determine whether one of the identical data is a subset of the standard string data set of the set type, thereby determining whether the set type of data to be verified is legal.

[0052] Exemplarily, the data of the collection type is (Select, Select, Select), the standard string information is (Select, Insert, Update, Delete), and Select is a subset of (Select, Insert, Update, Delete), then it can be determined that (Select, Select, Select) is legal.

[0053] Figure 2 A schematic diagram of the execution process of a trigger statement provided in this embodiment, such as Figure 2 As shown, first obtain the stored standard string information, and obtain the input data to be verified, traverse the data to be verified to determine whether the data to be verified conforms to the standard string information. If not, the data is determined to be illegal. If it conforms, the template (standard format) in the standard string data can be obtained, and the data to be verified is stored in the preset data type column according to the template (standard format) in the standard string data.

[0054] As an optional implementation of this embodiment, before obtaining the data to be verified, the method further includes:

[0055] a1) determining corresponding preset data type information based on the column definition of the data type to be converted, wherein the preset data type information includes the preset data type and the precision of the preset data type, wherein the precision includes a first precision and a second precision; the data type to be converted includes an enumeration type and a set type;

[0056] In this embodiment, the corresponding preset data type information can be determined based on the column definition of the data type to be converted, wherein the data type to be converted can be a data type that needs to be converted, such as an enumeration type and / or a collection type. The column definition can be preset (it can also be understood that the column definition is given in advance). The column definition of the data type to be converted includes the data type to be converted and / or a set of values ​​of the data type to be converted, the data type to be converted includes an enumeration type and / or a collection type, and the set of values ​​of the data type to be converted includes a set of enumeration type values ​​and a set of collection type values.

[0057] Specifically, the corresponding preset data type information can be determined based on the column definition of the data type to be converted, wherein the preset data type information can include the preset data type and the precision of the preset data type, and the precision can include the first precision and the second precision, wherein the first precision can be the precision of the preset data type corresponding to the enumeration type, and the first precision can be consistent with the maximum string length in the set of enumeration type values; the second precision can be the precision of the preset data type corresponding to the set type, and the second precision can be consistent with the standard string length of the set type. Exemplarily, the data of the enumeration type includes ('Yes', 'No'), the preset data type information corresponding to the enumeration type can be CHAR(3), the preset data type can be CHAR type, and 3 can be the first precision of the preset data type corresponding to the enumeration type (the maximum string length in the set of enumeration type values); the data of the set type includes (Select, Insert, Update, Delete), the preset data type information corresponding to the set type can be CHAR(27), the preset data type can be CHAR type, and 27 can be the second precision of the preset data type corresponding to the set type (the standard string length of the set type).

[0058] b1) using create table and modify table statements, creating a preset data type column corresponding to the first precision and a preset data type column corresponding to the second precision according to the preset data type information;

[0059] Specifically, after obtaining the preset data type information, a preset data type column corresponding to the first precision and a preset data type column corresponding to the second precision can be created using create table and modify table statements according to the preset data type information. In this embodiment, the create table and modify table statements can be statements used to create or modify tables in a database language, wherein the create table statement can be CREATE TABLE.

[0060] For example, the table creation statement can be expressed as CREATE TABEL T1(C1 CHAR(3), C2CHAR(27)), where CREATE TABLE T1: This part can indicate the creation of a new table named T1; (C1 CHAR(3), C2 CHAR(27)): It can be understood as defining two columns: the enumeration type column C1 and the collection type column C2, using the CHAR(n) data type, where n represents the first precision and second precision of the string. C1 CHAR(3): It can indicate that the C1 column stores the data converted from the enumeration type according to the first precision of 3; C2 CHAR(27): It can indicate that the C2 column stores the data converted from the collection type according to the second precision of 27.

[0061] As an optional implementation of this embodiment, the column definition of the data type to be converted includes the data type to be converted and / or a set of values ​​of the data type to be converted, the data type to be converted includes an enumeration type and / or a set type, and the set of values ​​of the data type to be converted includes a set of enumeration type values ​​and a set of set type values; the standard string information includes standard string information of the enumeration type and / or standard string information of the set type,

[0062] The data type storage method provided in this embodiment may further include a process of determining standard string information. When the data type to be converted is an enumeration type, the process of determining the standard string information includes:

[0063] a2) determining a first standard string of data according to a set of enumeration type values;

[0064] Specifically, when the data to be converted is an enumeration type, the first standard string data can be determined according to the set of values ​​of the enumeration type in the column definition, wherein the first standard string data can be the standard string data corresponding to the enumeration type, and the content of the first standard string data can be consistent with the set of values ​​of the enumeration type. Exemplarily, the set of values ​​of the enumeration type can be expressed as (Yes, No), and (Yes, No) can be determined as the first standard string data.

[0065] b2) determining standard string information of an enumerated type according to the first standard string data, the standard string information of the enumerated type including at least one first standard string data and / or a standard string label;

[0066] Continuing with the above description, after obtaining the first standard string data, the standard string information of the enumeration type can be determined according to the first standard string data. After obtaining the standard string information of the enumeration type, the standard string information of the enumeration type can be stored using a storage structure, wherein the standard string information of the enumeration type can include at least one first standard string data and / or a standard string label, and the standard string label can be used to calibrate the data type corresponding to the standard string information. Exemplarily, the first standard string data can be (Yes, No), and the standard string information of the enumeration type can include (Yes, No) and the enumeration type.

[0067] When the data type to be converted is a set type, the process of determining the standard string information includes:

[0068] a3) determining the second standard string data according to the set of set type values;

[0069] Specifically, when the data to be converted is an enumeration type, the second standard string data can be determined according to the set data of the set type value in the column definition. The first standard string data can be the standard string data corresponding to the set type, and the content of the second standard string data can be consistent with the set of the set type value. Exemplary: the set of the set type value can be (Select, Insert, Update, Delete), then (Select, Insert, Update, Delete) can be determined as the second standard string data.

[0070] b3) determining the standard string information of the set type according to the second standard string data, the standard string information of the set type including at least one second standard string data, a standard string length and / or a standard string tag; wherein the standard string tag is used to calibrate the data type corresponding to the standard string information;

[0071] Continuing with the above description, after obtaining the second standard string data, the standard string information of the set type can be determined according to the second standard string data. After obtaining the standard string information of the set type, the standard string information of the set type can be stored using a storage structure, wherein the standard string information of the set type can include at least one standard string data, a standard string length and / or a standard string tag, the standard string length can be used to indicate the length of all standard string data, and the standard string tag can be used to calibrate the data type corresponding to the standard string information. It should be explained that the second precision can be consistent with the standard string length.

[0072] Exemplarily, the second standard string data may be (Select, Insert, Update, Delete), and the standard string information of the set type may include (Select, Insert, Update, Delete), 27 and the set type.

[0073] The following is a specific example to illustrate the storage method of the data type provided by the present application. Taking the ENUM and SET data types as examples, the storage support for the ENUM and SET data types may involve the creation and modification of tables, and the insertion and update processing of table data. The overall idea is to convert ENUM and SET into CHAR(n) during the syntax parsing stage of creating a table, and create corresponding verification triggers before insertion and update.

[0074] (1) Parsing ENUM and SET column standard strings at the word syntax stage

[0075] Try to create a table with ENUM and SET columns, for example:

[0076] CREATE ATBEL T1(

[0077] C1 ENUM('Yes','No'),

[0078] C2 SET('Select', 'Insert', 'Update', 'Delete') );

[0080] Among them, C1 and C2 are ENUM and SET columns. After verification, there are no duplicate values ​​and they meet the preset definition. The standard string of C1 column is (Yes, No); the standard string of C2 column is (Select, Insert, Update, Delete). First, convert the SET and ENUM columns to CHAR(n) columns, which is equivalent to converting into the following statement:

[0081] CREATE ATBEL T1(

[0082] C1 CHAR(3),

[0083] C2 CHAR(27) );

[0085] Here, the length of the ENUM column after conversion is based on the maximum character length of the character length of the ENUM type data C1 that conforms to the preset definition, and the length of the SET column after conversion is based on the standard string length of the set type data C2 that conforms to the preset definition.

[0086] The relevant pseudo code implemented in the .y file is as follows:

[0087] datatype:

[0088] normal datatype

[0089] |ENUM(string_list)

[0090] {

[0091] 1. Determine whether the enumeration type data string_list contains duplicate values ​​and determine the ENUM column definition.

[0092] 2. Record the maximum ENUM item length as n and the standard string length.

[0093] 3. Convert ENUM type to CHAR(n).

[0094] 4. Record standard string data, standard string labels and other information for subsequent creation of corresponding triggers.

[0095] }

[0096] |SET(string_list)

[0097] {

[0098] 1. Determine whether the set type data string_list contains duplicate values ​​and determine the SET column definition.

[0099] 2. Record the standard string length as n.

[0100] 3. Convert the SET type to CHAR(n).

[0101] 4. Record information such as standard string data, standard string length, and standard string label for subsequent creation of corresponding trigger statements.

[0102] }

[0103] (2) Constructing trigger statements to assign semantics to ENUM and SET types

[0104] Create a trigger statement for each ENUM and SET column to determine whether the data conforms to the items in the standard string information before inserting and updating. If the data to be converted conforms to the standard string data in the standard string information, the semantics of ENUM and SET are inserted or updated into the table as the semantics of the converted CHAR(n) according to the standard string template; if not, an error "illegal data" should be reported. The basic logical functions implemented by the trigger are as follows:

[0105] 1) Obtain the standard string information obtained in the word grammar stage.

[0106] 2) Determine whether ENUM and SET data conform to standard string information before inserting or updating.

[0107] 3) If it is compliant, the semantics of ENUM and SET are used as the semantics of the converted CHAR(n) and inserted into the table. You can also use the order and format of each item in the standard string data to determine whether it complies with the standard string information. If it does not comply, remove it; if it complies, insert it.

[0108] (3) Convert the SQL statement for creating a table with ENUM and SET columns into a statement block

[0109] The table creation statement containing ENUM and SET columns is parsed at the syntax level and converted into a statement block. This statement block contains two SQL functions: one is the table creation statement containing the converted data type, which is used to create the table; the other is the verification trigger statement created on the ENUM and SET columns, which is used to give the semantics of the ENUM and SET columns. It is equivalent to the following statement:

[0110] BEGIN

[0111] --Create table

[0112] CREATE ATBEL T1(C1 CHAR(3),C2 CHAR(27));

[0113] --Create trigger

[0114] CREATE TRIGGER T1_C1_TRION T1...--For checking before inserting and updating C1 column

[0115] CREATE TRIGGER T1_C2_TRION T1...--For checking before inserting and updating the C2 column

[0116] END;

[0117] Parse and execute the statement block again to implement the conversion support for ENUM and SET columns: create a table with mapping columns and create a trigger for assigning ENUM and SET column semantics.

[0118] Figure 3 A schematic diagram of a process for storing data types based on preset data columns provided in this embodiment, such as Figure 3 As shown, the table creation and table modification statements are parsed to create preset data type columns. When the column definition contains ENUM and SET columns, the ENUM and SET column definitions can be used to determine the standard string information and CHAR(n). The preset data type column is determined based on CHAR(n). A trigger statement is created based on the standard string information. The data to be verified is verified based on the preset data type column and the trigger statement to provide support for data type storage of ENUM and SET types.

[0119] (4) Based on this method, we can improve the support for ENUM and SET data types.

[0120] Similarly, when modifying a table by ADDing a single column, ADDing multiple columns, MODIFYing a single column, or MODIFYing multiple columns, ENUM or SET columns must be converted accordingly. When adding or converting a normal column to an ENUM or SET column, a validation trigger must be added; when converting an ENUM or SET column to an ENUM or SET column, Delete first and then add triggers ; When ENUM and SET columns are converted to ordinary columns, the corresponding triggers are deleted. When modifying a table to delete ENUM and SET columns, the corresponding validation triggers need to be deleted in cascade.

[0121] (5) Support for data type conversion is achieved through syntax analysis and trigger verification

[0122] After the table is created successfully, insert data into the table. The trigger verifies whether it is legal. If it is legal, insert the data. If it is inserted into the table according to the standard string format, take the following data as an example:

[0123] INSERT INTO T1 VALUES(

[0124] 'yes',

[0125] 'DELETE,update,Insert,Select,Update' );

[0127] After successfully inserting the data, query the table and there should be a column of data as follows:

[0128] ('Yes','Select,Insert,Update,Delete')

[0129] It can be considered that storage support for ENUM and SET data types has been achieved to a certain extent.

[0130] Figure 4 A schematic diagram of a data type storage process provided in this embodiment, such as Figure 4As shown, when it is necessary to insert or update ENUM and SET, the ENUM and SET data to be checked can be obtained first, and a general check can be performed on the obtained ENUM and SET data. The general check can be used to determine the data type of the obtained data, whether there are missing values, blank fields, etc.; after the obtained data passes the general check, it is determined whether the ENUM and SET data to be checked conforms to the standard string information in the trigger statement. If not, it is determined that the ENUM and SET data to be checked are illegal. If they conform, the data to be checked is stored in the preset data type column in the format of the standard string. When mapping the ENUM and SET data types to CHAR(n), the semantics of the ENUM and SET data are taken into consideration, thereby improving the accuracy of the data type conversion process.

[0131] Embodiment 2

[0132] Figure 5 is a structural diagram of a storage device of a data type provided in the second embodiment of the present disclosure; Figure 5 As shown, the device includes: a data acquisition module 210, a verification module 220, and a storage module 230.

[0133] The data acquisition module 210 is used to acquire the data to be verified, wherein the data to be verified includes enumerated type data and / or set type data;

[0134] The verification module 220 is used to verify the data to be verified using the standard string information in the trigger statement to obtain a verification result; wherein the standard string information includes at least one standard string data, and the standard string data includes a comma separator;

[0135] The storage module 230 is used to store the data to be verified in a preset data type column in a standard string format when the verification result is that the data to be converted is legal.

[0136] A second embodiment of the present disclosure provides a storage device for data types, which improves the accuracy of data type storage.

[0137] Furthermore, the data to be converted is of an enumeration type; the verification module 220 may further include:

[0138] It is determined whether the data type to be checked is the same as any standard string data in the standard string information when the data type is not case-sensitive. If the data type to be checked is the same as any standard string data in the standard string information, it is determined that the data to be checked is legal.

[0139] Furthermore, the data to be converted is of set type; the verification module 220 may further include:

[0140] It is determined whether the data to be verified is a subset of the standard string data set in the standard string information when the data is not case-sensitive and not repeated; if so, it is determined that the data to be converted is legal.

[0141] Furthermore, the device also includes:

[0142] A preset data type information acquisition module, used to determine corresponding preset data type information based on the column definition of the data type to be converted, wherein the preset data type information includes the preset data type and the precision of the preset data type, wherein the precision includes a first precision and a second precision; the data type to be converted includes an enumeration type and a set type;

[0143] The preset data type column creation module is used to create a preset data type column corresponding to the first precision and a preset data type column corresponding to the second precision according to the preset data type information by using create table and modify table statements.

[0144] Further, the column definition of the data type to be converted includes the data type to be converted and / or a set of values ​​of the data type to be converted, the data type to be converted includes an enumeration type and / or a set type, and the set of values ​​of the data type to be converted includes a set of enumeration type values ​​and a set of set type values;

[0145] The standard string information includes enumerated type standard string information and / or set type standard string information, and the device further includes: a standard string information determination module;

[0146] The standard string information determination module is used for:

[0147] Determine a first standard string of data according to a set of enumeration type values;

[0148] Determine standard string information of an enumerated type according to the first standard string data, where the standard string information of the enumerated type includes at least one first standard string data and / or a standard string label;

[0149] The standard string information determination module is further used for:

[0150] Determine the second standard string data according to the set of set type values;

[0151] Determine the standard string information of the set type according to the second standard string data, where the standard string information of the set type includes at least one second standard string data, a standard string length and / or a standard string tag;

[0152] The standard string label is used to identify the data type corresponding to the standard string information.

[0153] Furthermore, the first precision is the maximum string length in the set of enumeration type values;

[0154] The second precision is the standard string length.

[0155] The storage device for data types provided in the embodiments of the present disclosure can execute the storage method for data types provided in any embodiment of the present disclosure, and has functional modules and beneficial effects corresponding to the execution method.

[0156] Embodiment 3

[0157] Figure 6 A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present disclosure 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 components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the embodiments of the present disclosure described and / or claimed herein.

[0158] like Figure 6 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0159] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0160] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microprocessor, etc. The processor 11 performs the various methods and processes described above, such as a storage method for data types.

[0161] In some embodiments, the storage method of the data type may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the storage method of the data type described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to execute the storage method of the data type in any other appropriate manner (e.g., by means of firmware).

[0162] Various implementations 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 chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0163] The computer programs for implementing the methods of the embodiments of the present disclosure 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, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine as a stand-alone software package and partially on a remote machine, or entirely on a remote machine or server.

[0164] In the context of the disclosed embodiments, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, device, or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0165] To provide interaction with a user, the systems and techniques described herein may 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 a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).

[0166] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0167] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.

[0168] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in the embodiments of the present disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions of the embodiments of the present disclosure can be achieved, and this document does not limit this.

[0169] The above specific implementations do not constitute a limitation on the protection scope of the embodiments of the present disclosure. It should be understood by those skilled in the art 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 the embodiments of the present disclosure shall be included in the protection scope of the embodiments of the present disclosure.

[0170] The embodiments of the present disclosure also provide a computer program product, including a computer program and / or instructions, which, when executed by a processor, implements a method for storing data types as provided in any embodiment of the present application.

[0171] In the process of implementation, the computer program product can be written in one or more programming languages ​​or a combination thereof to write computer program codes for performing the operation of the disclosed embodiments, the programming languages ​​including object-oriented programming languages, such as Java, Smalltalk, C++, and also including conventional procedural programming languages, such as "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (e.g., using an Internet service provider to connect through the Internet).

[0172] Note that the above are only preferred embodiments of the embodiments of the present disclosure and the technical principles used. Those skilled in the art will understand that the embodiments of the present disclosure are not limited to the specific embodiments herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the protection scope of the embodiments of the present disclosure. Therefore, although the embodiments of the present disclosure are described in more detail through the above embodiments, the embodiments of the present disclosure are not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the embodiments of the present disclosure, and the scope of the embodiments of the present disclosure is determined by the scope of the attached claims.

Claims

1. A method for storing data types, characterized in that: include: Acquire data to be verified, where the data to be verified includes data of enumeration type and / or data of collection type; Using the standard string information in the trigger statement to verify the data to be verified, and obtaining a verification result; wherein the standard string information includes at least one standard string data, and the standard string data includes a comma separator; When the verification result shows that the data to be converted is legal, the data to be verified is stored in a preset data type column in a standard string format.

2. The method according to claim 1, characterized in that The data to be verified is of an enumeration type; and the method of verifying the data to be verified by using the standard string information in the trigger statement includes: It is determined whether the data type to be checked is the same as any standard string data in the standard string information when the data type is not case-sensitive. If the data type to be checked is the same as any standard string data in the standard string information, it is determined that the data to be checked is legal.

3. The method according to claim 1, characterized in that The data to be verified is of a set type; and the method of verifying the data to be verified by using the standard string information in the trigger statement includes: It is determined whether the data to be verified is a subset of the standard string data set in the standard string information when the data is not case-sensitive and not repeated; if so, it is determined that the data to be converted is legal.

4. The method according to claim 1, characterized in that: Before obtaining the data to be verified, the method further includes: Determine corresponding preset data type information based on the column definition of the data type to be converted, the preset data type information includes the preset data type and the precision of the preset data type, the precision includes a first precision and a second precision; the data type to be converted includes an enumeration type and a collection type; Using create table and modify table statements, a preset data type column corresponding to the first precision and a preset data type column corresponding to the second precision are created according to the preset data type information.

5. The method according to claim 4, characterized in that The column definition of the data type to be converted includes the data type to be converted and / or a set of values ​​of the data type to be converted, the data type to be converted includes an enumeration type and / or a set type, and the set of values ​​of the data type to be converted includes a set of enumeration type values ​​and a set of set type values; The standard string information includes enumerated type standard string information and / or set type standard string information, and the determination process of the standard string information includes: Determine a first standard string of data according to a set of enumeration type values; Determine standard string information of an enumerated type according to the first standard string data, where the standard string information of the enumerated type includes at least one first standard string data and / or a standard string label; Determine the second standard string data according to the set of set type values; Determine the standard string information of the set type according to the second standard string data, where the standard string information of the set type includes at least one second standard string data, a standard string length and / or a standard string tag; The standard string label is used to identify the data type corresponding to the standard string information.

6. The method according to claim 5, characterized in that The first precision is the maximum string length in the set of enumeration type values; The second precision is the standard string length.

7. A storage device for a data type, characterized in that: include: A data acquisition module, used to acquire data to be verified, wherein the data to be verified includes enumerated type data and / or set type data; A verification module, used to verify the data to be verified using the standard string information in the trigger statement to obtain a verification result; wherein the standard string information includes at least one standard string data, and the standard string data includes a comma separator; The storage module is used to store the data to be verified in a preset data type column in a standard string format when the verification result is that the data to be converted is legal.

8. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method for storing the data type as described in any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, a method for storing data types as described in any one of claims 1 to 6 is implemented.

10. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the computer program implements the method for storing the data type according to any one of claims 1 to 6.