CN113505128A - Method, device and equipment for creating data table and storage medium - Google Patents

Method, device and equipment for creating data table and storage medium Download PDF

Info

Publication number
CN113505128A
CN113505128A CN202110736351.9A CN202110736351A CN113505128A CN 113505128 A CN113505128 A CN 113505128A CN 202110736351 A CN202110736351 A CN 202110736351A CN 113505128 A CN113505128 A CN 113505128A
Authority
CN
China
Prior art keywords
field
database
type
field type
information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202110736351.9A
Other languages
Chinese (zh)
Other versions
CN113505128B (en
Inventor
杨勇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN202110736351.9A priority Critical patent/CN113505128B/en
Priority claimed from CN202110736351.9A external-priority patent/CN113505128B/en
Publication of CN113505128A publication Critical patent/CN113505128A/en
Application granted granted Critical
Publication of CN113505128B publication Critical patent/CN113505128B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2282Tablespace storage structures; Management thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Computing Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Stored Programmes (AREA)

Abstract

The application is applicable to the technical field of database processing, and provides a method, a device, equipment and a storage medium for creating a data table. The method comprises the following steps: acquiring the type and field name of an input first database and first information corresponding to the field name; determining a corresponding target field type of the first information in a second database according to the first information and a preset mapping relation; generating a table building statement corresponding to the field name and the target field type according to the field name and the target field type; and creating a data table in the second database according to the table building statement. In the scheme, no matter the data table is directly created or created during data synchronization, a user does not need to master the characteristics of various databases, the whole data table creating step is simple, the user does not need to master the characteristics of the various databases, data synchronization scripts, configuration synchronization parameters and the like are not needed, the cost for creating the data table is saved, the efficiency for automatically creating the data table is high, and errors are not easy to occur.

Description

Method, device and equipment for creating data table and storage medium
Technical Field
The present application relates to the field of database processing technologies, and in particular, to a method, an apparatus, a device, and a storage medium for creating a data table.
Background
When a user creates a data table in a database, the user needs to use the table building statement of each database, and the characteristics and the use mode of various data types of each database need to be clearly known.
Or, when creating a data table during data synchronization, developers need to be familiar with the characteristics of various databases, various data types corresponding to each database and the use mode of each database, write a data synchronization script according to the information, configure synchronization parameters, and continuously adjust and test the synchronization of the data.
The inventor realizes that in the prior art, no matter the data table is created directly or when data is synchronized, a user needs to master the characteristics of various databases, so that a lot of time is spent, the steps are complicated, the efficiency of creating the data table is low, the cost is high, and errors are easy to occur.
Disclosure of Invention
In view of this, embodiments of the present application provide a method, an apparatus, a device, and a storage medium for creating a data table. The method and the device solve the problems that in the prior art, no matter the data table is created directly or during data synchronization, a user needs to master the characteristics of various databases, a large amount of time is spent, the steps are complicated, and the data table creation efficiency is low, the cost is high, and errors are easy to occur.
A first aspect of an embodiment of the present application provides a method for creating a data table, where the method includes:
acquiring the type and field name of an input first database and first information corresponding to the field name;
determining a corresponding target field type of the first information in a second database according to the first information and a preset mapping relation;
generating a table building statement corresponding to the field name and the target field type according to the field name and the target field type;
and creating a data table in the second database according to the table building statement.
Optionally, when the first database is the second database, the first information is attribute information, and the obtaining the input type of the first database, the field name, and the first information corresponding to the field name includes:
the method comprises the steps of obtaining the type and field name of an input first database and attribute information corresponding to the field name, wherein the attribute information comprises at least one of character strings, texts, integers, decimal numbers, time and IP addresses.
Optionally, determining a target field type corresponding to the first information in a second database according to the first information and a preset mapping relationship, including:
extracting keywords corresponding to the attribute information;
and searching a field type matched with the keyword corresponding to the attribute information based on a preset mapping relation to obtain the target field type.
Optionally, when the first database is different from the second database, the first information is a field type corresponding to the field name, and the obtaining the input type of the first database, the field name, and the first information corresponding to the field name includes:
acquiring the type and an original table of an input second database;
and extracting field names and field types corresponding to the field names from the original table.
Optionally, the determining, according to the first information and a preset mapping relationship, a target field type corresponding to the first information in a second database includes:
acquiring a priority corresponding to each preset field type in a preset first configuration table, wherein each preset field type corresponds to the second database;
and in all the preset field types corresponding to the second database, sequencing each preset field type according to the priority corresponding to each preset field type, and sequentially searching for the target field type corresponding to the field type according to the sequencing result.
Optionally, the determining, according to the first information and a preset mapping relationship, a target field type corresponding to the first information in a second database includes:
acquiring the priority corresponding to each parent field type in a preset second configuration table, wherein each parent field type corresponds to the target database;
in all the parent field types corresponding to the second database, sequencing each parent field type according to the priority corresponding to each parent field type, and sequentially searching a target parent field type corresponding to the field type according to a sequencing result;
acquiring the priority corresponding to each subfield type, wherein each subfield type corresponds to the target parent field type;
and in all the sub-field types corresponding to the target parent field type, sorting each sub-field type according to the priority corresponding to each sub-field type, and sequentially searching the target field type corresponding to the field type according to the sorting result.
Optionally, the method further comprises:
determining the number of times each preset field type in the first configuration table is used;
and adjusting the priority corresponding to each preset field type according to the number of times that each preset field type is used.
A second aspect of an embodiment of the present application provides an apparatus for creating a data table, including:
the system comprises an acquisition unit, a storage unit and a display unit, wherein the acquisition unit is used for acquiring the type, the field name and first information corresponding to the field name of an input first database;
the determining unit is used for determining a corresponding target field type of the first information in a second database according to the first information and a preset mapping relation;
the generating unit is used for generating a table building statement corresponding to the field name and the target field type according to the field name and the target field type;
and the creating unit is used for creating a data table in the second database according to the table building statement.
A third aspect of the embodiments of the present application provides an apparatus for creating a data table, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the steps of the method for creating a data table according to the first aspect.
A fourth aspect of embodiments of the present application provides a computer-readable storage medium, which stores a computer program that, when executed by a processor, implements the steps of the method of creating a data table as described in the first aspect above.
A fifth aspect of embodiments of the present application provides a computer program product, which, when run on an apparatus for creating a data table, causes the apparatus to perform the steps of the method for creating a data table according to the first aspect.
The method, the device, the equipment and the storage medium for creating the data table provided by the embodiment of the application have the following beneficial effects:
the method comprises the steps of firstly obtaining the type and the field name of an input first database and first information corresponding to the field name, and no matter whether a data table is directly created or created during data synchronization, a user does not need to master the characteristics of various databases. Then automatically generating a table building statement corresponding to the field name and the target field type according to the field name and the target field type; and creating a data table in the second database according to the table building statement. The whole step of creating the data table is simple, a user does not need to master the characteristics of various databases, data synchronization scripts do not need to be compiled, synchronization parameters do not need to be configured, and the like, so that the cost of creating the data table is saved, the efficiency of automatically creating the data table is high, and errors are not easy to occur.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
FIG. 1 is a schematic flow chart diagram of a method for creating a data table according to an embodiment of the present application;
FIG. 2 is a flowchart illustrating in detail step S102 of a method for creating a data table according to an exemplary embodiment of the present application;
FIG. 3 is a flowchart illustrating in detail step S102 of a method for creating a data table according to an exemplary embodiment of the present application;
FIG. 4 is a flowchart detailing step S102 of a method for creating a data table according to yet another exemplary embodiment of the present application;
FIG. 5 is a diagram illustrating an apparatus for creating a data table according to an embodiment of the present application;
fig. 6 is a schematic diagram of an apparatus for creating a data table according to another embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
In the description of the embodiments of the present application, "/" means "or" unless otherwise specified, for example, a/B may mean a or B; "and/or" herein is merely an association describing an associated object, and means that there may be three relationships, e.g., a and/or B, which may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, in the description of the embodiments of the present application, "a plurality" means two or more than two.
In the following, the terms "first", "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of the present embodiment, "a plurality" means two or more unless otherwise specified.
The creation of the data table in the database is the beginning of using a database function, and after the database is created, if data is stored in the database for use, the data table needs to be created first to realize the functions of data insertion, query and the like.
Conventional database tabulation requires users to use the tabulation statements or the assistance tools of each database client for each database, and requires a clear understanding of the nature and manner of use of each data type for each database.
Particularly, when data is synchronized, a data table is created, developers need to be familiar with the characteristics of various databases, various data types corresponding to each database and the using mode of each database, and also need to compile data synchronization scripts according to the information, configure synchronization parameters and continuously adjust and test to realize data synchronization.
For example, when a non-developer wants to import Excel-format table data into a database for analysis, he needs to know the data type and table-building syntax of each database. These all cause certain use thresholds for users, increase learning costs for users, and cause certain difficulties for users to want to store data in the database. Resulting in inefficient, costly and error prone creation of data tables.
In view of this, the present application provides a method for creating a data table, which obtains a type, a field name, and first information corresponding to the field name of an input first database; determining a corresponding target field type of the first information in a second database according to the first information and a preset mapping relation; generating a table building statement corresponding to the field name and the target field type according to the field name and the target field type; and creating a data table in the second database according to the table building statement. In the scheme, no matter the data table is created directly or the data table is created during data synchronization, a user does not need to master the characteristics of various databases, and the method can automatically and quickly determine the corresponding target field type of the first information in the second database according to the first information and the preset mapping relation. Then automatically generating a table building statement corresponding to the field name and the target field type according to the field name and the target field type; and creating a data table in the second database according to the table building statement. The whole step of creating the data table is simple, a user does not need to master the characteristics of various databases, data synchronization scripts do not need to be compiled, synchronization parameters do not need to be configured, and the like, so that the cost of creating the data table is saved, the efficiency of automatically creating the data table is high, and errors are not easy to occur.
Referring to fig. 1, fig. 1 is a schematic flow chart of a method for creating a data table according to an embodiment of the present application. The main execution body of the method for creating a data table in this embodiment is a device for creating a data table, where the device includes, but is not limited to, a Domain Name Server (DNS), an independent Server, a distributed Server, a Server cluster, or a cloud Server. The device may also be a mobile terminal such as a smartphone, a tablet computer, a Personal Digital Assistant (PDA), a desktop computer, or the like. The method for creating a data table as shown in fig. 1 may include S101 to S104, and the specific implementation principle of each step is as follows.
S101: the method comprises the steps of obtaining the type, the field name and first information corresponding to the field name of an input first database.
When a user directly creates a data table, the first database and the second database refer to the same database, and both the first database and the second database refer to databases corresponding to the data table to be created, which can be understood as that the data table to be created is created in the second database in the future. The second database may be of the type of a relational database, a non-relational database, and a key-value database.
Wherein the relational database may include a relational database management system (MySQL), a maridb database management system (a substitute for MySQL), a Percona Server database management system (a substitute for MySQL), a PostgreSQL database, a Microsoft Access database, a Microsoft SQL Server database, a Google Fusion Tables database, a FileMaker database, an Oracle database, a Sybase database, a dBASE database, a Clipper database, a FoxPro database, a fosshub database, and the like.
Non-relational databases may include distributed data storage systems (BigTable), databases based on distributed file storage (MongoDB), open-source document-oriented database management systems (CouchDB), and the like.
Key-value databases may include an open source distributed database management system (Apache Cassandra), amazon's key-value schema storage platform (Dynamo), efficient key-value databases (LevelDB).
Illustratively, when a user directly creates a data table, the field names are the names of the columns of the data table to be created. At this time, the first information corresponding to the field name is attribute information corresponding to the field name, and the attribute information is used for describing the data type corresponding to the field name.
Optionally, when some data needs to be imported into the second database and a data table needs to be created, the field name is the name of each column of the data table to be created. The first information corresponding to the field name is attribute information corresponding to the field name, and the attribute information is used for describing a data type corresponding to the field name.
When the synchronous data needs to create a data table, the field names are one or more field names contained in the original table, and the field type corresponding to the field names is the field type corresponding to each field name in the original table.
Optionally, in a possible implementation manner, when a user wants to create a data table in the second database, the type of the first database (in this case, the first database and the second database refer to the same database), one or more field names, and attribute information corresponding to each field name are input in a system input interface of the terminal, and the terminal sends the information input by the user to the server. The system interface may be preset with different types of databases, multiple candidate field names, and multiple candidate attribute information corresponding to each field name, and the user may select the type of the first database, the field name, and the attribute information corresponding to each field name from these options according to actual needs. The terminal transmits the information selected by the user to the server. The description is given for illustrative purposes only and is not intended to be limiting.
Optionally, in one possible implementation, the type of the second database entered is obtained when the synchronization data requires creation of a data table. One or more field names contained in the original table are obtained, and the field type corresponding to each field name in the original table is obtained. For example, it is desired to synchronize a data table a in a database a into a database B, where the data table a is an original table, the database a is a first database, the database B is a second database, obtain a type of the input database B, one or more field names included in the data table a, and obtain a field type corresponding to each field name in the data table a. The description is given for illustrative purposes only and is not intended to be limiting.
S102: and determining the corresponding target field type of the first information in the second database according to the first information and the preset mapping relation.
The target field type may be understood as a data table to be created in the second database, which contains a field type corresponding to the field name.
Illustratively, the number of field names is not limited, each field name corresponding to a field type. And when a plurality of field names exist, determining a target field type corresponding to the field name in the second database according to the field type and the preset mapping relation for each field name. In the same way, each target field type corresponding to the field type corresponding to each field name in the second database is determined.
S103: and generating a table building statement corresponding to the field name and the target field type according to the field name and the target field type.
Illustratively, the corresponding relations between different types of databases and different table building statement templates are established in advance and stored. And acquiring a table building statement template corresponding to the type of the second database, filling the field name and the target field type into the table building statement template, and generating a table building statement corresponding to the field name and the target field type.
Illustratively, when there are multiple field names, there are multiple target field types that correspond. And sequentially filling the field names and the target field types corresponding to the field names into a table building statement template aiming at each field name and the target field type corresponding to the field name, and generating the table building statements corresponding to the field names and the target field types. And performing the processing on each field name and the target field type corresponding to each field name to obtain a plurality of table building sentences. The description is given for illustrative purposes only and is not intended to be limiting.
Optionally, in a possible implementation, an automatic table building program is preset in the system. And starting an automatic table building program, wherein the automatic table building program can automatically generate table building sentences corresponding to the field names and the target field types according to the field names and the target field types during running. The automatic table building program can provide a visual interface for a user, so that the user can conveniently check the process of creating the data table and timely master the process of creating the data table.
S104: and creating a data table in the second database according to the table building statement.
The table building statement is used to build a data table in the second database. It is understood that the table building statement is composed of field names that should be included in the data table to be created and field types corresponding to each field name. Thus, after the table build statement is determined, a data table may be created from the table build statement directly in the second database. For example, where the second database is MySQL, a data table is created in MySQL from a build statement. When the second database is Oracle, a data table is created in Oracle from the build statement. The description is given for illustrative purposes only and is not intended to be limiting.
Optionally, in one possible implementation, an automatic table building program is used to create a data table from the table building statement in the second database. Illustratively, the automatic table building program automatically generates a table building statement corresponding to both the field name and the target field type according to the field name and the target field type at the time of running. A data table is then created in the second database from the table building statement. The description is given for illustrative purposes only and is not intended to be limiting.
In the implementation mode, the type and the field name of the input first database and the first information corresponding to the field name are obtained first, and no matter the data table is created directly or the data table is created during data synchronization, a user does not need to master the characteristics of various databases. Then automatically generating a table building statement corresponding to the field name and the target field type according to the field name and the target field type; and creating a data table in the second database according to the table building statement. The whole step of creating the data table is simple, a user does not need to master the characteristics of various databases, data synchronization scripts do not need to be compiled, synchronization parameters do not need to be configured, and the like, so that the cost of creating the data table is saved, the efficiency of automatically creating the data table is high, and errors are not easy to occur.
Optionally, in some possible implementations of the present application, when a user directly creates a data table, or when some data needs to be imported into the second database and the data table needs to be created, the first database is the second database, and the first information is the attribute information. The S101 may include: and acquiring the type, the field name and attribute information corresponding to the field name of the input first database.
Illustratively, the type of the first database, one or more field names, and attribute information corresponding to each field name are input at a system input interface of the terminal. The attribute information may include at least one of a character string, text, an autonomic key, a binary, an integer, a decimal, time, a number, a letter, an IP address, and the like. The terminal transmits the information input by the user to the server.
Optionally, when the user inputs the attribute information, the system interface displays prompt information to help the user select appropriate attribute information for the field name, so as to facilitate subsequently and accurately determining the target field type corresponding to the field name in the second database according to the attribute information. For example, the user is prompted as to what type of data, text or number, document type or common character string type, needs to be stored in the field corresponding to the field name, and how large the length of the character string type needs to be set, whether the number is an integer or a decimal, and the like. The data type of each field is specified. The description is given for illustrative purposes only and is not intended to be limiting.
In the implementation mode, the prompt information is popular and easy to understand, the user can accurately select the attribute information suitable for each field name according to the prompt information, all data types and field types of the second database needing to create the data table do not need to be mastered in detail, the doorsill for creating the data table is reduced, the operation is simple, and the efficiency for creating the data table is improved laterally.
FIG. 2 is a flowchart illustrating in detail step S102 of a method for creating a data table according to an exemplary embodiment of the present application; optionally, in some possible implementations of the present application, when a user directly creates a data table, or when some data needs to be imported into a target database and the data table needs to be created, the above S102 may include S1021 to S1022, specifically as follows:
s1021: and extracting keywords corresponding to the attribute information.
Illustratively, when the acquired attribute information is a descriptive statement, a keyword corresponding to the attribute information is extracted. For example, the attribute information is a character string with the length of 11, and the keyword corresponding to the attribute information is extracted as the character string with the length of 11; for another example, the attribute information is an integer of which the length is 3, and the keyword corresponding to the attribute information is extracted as the length 3 and the integer. The specific way of extracting the keywords may refer to the way of extracting the keywords in the prior art, and is not described herein again.
S1022: and searching the field type matched with the keyword corresponding to the attribute information based on a preset mapping relation to obtain the target field type.
The preset mapping relationship comprises corresponding relationships between different keywords and different field types. For example, various keywords are set in advance, and a field type corresponding to each keyword is set for each keyword. In the actual implementation process, according to the preset mapping relationship, the field type matched with the keyword corresponding to the attribute information is searched, the target field type corresponding to the attribute information is obtained, and the target field type corresponding to the field name corresponding to the attribute information is also obtained.
Optionally, when there are multiple field names, there are multiple attribute information correspondingly, extracting a keyword for each attribute information, and searching for a field type matched with the keyword corresponding to each attribute information based on a preset mapping relationship to obtain a target field type corresponding to each field name.
Optionally, in some possible implementation manners of the present application, when the attribute information itself includes only a keyword, that is, the attribute information includes only information such as a character string, a text, an integer, a decimal, time, a number, an alphabet, an IP address, and the like, and does not include redundant description statements, at this time, a field type matched with the keyword corresponding to the attribute information may be directly searched based on a preset mapping relationship, so as to obtain the target field type. The description is given for illustrative purposes only and is not intended to be limiting.
In the implementation manner, the target field type corresponding to the field name corresponding to the attribute information can be determined according to the attribute information input by the user, the user does not need to grasp all data types and field types of the second database needing to create the data table in detail, the threshold for creating the data table is reduced, the operation is simple, and the efficiency for creating the data table is improved laterally.
Optionally, in some possible implementation manners of the present application, different database types are preset, and in a preset mapping relationship corresponding to each database type, a corresponding relationship between different keywords and different field types is established. For example, different database types are preset, various keywords are set under each database type, and then the corresponding field type in the database of the type is set for each keyword. In the actual implementation process, the type of the second database is obtained first, and the field type matched with the keyword corresponding to the attribute information is searched in the preset mapping relation corresponding to the type of the second database to obtain the target field type.
In the implementation mode, the preset mapping relations corresponding to different database types are set for different database types, and the set field type corresponding to each keyword is more compatible with the database of the type, so that the table building is smoother according to the field type and is not easy to make mistakes.
Optionally, in some possible implementation manners of the present application, when the data table needs to be created for the synchronized data, the first database is different from the second database, and the first information is a field type corresponding to a field name, where the S101 may include: acquiring the type and an original table of an input second database; and extracting the field names and the field types corresponding to the field names from the original table.
Illustratively, when synchronizing data requires creating a data table, the data needs to be synchronized to which database, which is the second database. For example, the Oracle database data needs to be synchronized to MySQL, which is the second database; the PostgreSQL library data needs to be synchronized to Microsoft SQL Server, which is the second database.
The original table is a data table in the first database, and the field name and the field type corresponding to the field name included in the original table are the field type corresponding to the field name and the field name included in the data table in the first database. For example, the data of the Oracle database is required to be synchronized to MySQL, the Oracle is the first database, and the data table in the Oracle is the original table. The original table can be imported into the system, and the system analyzes the original table to obtain the field names contained in the original table and the field types corresponding to the field names. And acquiring the type of the second database input by the user.
In the implementation mode, the user does not need to know the field type corresponding to each field name in the original table, and only the original table needs to be provided, so that the field names in the original table and the field types corresponding to each field name can be automatically obtained, great convenience is brought to the user, and the user sensitivity is improved.
FIG. 3 is a flowchart illustrating in detail step S102 of a method for creating a data table according to an exemplary embodiment of the present application; optionally, in some possible implementations of the present application, when the data table needs to be created by synchronizing data, the S102 may include S1023 to S1024, and it should be noted that the S1021 to S1022 and the S1023 to S1024 are not in a sequential order, but different steps are selectively executed in different scenarios, which is not limited to actual implementation, and the S1023 to S1024 are specifically as follows:
s1023: and acquiring the priority corresponding to each preset field type in a preset first configuration table, wherein each preset field type corresponds to the second database.
Different database types are preset in the first configuration table, and a plurality of preset field types and the corresponding priority of each preset field type are preset under the column of each database type. In this setting, each preset field type corresponds to the database corresponding to its database type.
For example, for Oracle, the corresponding preset field types include Char, Varchar, Text, NUMBER, int, and the corresponding priority is set for each preset field type. For example, Char corresponds to a priority of 1, Varchar corresponds to a priority of 2, Text corresponds to a priority of 3, NUMBER corresponds to a priority of 4, and int corresponds to a priority of 5. The priority of each preset field type may also be set based on the experience of the developer.
The priority may be represented by numbers, letters, Chinese characters, etc. Illustratively, the smaller the number is, the higher the priority of the preset field type corresponding to the number is, the more the sequence is advanced, and the more the number of times the preset field type is used at ordinary times; the larger the number is, the lower the priority of the preset field type corresponding to the number is, and the later the ranking is, the fewer the number of times the preset field type is used in normal times. Optionally, the smaller the number is, the lower the priority of the preset field type corresponding to the number is, the later the ranking is, the fewer the times of the preset field type used in normal times are; the larger the number is, the higher the priority of the preset field type corresponding to the number is, the more the ranking is, and the more the number of times the preset field type is used in normal times. The description is given for illustrative purposes only and is not intended to be limiting.
S1024: and in all the preset field types corresponding to the second database, sequencing each preset field type according to the priority corresponding to each preset field type, and sequentially searching for the target field type corresponding to the field type according to the sequencing result.
Illustratively, if the second database is Oracle, following the example in S1023, the target field type corresponding to the field type is found in all the preset field types corresponding to Oracle, i.e. Char, Varchar, Text, NUMBER, int. And sorting all the preset field types corresponding to Oracle from high to low in advance according to the priority corresponding to each preset field type, and searching the target field type matched with the field type corresponding to the field name in the original table in the preset field types in sequence (from high to low) according to the sorting result.
For example, a field type corresponding to a field name in the original table is Varchar, Char is preferred when searching in a preset field type, if it is detected that Char and Varchar are not matched, the next priority search is continued, and when Varchar is searched, if the Char and Varchar are matched, the searched Varchar is recorded as a target field type matched with the field type corresponding to the field name in the original table. The description is given for illustrative purposes only and is not intended to be limiting.
In the implementation mode, different priorities are set according to the number of times the field type is used, the field type is searched from high to low according to the priorities when being searched, and due to the setting of the priorities, the target field type can be searched without traversing all the field types, so that the speed of determining the target field type is increased, and the speed of creating the data table is increased laterally.
FIG. 4 is a flowchart detailing step S102 of a method for creating a data table according to yet another exemplary embodiment of the present application; optionally, in some possible implementation manners of the present application, when the data table needs to be created by synchronizing data, the foregoing S102 may include S1025 to S1028, and it is worth to be noted that S1023 to S1024 are parallel to S1025 to S1028, and are not in a sequential execution order, but different steps are selectively executed in different scenarios, which is not limited to actual implementation, and S1025 to S1028 are specifically as follows:
s1025: and acquiring the priority corresponding to each parent field type in a preset second configuration table, wherein each parent field type corresponds to the target database.
Different database types are preset in the second configuration table, and a plurality of parent field types and the corresponding priority of each parent field type are preset under the column of each database type. One or more sub-field types corresponding to the parent field type and the priority corresponding to each sub-field type are preset below the column of each parent field type. In this arrangement, each parent field type corresponds to the database corresponding to its database type.
For example, for Oracle, its corresponding parent field types include: character data type, date and time data type, currency data type, etc. The priority corresponding to the character data type is 1, the priority corresponding to the date and time data type is 2, and the priority corresponding to the currency data type is 3. The sub-field type corresponding to the character data type may be: VARCHAR2, NVARCHAR2, CHAR, etc. The priority corresponding to VARCHAR2 is 1, the priority corresponding to NVARCHAR2 is 2, and the priority corresponding to CHAR is 3. The description is given for illustrative purposes only and is not intended to be limiting.
S1026: and in all the parent field types corresponding to the second database, sequencing each parent field type according to the priority corresponding to each parent field type, and sequentially searching the target parent field type corresponding to the field type according to the sequencing result.
Illustratively, if the second database is Oracle, following the example in S1025, the target parent field type corresponding to the field type is found in all the parent field types corresponding to Oracle, i.e., the character data type, the date and time data type, and the currency data type. And sorting all the parent field types corresponding to the Oracle from high to low in advance according to the priority corresponding to each parent field type, and sequentially (from high to low) searching target parent field types matched with the field types corresponding to the field names in the original table in the parent field types according to the sorting result.
S1027: and acquiring the priority corresponding to each subfield type, wherein each subfield type corresponds to the target parent field type.
And after the target parent field type is found, one or more sub-field types corresponding to the target parent field type and the priority corresponding to each sub-field type are obtained.
S1028: and in all the sub-field types corresponding to the target parent field type, sorting each sub-field type according to the priority corresponding to each sub-field type, and sequentially searching the target field type corresponding to the field type according to the sorting result.
Illustratively, if the second database is Oracle, following the example in S1025, the target field type corresponding to the field type is found in all the sub-field types corresponding to the target parent field type corresponding to Oracle, i.e., in VARCHAR2, nvarch 2, CHAR. And sorting all the sub-field types corresponding to the target parent field type from high to low according to the priority corresponding to each sub-field type in advance, and sequentially (from high to low) searching the target field type matched with the field type corresponding to the field name in the original table in the sub-field types according to the sorting result.
For example, the field type corresponding to a field name in the original table is VARCHAR2, the found target parent field type is a character data type, and the found target parent field type is found in all the sub-field types corresponding to the character data type, because the priority of the VARCHAR2 is the highest, the VARCHAR2 is preferred, and if the two are found to be matched, the found VARCHAR2 is recorded as the target field type matched with the field type corresponding to the field name in the original table. The description is given for illustrative purposes only and is not intended to be limiting.
In the implementation mode, different priorities are set according to the number of times the field type is used, the field type is searched from high to low according to the priorities when being searched, and due to the setting of the priorities, the target field type can be searched without traversing all the field types, so that the speed of determining the target field type is increased, and the speed of creating the data table is increased laterally.
Optionally, in some possible implementation manners of the present application, the method for creating a data table provided by the present application further includes: determining the number of times (or frequency of use) each preset field type in the first configuration table is used; and adjusting the priority corresponding to each preset field type according to the number of times (or the use frequency) that each preset field type is used.
For example, each time a certain preset field type in the first configuration table is determined as the target field type, the number of times of use corresponding to the preset field type is increased by one, the number of times of use of all the preset field types is counted every preset time, and the priority corresponding to each preset field type is adjusted according to the number of times of use of each preset field type. For example, the priority is adjusted for each preset field type according to the order of the number of times of use, from high to low.
Optionally, determining the number of times (or frequency of use) each parent field type and each sub-field type is used in the second configuration table; the priority level corresponding to each parent field type is adjusted, and the priority level corresponding to each subfield type is adjusted, according to each parent field type and the number of times (or frequency of use) that each subfield type is used.
In the implementation manner, the priority corresponding to each field type is adjusted in time according to the number of times that different field types are used at intervals. When the field type is searched, the field type is searched from high to low according to the priority, and the target field type can be searched without traversing all the field types due to the setting of the priority, so that the speed of determining the target field type is increased, and the speed of creating the data table is increased laterally.
Referring to fig. 5, fig. 5 is a schematic diagram of an apparatus for creating a data table according to an embodiment of the present application. The device comprises units for performing the steps in the embodiments corresponding to fig. 1, 2, 3, 4. Please refer to the related descriptions in the embodiments corresponding to fig. 1, fig. 2, fig. 3, and fig. 4, respectively. For convenience of explanation, only the portions related to the present embodiment are shown. Referring to fig. 5, it includes:
an obtaining unit 210, configured to obtain a type of an input first database, a field name, and first information corresponding to the field name;
a determining unit 220, configured to determine, according to the first information and a preset mapping relationship, a target field type corresponding to the first information in a second database;
a generating unit 230, configured to generate a table building statement corresponding to the field name and the target field type according to the field name and the target field type;
a creating unit 240, configured to create a data table in the second database according to the table creation statement.
Optionally, when the first database is the second database, the first information is attribute information, and the obtaining unit 210 is specifically configured to:
the method comprises the steps of obtaining the type and field name of an input first database and attribute information corresponding to the field name, wherein the attribute information comprises at least one of character strings, texts, integers, decimal numbers, time and IP addresses.
Optionally, the determining unit 220 is specifically configured to:
extracting keywords corresponding to the attribute information;
and searching a field type matched with the keyword corresponding to the attribute information based on a preset mapping relation to obtain the target field type.
Optionally, when the first database is different from the second database, the first information is a field type corresponding to the field name, and the obtaining unit 210 is further configured to:
acquiring the type and an original table of an input second database;
and extracting field names and field types corresponding to the field names from the original table.
Optionally, the determining unit 220 is further configured to:
acquiring a priority corresponding to each preset field type in a preset first configuration table, wherein each preset field type corresponds to the second database;
and in all the preset field types corresponding to the second database, sequencing each preset field type according to the priority corresponding to each preset field type, and sequentially searching for the target field type corresponding to the field type according to the sequencing result.
Optionally, the determining unit 220 is further configured to:
acquiring the priority corresponding to each parent field type in a preset second configuration table, wherein each parent field type corresponds to the target database;
in all the parent field types corresponding to the second database, sequencing each parent field type according to the priority corresponding to each parent field type, and sequentially searching a target parent field type corresponding to the field type according to a sequencing result;
acquiring the priority corresponding to each subfield type, wherein each subfield type corresponds to the target parent field type;
and in all the sub-field types corresponding to the target parent field type, sorting each sub-field type according to the priority corresponding to each sub-field type, and sequentially searching the target field type corresponding to the field type according to the sorting result.
Optionally, the apparatus further comprises:
a use number determining unit, configured to determine the number of times each of the preset field types in the first configuration table is used;
and the adjusting unit is used for adjusting the priority corresponding to each preset field type according to the number of times that each preset field type is used.
Referring to fig. 6, fig. 6 is a schematic diagram of an apparatus for creating a data table according to another embodiment of the present application. As shown in fig. 6, the apparatus 3 for creating a data table of this embodiment includes: a processor 30, a memory 31, and computer instructions 32 stored in the memory 31 and executable on the processor 30. The processor 30, when executing the computer instructions 32, implements the steps in the various method embodiments described above for creating a data table, such as S101-S104 shown in fig. 1. Alternatively, the processor 30, when executing the computer instructions 32, implements the functions of the units in the embodiments described above, such as the functions of the units 210 to 240 shown in fig. 5.
Illustratively, the computer instructions 32 may be divided into one or more units, which are stored in the memory 31 and executed by the processor 30 to accomplish the present application. The one or more units may be a series of computer instruction segments capable of performing specific functions, which are used to describe the execution of the computer instructions 32 in the apparatus 3 for creating a data table. For example, the computer instructions 32 may be divided into an acquisition unit, a determination unit, a generation unit, and a creation unit, each unit having the specific functions described above.
The device 3 for creating the data table may include, but is not limited to, a processor 30 and a memory 31. It will be appreciated by those skilled in the art that fig. 6 is merely an example of the device 3 for creating a data table and does not constitute a limitation of the device for creating a data table, and may comprise more or less components than those shown, or some components may be combined, or different components, for example, the device for creating a data table may further comprise input-output devices, network access devices, buses, etc.
The Processor 30 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 31 may be an internal storage unit of the apparatus for creating a data table, such as a hard disk or a memory of the apparatus for creating a data table. The memory 31 may also be an external storage terminal of the device for creating the data table, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are equipped on the device for creating the data table. Further, the memory 31 may also include both an internal storage unit and an external storage terminal of the apparatus for creating a data table. The memory 31 is used for storing the computer instructions and other programs and data required by the terminal. The memory 31 may also be used to temporarily store data that has been output or is to be output.
The embodiment of the present application further provides a computer storage medium, where the computer storage medium may be nonvolatile or volatile, and the computer storage medium stores a computer program, and the computer program, when executed by a processor, implements the steps in the above method embodiments for creating a data table.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not cause the essential features of the corresponding technical solutions to depart from the spirit scope of the technical solutions of the embodiments of the present application, and are intended to be included within the scope of the present application.

Claims (10)

1. A method of creating a data table, comprising:
acquiring the type and field name of an input first database and first information corresponding to the field name;
determining a corresponding target field type of the first information in a second database according to the first information and a preset mapping relation;
generating a table building statement corresponding to the field name and the target field type according to the field name and the target field type;
and creating a data table in the second database according to the table building statement.
2. The method according to claim 1, wherein when the first database is the second database, the first information is attribute information, and the obtaining the input first information corresponding to the type, the field name, and the field name of the first database includes:
the method comprises the steps of obtaining the type and field name of an input first database and attribute information corresponding to the field name, wherein the attribute information comprises at least one of character strings, texts, integers, decimal numbers, time and IP addresses.
3. The method of claim 2, wherein the determining the target field type corresponding to the first information in the second database according to the first information and a preset mapping relationship comprises:
extracting keywords corresponding to the attribute information;
and searching a field type matched with the keyword corresponding to the attribute information based on a preset mapping relation to obtain the target field type.
4. The method of claim 1, wherein when the first database is different from the second database, the first information is a field type corresponding to the field name, and the obtaining the input first information corresponding to the type, the field name, and the field name of the first database comprises:
acquiring the type and an original table of an input second database;
and extracting field names and field types corresponding to the field names from the original table.
5. The method of claim 4, wherein the determining the target field type corresponding to the first information in the second database according to the first information and a preset mapping relationship comprises:
acquiring a priority corresponding to each preset field type in a preset first configuration table, wherein each preset field type corresponds to the second database;
and in all the preset field types corresponding to the second database, sequencing each preset field type according to the priority corresponding to each preset field type, and sequentially searching for the target field type corresponding to the field type according to the sequencing result.
6. The method of claim 4, wherein the determining the target field type corresponding to the first information in the second database according to the first information and a preset mapping relationship comprises:
acquiring the priority corresponding to each parent field type in a preset second configuration table, wherein each parent field type corresponds to the target database;
in all the parent field types corresponding to the second database, sequencing each parent field type according to the priority corresponding to each parent field type, and sequentially searching a target parent field type corresponding to the field type according to a sequencing result;
acquiring the priority corresponding to each subfield type, wherein each subfield type corresponds to the target parent field type;
and in all the sub-field types corresponding to the target parent field type, sorting each sub-field type according to the priority corresponding to each sub-field type, and sequentially searching the target field type corresponding to the field type according to the sorting result.
7. The method of claim 5, wherein the method further comprises:
determining the number of times each preset field type in the first configuration table is used;
and adjusting the priority corresponding to each preset field type according to the number of times that each preset field type is used.
8. An apparatus for creating a data table, comprising:
the system comprises an acquisition unit, a storage unit and a display unit, wherein the acquisition unit is used for acquiring the type, the field name and first information corresponding to the field name of an input first database;
the determining unit is used for determining a corresponding target field type of the first information in a second database according to the first information and a preset mapping relation;
the generating unit is used for generating a table building statement corresponding to the field name and the target field type according to the field name and the target field type;
and the creating unit is used for creating a data table in the second database according to the table building statement.
9. An apparatus for creating a data table, comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the method according to any of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1 to 7.
CN202110736351.9A 2021-06-30 Method, device, equipment and storage medium for creating data table Active CN113505128B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110736351.9A CN113505128B (en) 2021-06-30 Method, device, equipment and storage medium for creating data table

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110736351.9A CN113505128B (en) 2021-06-30 Method, device, equipment and storage medium for creating data table

Publications (2)

Publication Number Publication Date
CN113505128A true CN113505128A (en) 2021-10-15
CN113505128B CN113505128B (en) 2024-05-31

Family

ID=

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114490858A (en) * 2022-02-22 2022-05-13 北京科杰科技有限公司 Table structure type conversion system and method for big data and RMDB
CN114996280A (en) * 2022-08-01 2022-09-02 每日互动股份有限公司 Method, device, equipment and medium for correcting field information of data table
CN115391459A (en) * 2022-08-24 2022-11-25 南京领行科技股份有限公司 Data synchronization method and device, electronic equipment and computer readable storage medium
CN115408473A (en) * 2022-11-01 2022-11-29 神州数码融信云技术服务有限公司 Data synchronization method and device, computer equipment and computer readable storage medium
CN116401303A (en) * 2023-04-12 2023-07-07 岱特智能科技(上海)有限公司 Hospital multi-database data management method and related device for kidney disease treatment
CN117235190A (en) * 2023-09-05 2023-12-15 上海异工同智信息科技有限公司 Data table generation method and device

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107545044A (en) * 2017-08-15 2018-01-05 北京微影时代科技有限公司 A kind of tables of data method for building up, electronic equipment and storage medium
JP2018116706A (en) * 2017-01-22 2018-07-26 株式会社日立製作所 Data multidimensional model generation system and data multidimensional model generation method
CN108681674A (en) * 2018-04-23 2018-10-19 平安科技(深圳)有限公司 Reports module creation method, device, computer installation and storage medium
CN110019474A (en) * 2017-12-19 2019-07-16 北京金山云网络技术有限公司 Synonymous data automatic correlation method, device and electronic equipment in heterogeneous database
CN110928895A (en) * 2018-09-19 2020-03-27 阿里巴巴集团控股有限公司 Data query method, data table establishing method, device and equipment
US20200125660A1 (en) * 2018-10-19 2020-04-23 Ca, Inc. Quick identification and retrieval of changed data rows in a data table of a database

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2018116706A (en) * 2017-01-22 2018-07-26 株式会社日立製作所 Data multidimensional model generation system and data multidimensional model generation method
CN107545044A (en) * 2017-08-15 2018-01-05 北京微影时代科技有限公司 A kind of tables of data method for building up, electronic equipment and storage medium
CN110019474A (en) * 2017-12-19 2019-07-16 北京金山云网络技术有限公司 Synonymous data automatic correlation method, device and electronic equipment in heterogeneous database
CN108681674A (en) * 2018-04-23 2018-10-19 平安科技(深圳)有限公司 Reports module creation method, device, computer installation and storage medium
CN110928895A (en) * 2018-09-19 2020-03-27 阿里巴巴集团控股有限公司 Data query method, data table establishing method, device and equipment
US20200125660A1 (en) * 2018-10-19 2020-04-23 Ca, Inc. Quick identification and retrieval of changed data rows in a data table of a database

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
鞠儒生;乔海泉;陈少卿;黄柯棣;: "HLA中基于OMT文件创建数据库关系表的方法", 计算机仿真, no. 05, 28 May 2006 (2006-05-28) *

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114490858A (en) * 2022-02-22 2022-05-13 北京科杰科技有限公司 Table structure type conversion system and method for big data and RMDB
CN114996280A (en) * 2022-08-01 2022-09-02 每日互动股份有限公司 Method, device, equipment and medium for correcting field information of data table
CN114996280B (en) * 2022-08-01 2022-10-25 每日互动股份有限公司 Method, device, equipment and medium for correcting field information of data table
CN115391459A (en) * 2022-08-24 2022-11-25 南京领行科技股份有限公司 Data synchronization method and device, electronic equipment and computer readable storage medium
CN115408473A (en) * 2022-11-01 2022-11-29 神州数码融信云技术服务有限公司 Data synchronization method and device, computer equipment and computer readable storage medium
CN116401303A (en) * 2023-04-12 2023-07-07 岱特智能科技(上海)有限公司 Hospital multi-database data management method and related device for kidney disease treatment
CN116401303B (en) * 2023-04-12 2023-11-10 岱特智能科技(上海)有限公司 Hospital multi-database data management method and related device for kidney disease treatment
CN117235190A (en) * 2023-09-05 2023-12-15 上海异工同智信息科技有限公司 Data table generation method and device

Similar Documents

Publication Publication Date Title
CN111522816B (en) Data processing method, device, terminal and medium based on database engine
JP6634515B2 (en) Question clustering processing method and apparatus in automatic question answering system
AU2017101864A4 (en) Method, device, server and storage apparatus of reviewing SQL
US10866973B2 (en) Test data management
US10282664B2 (en) Method and device for constructing event knowledge base
US10628492B2 (en) Distributed graph database writes
US9984166B2 (en) Systems and methods of de-duplicating similar news feed items
US20190095489A1 (en) Character matching in text processing
CN109871311B (en) Method and device for recommending test cases
US20110314001A1 (en) Performing query expansion based upon statistical analysis of structured data
Silva et al. Integrating big data into the computing curricula
US20180357278A1 (en) Processing aggregate queries in a graph database
CN110569335A (en) triple verification method and device based on artificial intelligence and storage medium
CN107016115B (en) Data export method and device, computer readable storage medium and electronic equipment
US8965797B2 (en) Explosions of bill-of-materials lists
US10235422B2 (en) Lock-free parallel dictionary encoding
EP3635580A1 (en) Functional equivalence of tuples and edges in graph databases
CN113032642A (en) Data processing method, device and medium for target object and electronic equipment
US10234295B2 (en) Address remediation using geo-coordinates
US11250002B2 (en) Result set output criteria
CN111984745A (en) Dynamic expansion method, device, equipment and storage medium for database field
CN113505128B (en) Method, device, equipment and storage medium for creating data table
US9256644B1 (en) System for identifying and investigating shared and derived content
CN113505128A (en) Method, device and equipment for creating data table and storage medium
RU2693328C2 (en) Methods and systems for generating a replacement request for a user input request

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant