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

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

Info

Publication number
CN113505128B
CN113505128B CN202110736351.9A CN202110736351A CN113505128B CN 113505128 B CN113505128 B CN 113505128B CN 202110736351 A CN202110736351 A CN 202110736351A CN 113505128 B CN113505128 B CN 113505128B
Authority
CN
China
Prior art keywords
field
database
field type
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.)
Active
Application number
CN202110736351.9A
Other languages
Chinese (zh)
Other versions
CN113505128A (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
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

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 suitable for 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, the field name and the first information corresponding to the field name of the input first database; determining a target field type corresponding to the first information in the 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 creation statement. In the scheme, no matter the data table is directly created or created during data synchronization, the user does not need to grasp the characteristics of various databases, the whole step of creating the data table is simple, the user does not need to grasp the characteristics of various databases, the writing of data synchronization scripts, the configuration of synchronization parameters and the like are not needed, the cost of creating the data table is saved, and the automatic data table creation efficiency is high and is not easy to make mistakes.

Description

Method, device, equipment and storage medium for creating data table
Technical Field
The present application belongs to the technical field of database processing, and in particular, relates 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 creation statement of each database, and the characteristics and the using modes of various data types of each database need to be known.
Or creating a data table when synchronizing data, and the developer is required to be familiar with the characteristics of various databases, various data types corresponding to each database and the use mode of each database, and then writing a data synchronization script according to the information, configuring synchronization parameters, and continuously adjusting the test to realize the synchronization of the data.
The inventor realizes that in the prior art, no matter the data table is directly created or the data table is created when the data is synchronized, the user is required to grasp the characteristics of various databases, a great deal of time is spent, the steps are complicated, the efficiency of creating the data table is low, the cost is high, and the error is easy to occur.
Disclosure of Invention
In view of this, the embodiments of the present application provide a method, apparatus, device, and storage medium for creating a data table. The method solves the problems that the existing method for directly creating the data table or creating the data table during the data synchronization requires users to master the characteristics of various databases, spends a great deal of time and has complicated steps, and the efficiency of creating the data table is low, the cost is high and the errors are easy to occur.
A first aspect of an embodiment of the present application provides a method for creating a data table, the method including:
acquiring the type, the field name and the first information corresponding to the field name of the input first database;
determining a target field type corresponding to 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 creating sentence.
Optionally, 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:
And acquiring the type, the field name and the attribute information corresponding to the field name of the input first database, wherein the attribute information comprises at least one of a character string, a text, an integer, a decimal, time and an IP address.
Optionally, 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:
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 the original table of the input second database;
And extracting a field name from the original table and a field type corresponding to the field name.
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 sequencing each preset field type in all preset field types corresponding to the second database according to the priority corresponding to each preset field type, and sequentially searching for a 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 a priority corresponding to each father field type in a preset second configuration table, wherein each father field type corresponds to the target database;
sorting all the father field types corresponding to the second database according to the priority corresponding to each father field type, and sequentially searching for a target father field type corresponding to the field type according to the sorting result;
Acquiring a priority corresponding to each sub-field type, wherein each sub-field type corresponds to the target parent field type;
And sequencing each sub-field type in all sub-field types corresponding to the target parent 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 sequencing result.
Optionally, the method further comprises:
determining the number of times each of the preset field types in the first configuration table is used;
And adjusting the priority corresponding to each preset field type according to the number of times 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 acquisition unit is used for acquiring the type, the field name and the first information corresponding to the field name of the input first database;
The determining unit is used for determining the type of the target field corresponding to the first information in the second database according to the first information and a preset mapping relation;
the generation 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 creating sentence.
A third aspect of an embodiment of the application provides an apparatus for creating a data table, comprising a memory, a processor and a computer program stored in said memory and executable on said processor, characterized in that the steps of the method for creating a data table as described in the first aspect are implemented when said computer program is executed by said processor.
A fourth aspect of the embodiments of the present application provides a computer-readable storage medium storing a computer program which, 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 an embodiment of the application provides a computer program product for causing a device for creating a data table to carry out the steps of the method for creating a data table as described in the first aspect above, when the computer program product is run on the device.
The method, the device, the equipment and the storage medium for creating the data table have the following beneficial effects:
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 a preset mapping relation, and the method does not need a user to grasp the characteristics of various databases no matter whether the data table is directly created or the data table is created during synchronous data. Further, according to the field name and the target field type, automatically generating a table building statement corresponding to the field name and the target field type; and creating a data table in the second database according to the table creation statement. The whole data table creating step is simple, the user does not need to master the characteristics of various databases, the writing of data synchronization scripts, the configuration of synchronization parameters and the like are not needed, the cost for creating the data table is saved, and the automatic data table creating efficiency is high and errors are not easy to occur.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the embodiments or the description of the prior art will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic flow chart of a method of creating a data table provided by an embodiment of the application;
FIG. 2 is a specific flowchart illustrating step S102 of a method of creating a data table according to an exemplary embodiment of the present application;
FIG. 3 is a specific flowchart illustrating step S102 of a method of creating a data table according to an exemplary embodiment of the present application;
FIG. 4 is a specific flow chart of step S102 of a method of creating a data table, as shown in yet another exemplary embodiment of the application;
FIG. 5 is a schematic diagram of 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
The present application will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present application more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the application.
In the description of the embodiments of the present application, unless otherwise indicated, "/" means or, for example, a/B may represent a or B; "and/or" herein is merely an association relationship describing an association object, and means that three relationships may exist, for example, a and/or B may mean: a exists alone, A and B exist together, and B exists alone. In addition, in the description of the embodiments of the present application, "plurality" means two or more than two.
The terms "first" and "second" are used below for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defining "a first" or "a second" may explicitly or implicitly include one or more such feature. In the description of the present embodiment, unless otherwise specified, the meaning of "plurality" is two or more.
Creating a data table in a database is the beginning of using the database function, and after creating the database, if the data is to be 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 construction requires users to use construction statements for each database or auxiliary tools for each database client, and to grasp the characteristics and usage patterns of each data type for each database.
Particularly, when the data are synchronized, a data table is created, so that a developer is required to be familiar with the characteristics of various databases, various data types corresponding to each database and the use mode of each database, a data synchronization script is written according to the information, synchronization parameters are configured, and adjustment and test are continuously carried out to realize the synchronization of the data.
For example, when a non-developer wants to import table data in Excel format into databases for analysis, he needs to master the data type and build table syntax for each database. These all cause a certain use threshold for the user, increase the learning cost of the user, and also cause a certain difficulty for the user to want to store the data in the database. Resulting in inefficient, costly, and error-prone creation of the data table.
In view of the above, 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 target field type corresponding to the first information in the 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 creation statement. In the scheme, no matter the data table is directly created or created during data synchronization, the user does not need to grasp the characteristics of various databases, and the method can automatically and quickly determine the type of the target field corresponding to the first information in the second database according to the first information and the preset mapping relation. Further, according to the field name and the target field type, automatically generating a table building statement corresponding to the field name and the target field type; and creating a data table in the second database according to the table creation statement. The whole data table creating step is simple, the user does not need to master the characteristics of various databases, the writing of data synchronization scripts, the configuration of synchronization parameters and the like are not needed, the cost for creating the data table is saved, and the automatic data table creating efficiency 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 execution subject 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 (Domain NAME SERVER, DNS), a stand-alone server, a distributed server, a server cluster, or a cloud server. The device may also be a mobile terminal such as a smart phone, tablet computer, personal digital assistant (Personal DIGITAL ASSISTANT, PDA), desktop computer, etc. The method of creating the data table as shown in fig. 1 may include S101 to S104, and the specific implementation principle of each step is as follows.
S101: and acquiring the type, the field name and the first information corresponding to the field name of the input first database.
When a user directly creates a data table, the first database and the second database refer to the same database, and at this time, 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 future. The second database may be of the type relational, non-relational or key value database.
The relational databases may include, among other things, a relational database management system (MySQL), a mariadib database management system (replacement of MySQL), a Percona Server database management system (replacement of 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 clip database, a FoxPro database, a foshub database, and the like.
The non-relational databases may include a distributed data storage system (BigTable), a distributed file storage-based database (MongoDB), an open-source document-oriented database management system (CouchDB), and the like.
The key-value databases may include an open source distributed database management system (APACHE CASSANDRA), a key-value mode storage platform (Dynamo), an efficient key-value database (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.
Alternatively, when it is desired to import some data into the second database and it is desired to create a data table, the field names are the names of the columns 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 the 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 types corresponding to the field names are the field types corresponding to the field names in the original table.
Optionally, in one possible implementation, when the user wants to create a data table in the second database, the type of the first database (the first database and the second database refer to the same database at this time), one or more field names and attribute information corresponding to the field names are input in the 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 selects the type of the first database, selects the field name and selects the attribute information corresponding to each field name from the options according to actual requirements. The terminal transmits the information selected by the user to the server. This is merely illustrative and is not limiting.
Optionally, in one possible implementation, when the synchronization data requires creation of a data table, the type of the second database entered is obtained. One or more field names contained in the original table are obtained, and field types corresponding to the field names in the original table are obtained. For example, it is desired to synchronize the data table a in the database a to the 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 the type of the input database B, one or more field names included in the data table a, and obtain the field types corresponding to the field names in the data table a. This is merely illustrative and is not limiting.
S102: and determining the type of the target field corresponding to the first information in the second database according to the first information and a 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 a field name.
Illustratively, the number of field names is not limited, and each field name corresponds to a field type. When a plurality of field names exist, determining a target field type corresponding to the field type corresponding to each field name in the second database according to the field type and a preset mapping relation. In the same manner, each target 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 relation between the databases of different types and the different table-building sentence templates is pre-established and stored. And acquiring a list establishing sentence template corresponding to the type of the second database, filling the field name and the target field type into the list establishing sentence template, and generating a list establishing sentence corresponding to the field name and the target field type.
Illustratively, when there are multiple field names, there are multiple target field types corresponding. And filling the field names and the target field types corresponding to the field names into a table-building sentence template in sequence aiming at each field name and the target field type corresponding to the field names, and generating a table-building sentence corresponding to each field name and each target field type. And carrying out the processing on each field name and the target field type corresponding to each field name to obtain a plurality of table building sentences. This is merely illustrative and is not 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 operation. The automatic table establishment 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 creation statement.
The list-building sentence is used for building a data list 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 list-building statement is determined, a data list can be created directly in the second database from the list-building statement. For example, when the second database is MySQL, a data table is created in MySQL from the build sentence. When the second database is Oracle, a data table is created in Oracle according to the table-building sentence. This is merely illustrative and is not limiting.
Optionally, in one possible implementation, the data table is created in the second database from the table-building sentence using an automatic table-building program. Illustratively, the automatic table-building program automatically generates table-building sentences corresponding to the field names and the target field types according to the field names and the target field types when running. And then creating a data table in the second database according to the table-creating sentence. This is merely illustrative and is not limiting.
In the implementation manner, the type, the field name and the first information corresponding to the field name of the input first database are acquired first, no matter the data table is directly created or is created when the data is synchronized, the user does not need to grasp 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. Further, according to the field name and the target field type, automatically generating a table building statement corresponding to the field name and the target field type; and creating a data table in the second database according to the table creation statement. The whole data table creating step is simple, the user does not need to master the characteristics of various databases, the writing of data synchronization scripts, the configuration of synchronization parameters and the like are not needed, the cost for creating the data table is saved, and the automatic data table creating efficiency is high and errors are not easy to occur.
Alternatively, in some possible implementations of the present application, when the user directly creates the data table, or when it is necessary to import some data into the second database and create the data table, the first database is the second database, and the first information is attribute information. The S101 may include: and acquiring the type, the field name and the 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 auto-key, a binary, an integer, a decimal, a 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 attribute information, the system interface may display prompt information to help the user select appropriate attribute information for the field name, so as to facilitate the subsequent accurate determination of the target field type corresponding to the field name in the second database according to the attribute information. For example, the user is prompted what type of data is required to be stored in the field corresponding to the field name, whether text or number is stored, whether document type or common character string type is stored, how much length is required to be set for the character string type, whether number is an integer or a decimal, and the like. The data type of each field is described in detail. This is merely illustrative and is not 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, and the detail grasp of all data types and field types of the second database needing to be created with the data table is not needed, so that the threshold for creating the data table is reduced, the operation is simple, and the efficiency of creating the data table is improved by the side face.
FIG. 2 is a specific flowchart illustrating step S102 of a method of creating a data table according to an exemplary embodiment of the present application; optionally, in some possible implementations of the present application, when the user directly creates the data table, or when it is necessary to import some data into the target database and create the data table, S102 may include S1021 to S1022 as follows:
S1021: and extracting keywords corresponding to the attribute information.
Illustratively, when the acquired attribute information is a description sentence, 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 a character string with the length of 11; for example, the attribute information is an integer having a length of 3, and the keyword corresponding to the attribute information is extracted as an integer having a length of 3. The specific way of extracting the keywords may refer to the way of extracting the keywords in the prior art, and will not be described herein.
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 relation comprises the corresponding relation between different keywords and different field types. For example, various keywords are set in advance, and a corresponding field type is set for each keyword. In the actual implementation process, according to the preset mapping relation, searching the field type matched with the keyword corresponding to the attribute information to obtain the target field type corresponding to the attribute information, and obtaining the target field type corresponding to the field name corresponding to the attribute information.
Optionally, when there are multiple field names, there are multiple attribute information correspondingly, extracting keywords from each attribute information, and searching the field type matched with the keywords corresponding to each attribute information based on a preset mapping relation to obtain the 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 the keywords, that is, the attribute information includes only the information such as a character string, a text, an integer, a decimal, a time, a number, a letter, an IP address, and the like, no redundant description sentence is included, at this time, a field type matched with the keywords corresponding to the attribute information may be searched directly based on a preset mapping relationship, so as to obtain the target field type. This is merely illustrative and is not 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 of creating the data table is improved by the side face.
Optionally, in some possible implementations of the present application, different database types are preset, and in a preset mapping relationship corresponding to each database type, a correspondence 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 types in the type database are set for each keyword. In the actual implementation process, the type of the second database is acquired 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 manner, the corresponding preset mapping relation is set for different database types, and then the set field type corresponding to each keyword is more compatible with the type database, so that the table is more fluent and is not easy to make mistakes when the table is built according to the field type.
Optionally, in some possible implementations of the present application, when the synchronization data needs to create the data table, the first database is different from the second database, the first information is a field type corresponding to a field name, and S101 may include: acquiring the type and the original table of the input second database; extracting the field name and the field type corresponding to the field name from the original table.
Illustratively, when synchronizing data requires creating a data table, it is necessary to synchronize the data 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, microsoft SQL SERVER being the second database.
The original table is a data table in the first database, and the field names contained in the original table and the field types corresponding to the field names, namely the field names contained in the data table in the first database and the field types corresponding to the field names. For example, the Oracle database data needs to be synchronized to MySQL, oracle is the first database, and the data table in 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 and the field types corresponding to the field names contained in the original table. The type of the second database input by the user is obtained.
In the implementation manner, the user does not need to know the field type corresponding to each field name in the original table, only the original table is provided, 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's goodness is improved.
FIG. 3 is a specific flowchart illustrating step S102 of a method of creating a data table according to an exemplary embodiment of the present application; optionally, in some possible implementations of the present application, when the synchronization data needs to create the data table, the S102 may include S1023 to S1024, and it should be noted that, the S1021 to S1022 and the S1023 to S1024 are not sequentially executed, but different steps are selectively executed in different scenarios, which is not limited to the actual implementation, and the S1023 to S1024 specifically include:
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 priorities corresponding to the preset field types are preset under one column of each database type. In this setting mode, each preset field type corresponds to a database corresponding to its database type.
For example, for Oracle, the corresponding preset field type includes Char, varchar, text, NUMBER, int, and for each preset field type, its corresponding priority is set. For example, the priority corresponding to Char is 1, the priority corresponding to Varchar is 2, the priority corresponding to text is 3, the priority corresponding to NUMBER is 4, and the priority corresponding to int is 5, wherein the priority can be set according to the number of times the preset field type is used at ordinary times, and the more the preset field type is used (the higher the frequency), the higher the priority corresponding to the preset field type is. The priority of each preset field type can also be set according to experience of a developer.
The priority may be represented by numbers, letters, chinese characters, etc. Illustratively, the smaller the number, the higher the priority of the preset field type corresponding to the number, the earlier the order thereof, and the more times it is used at ordinary times; the larger the number, the lower the priority of the preset field type corresponding to the number, the later the sequence, and the lower the number of times the number is used in normal times. Alternatively, the smaller the number, the lower the priority of the preset field type corresponding to the number, the later the order of the number, and the lower the number of times the number is used in normal times; the larger the number, the higher the priority of the preset field type corresponding to the number, the earlier the order of the number, and the more times the number is used in normal times. This is merely illustrative and is not limiting.
S1024: and sequencing each preset field type in all preset field types corresponding to the second database according to the priority corresponding to each preset field type, and sequentially searching for a target field type corresponding to the field type according to the sequencing result.
For example, if the second database is Oracle, the example in S1023 is taken as follows, and the target field type corresponding to the field type is searched for in all preset field types corresponding to Oracle, i.e. in Char, varchar, text, NUMBER, int. And sequencing all preset field types corresponding to Oracle from high to low in advance according to the priority corresponding to each preset field type, and sequentially (from high to low) searching target field types matched with the field types corresponding to the field names in the original table in the preset field types according to the sequencing result.
For example, if a field type corresponding to a field name in the original table is Varchar, when a search is performed in a preset field type, char is first selected, if Char and Varchar are detected to be not matched, search is continued to be performed in the next priority, when Varchar is found, and if found, the two are matched, the found Varchar is marked as a target field type matched with the field type corresponding to the field name in the original table. This is merely illustrative and is not limiting.
In the implementation manner, different priorities are set according to the number of times the field type is used, and when the field type is searched, the priority is set, and the target field type can be searched without traversing all the field types, so that the speed of determining the target field type is improved, and the speed of creating the data table is improved laterally.
FIG. 4 is a specific flow chart of step S102 of a method of creating a data table, as shown in yet another exemplary embodiment of the application; optionally, in some possible implementations of the present application, when the synchronization data needs to create the data table, the S102 may include S1025 to S1028, and it should be noted that, S1023 to S1024 are juxtaposed with S1025 to S1028, and are not sequentially executed, but different steps are selectively executed in different scenes, so that the implementation is not limited, and S1025 to S1028 specifically include:
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 father field types and priorities corresponding to the father field types are preset under one column of each database type. Under this column of each parent field type, one or more sub-field types corresponding to the parent field type, and a priority corresponding to each sub-field type are preset. In this arrangement, each parent field type corresponds to its database for which the database type corresponds.
For example, for Oracle, its corresponding parent field type includes: 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. This is merely illustrative and is not limiting.
S1026: and sequencing each parent field type in all the parent field types corresponding to the second database according to the priority corresponding to each parent field type, and sequentially searching for a target parent field type corresponding to the field type according to the sequencing result.
Illustratively, if the second database is Oracle, the example in S1025 is taken along, and the target parent field type corresponding to the field type is found in all the parent field types corresponding to Oracle, that is, in the character data type, date and time data type, and currency data type. And sequencing all the father field types corresponding to Oracle from high to low in advance according to the priority corresponding to each father field type, and sequentially (from high to low) searching target father field types matched with the field types corresponding to the field names in the original table in the father field types according to the sequencing result.
S1027: and acquiring the priority corresponding to each sub-field type, wherein each sub-field type corresponds to the target parent field type.
After finding the target father field type, obtaining one or more sub-field types corresponding to the target father field type and the priority corresponding to each sub-field type.
S1028: and sequencing each sub-field type in all sub-field types corresponding to the target parent 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 sequencing result.
For example, if the second database is Oracle, the example in S1025 is used to find the target field type corresponding to the field type in all the sub-field types corresponding to the target parent field type corresponding to Oracle, that is, in VARCHAR2, NVARCHAR, CHAR. And sequencing all the sub-field types corresponding to the target parent field type from high to low in advance according to the priority corresponding to each sub-field type, 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 sequencing result.
For example, the field type corresponding to a field name in the original table is VARCHAR2, the searched target parent field type is a character data type, and the target parent field type is searched in all sub-field types corresponding to the character data type, and since the priority of VARCHAR2 is highest, VARCHAR2 is preferred, and if the two types are found to match, the searched target field type matched with the field type corresponding to the field name in the original table is marked as the target field type matched with the field name in the original table. This is merely illustrative and is not limiting.
In the implementation manner, different priorities are set according to the number of times the field type is used, and when the field type is searched, the priority is set, and the target field type can be searched without traversing all the field types, so that the speed of determining the target field type is improved, and the speed of creating the data table is improved laterally.
Optionally, in some possible implementations 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 is used in the first configuration table; and adjusting the priority corresponding to each preset field type according to the number of times (or the frequency of use) that each preset field type is used.
For example, each time a certain preset field type in the first configuration table is determined as a target field type, the number of times of use corresponding to the preset field type is increased by one, the number of times that all preset field types are used is counted once every preset duration, and the priority corresponding to each preset field type is adjusted according to the number of times that each preset field type is used. For example, the order is sorted in order of the number of uses from high to low according to the number of times each preset field type is used, and the priority is adjusted for each preset field type according to the order.
Optionally, determining the number of times (or frequency of use) each parent field type and each child field type is used in the second configuration table; according to the number of times (or frequency) that each parent field type and each sub-field type are used, the priority corresponding to each parent field type is adjusted, and the priority corresponding to each sub-field type is adjusted.
In the above implementation manner, at intervals, the priority corresponding to each field type is adjusted in time according to the number of times different field types are used. When the field types are searched, the target field types can be searched from high to low according to the priority, and due to the fact that the priority is set, all the field types are not required to be traversed, the speed of determining the target field types is improved, and the speed of creating the data table is improved 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 application. The apparatus comprises means for performing the steps of the embodiments corresponding to fig. 1,2, 3 and 4. Refer specifically to the related descriptions in the embodiments corresponding to fig. 1, fig. 2, fig. 3, and fig. 4. For convenience of explanation, only the portions related to the present embodiment are shown. Referring to fig. 5, comprising:
an obtaining unit 210, configured to obtain first information corresponding to a type, a field name, and a field name of the input first database;
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-creating sentence.
Optionally, when the first database is the second database, the first information is attribute information, and the obtaining unit 210 is specifically configured to:
And acquiring the type, the field name and the attribute information corresponding to the field name of the input first database, wherein the attribute information comprises at least one of a character string, a text, an integer, a decimal, time and an IP address.
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 the original table of the input second database;
And extracting a field name from the original table and a field type corresponding to the field name.
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 sequencing each preset field type in all preset field types corresponding to the second database according to the priority corresponding to each preset field type, and sequentially searching for a target field type corresponding to the field type according to the sequencing result.
Optionally, the determining unit 220 is further configured to:
acquiring a priority corresponding to each father field type in a preset second configuration table, wherein each father field type corresponds to the target database;
sorting all the father field types corresponding to the second database according to the priority corresponding to each father field type, and sequentially searching for a target father field type corresponding to the field type according to the sorting result;
Acquiring a priority corresponding to each sub-field type, wherein each sub-field type corresponds to the target parent field type;
And sequencing each sub-field type in all sub-field types corresponding to the target parent 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 sequencing result.
Optionally, the apparatus further comprises:
a usage number determining unit configured to determine a 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 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 described above in the various method embodiments for creating a data table, such as S101 through S104 shown in fig. 1. Or the processor 30, when executing the computer instructions 32, performs the functions of the units of the embodiments described above, such as the units 210-240 of fig. 5.
Illustratively, the computer instructions 32 may be partitioned into one or more units that are stored in the memory 31 and executed by the processor 30 to complete the present application. The one or more units may be a series of computer instruction segments capable of performing a specific function describing the execution of the computer instructions 32 in the device 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 functioning specifically as described above.
The device 3 for creating a data table may include, but is not limited to, a processor 30, 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 include more or less components than illustrated, or may combine certain components, or different components, e.g. the device for creating a data table may also include an input-output device, a network access device, a bus, etc.
The Processor 30 may be a central processing unit (Central Processing Unit, CPU), other general purpose Processor, digital signal Processor (DIGITAL SIGNAL Processor, DSP), application SPECIFIC INTEGRATED Circuit (ASIC), off-the-shelf Programmable gate array (Field-Programmable GATE ARRAY, FPGA) or other Programmable logic device, discrete gate or transistor logic device, discrete hardware components, or the like. 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, for example, a hard disk or a memory of the apparatus for creating a data table. The memory 31 may be an external storage terminal of the apparatus for creating a data table, such as a plug-in hard disk, a smart memory card (SMART MEDIA CARD, SMC), a Secure Digital (SD) card, a flash memory card (FLASH CARD), or the like. Further, the memory 31 may also include both an internal memory unit and an external memory 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 for temporarily storing data that has been output or is to be output.
The embodiment of the application also provides a computer storage medium, which can be nonvolatile or volatile, and stores a computer program, and the computer program is executed by a processor to implement the steps in the method embodiments for creating the data table.
The above embodiments are only for illustrating the technical solution of the present application, and not for limiting the same; although the application has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present application, and are intended to be included in the scope of the present application.

Claims (8)

1. A method of creating a data table, comprising:
Acquiring the type, the field name and the first information corresponding to the field name of the input first database; the first information is attribute information, and the attribute information comprises a description sentence; the description statement is used for describing the data type corresponding to the field name;
Determining a target field type corresponding to the first information in a second database according to the first information and a preset mapping relation; the first database is the same as the second database; 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: extracting keywords corresponding to the attribute information; 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;
Generating a list building statement corresponding to the field name and the target field type by using an automatic list building program according to the field name and the target field type;
And creating a data table in the second database according to the table-creating sentence by using an automatic table-creating program.
2. 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 includes:
Acquiring the type and the original table of the input second database;
And extracting a field name from the original table and a field type corresponding to the field name.
3. The method of claim 2, wherein 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 sequencing each preset field type in all preset field types corresponding to the second database according to the priority corresponding to each preset field type, and sequentially searching for a target field type corresponding to the field type according to the sequencing result.
4. The method of claim 2, wherein 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 father field type in a preset second configuration table, wherein each father field type corresponds to a target database;
sorting all the father field types corresponding to the second database according to the priority corresponding to each father field type, and sequentially searching for a target father field type corresponding to the field type according to the sorting result;
Acquiring a priority corresponding to each sub-field type, wherein each sub-field type corresponds to the target parent field type;
And sequencing each sub-field type in all sub-field types corresponding to the target parent 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 sequencing result.
5. A method as claimed in claim 3, wherein the method further comprises:
determining the number of times each of the preset field types in the first configuration table is used;
And adjusting the priority corresponding to each preset field type according to the number of times each preset field type is used.
6. An apparatus for creating a data table, comprising:
the acquisition unit is used for acquiring the type, the field name and the first information corresponding to the field name of the input first database; the first information is attribute information, and the attribute information comprises a description sentence; the description statement is used for describing the data type corresponding to the field name;
The determining unit is used for determining the type of the target field corresponding to the first information in the second database according to the first information and a preset mapping relation; the first database is the same as the second database; 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: extracting keywords corresponding to the attribute information; 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;
the generation unit is used for generating a table building statement corresponding to the field name and the target field type by utilizing an automatic table building program according to the field name and the target field type;
And the creation unit is used for creating a data table in the second database according to the table-building sentence by utilizing an automatic table-building program.
7. 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, wherein the processor implements the method of any one of claims 1 to 5 when executing the computer program.
8. A computer readable storage medium storing a computer program, characterized in that the computer program when executed by a processor implements the method according to any one of claims 1 to 5.
CN202110736351.9A 2021-06-30 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 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 2021-06-30 Method, device, equipment and storage medium for creating data table

Publications (2)

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

Family

ID=78009702

Family Applications (1)

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

Country Status (1)

Country Link
CN (1) CN113505128B (en)

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114090548B (en) * 2021-11-29 2024-07-16 平安科技(深圳)有限公司 Database-based data processing method, device, equipment and storage medium
CN114490858A (en) * 2022-02-22 2022-05-13 北京科杰科技有限公司 Table structure type conversion system and method for big data and RMDB
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
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
CN117591588A (en) * 2023-11-21 2024-02-23 国金证券股份有限公司 Data processing system and data processing method

Citations (5)

* 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

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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 (5)

* 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

Non-Patent Citations (1)

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

Also Published As

Publication number Publication date
CN113505128A (en) 2021-10-15

Similar Documents

Publication Publication Date Title
CN113505128B (en) Method, device, equipment and storage medium for creating data table
US11907244B2 (en) Modifying field definitions to include post-processing instructions
US20230121279A1 (en) System and method for providing technology assisted data review with optimizing features
CN108932294B (en) Resume data processing method, device, equipment and storage medium based on index
US10628492B2 (en) Distributed graph database writes
US20160117405A1 (en) Information Processing Method and Apparatus
US20180357329A1 (en) Supporting tuples in log-based representations of graph databases
US10169414B2 (en) Character matching in text processing
CN116028653B (en) Method and system for constructing map by visually configuring multi-source heterogeneous data
WO2022083436A1 (en) Data processing method and apparatus, and device and readable storage medium
US20180357278A1 (en) Processing aggregate queries in a graph database
CN110795524A (en) Main data mapping processing method and device, computer equipment and storage medium
Silva et al. Integrating big data into the computing curricula
CN115203435A (en) Entity relation generation method and data query method based on knowledge graph
US10235422B2 (en) Lock-free parallel dictionary encoding
EP3635580A1 (en) Functional equivalence of tuples and edges in graph databases
CN110737432A (en) script aided design method and device based on root list
US10234295B2 (en) Address remediation using geo-coordinates
CN114153910A (en) Data acquisition method and device, electronic device and computer program product
CN115617773A (en) Data migration method, device and system
US11250002B2 (en) Result set output criteria
US9256644B1 (en) System for identifying and investigating shared and derived content
CN114741077A (en) Page effect preview method, device, equipment and medium based on field granularity
CN114676155A (en) Code prompt information determining method, data set determining method and electronic equipment
CN106557564A (en) A kind of object data analysis method and device

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
GR01 Patent grant