CN101533414A - A method and a device for generating unique identifier of database record - Google Patents

A method and a device for generating unique identifier of database record Download PDF

Info

Publication number
CN101533414A
CN101533414A CN200910130809A CN200910130809A CN101533414A CN 101533414 A CN101533414 A CN 101533414A CN 200910130809 A CN200910130809 A CN 200910130809A CN 200910130809 A CN200910130809 A CN 200910130809A CN 101533414 A CN101533414 A CN 101533414A
Authority
CN
China
Prior art keywords
character
converted
value
character string
time portion
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.)
Pending
Application number
CN200910130809A
Other languages
Chinese (zh)
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.)
Alibaba Group Holding Ltd
Original Assignee
Alibaba Group Holding 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 Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN200910130809A priority Critical patent/CN101533414A/en
Publication of CN101533414A publication Critical patent/CN101533414A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application discloses a method and a device for generating unique identifier of database record; wherein the method comprises the following steps: acquiring system time; generating a time character string according to the system time; generating random character string; splicing the time character string and the random character string into a unique identifier, wherein the time character string is positioned at the beginning of the unique identifier; and the unique identifier is distributed to a data table to be a primary key of the data table. In the embodiment of the application, the technical proposal of splicing the generated time character string and the random character string into the unique identifier and arranging the time character string at the beginning of the unique identifier solves the problem that the uniqueness and the order of the unique identifier can not be realized at the same time, thereby ensuring the uniqueness and the order of the identifier at the same time.

Description

Method and device that a kind of unique identifier of database record generates
Technical field
The application relates to field of computer technology, relates in particular to method and device that a kind of unique identifier of database record generates.
Background technology
In development of database system, tend to use the major key that unique identifier is used as tables of data, with each line item of distinguishes data table, and the generating mode of unique identifier directly influence data in the tables of data write efficient and recall precision.In general, if do not need a concentrated server to coordinate during each self-generating unique identifier of various computing machine, such method is that efficient is high; If the order of the unique identifier that generates meets the natural order of data recording, such unique identifier is higher for data retrieval efficient; If the shared byte of unique identifier that computing machine generates is few more, such unique identifier is high more for data retrieval efficient, and more saves storage space; If the unique identifier that computing machine generates meets the identifier definition of most of programming languages, then such unique identifier is friendly to programming.
At present, the method for generation unique identifier mainly contains two kinds.A kind of is that the mechanism that increases certainly of utilizing database to provide generates unique identifier.
General database all can provide from increasing data type or from increasing sequence.For the data rows of needs generation unique identifier, at first to specify these data to classify as from increasing data type or specifying it from from increasing sequence, obtaining from increasing numerical value.When needs generate unique identifier, only need to insert record to the data of database table, the data rows of unique identifier will produce automatically.For increasing data type certainly or from increasing sequence, each value that produces all can increase automatically, so just can guarantee the order of the identifier that generates.If the client of database need generate unique identifier, then client just can obtain unique identifier after need coming and going database server, and database server also just becomes the coordination server that each client generates unique identifier.
For example, in MS SQL Server database, just provide a kind of special data type attribute-identifier.Each produce new record in, identifier column all can automatic increase, to realize the unique identification of data recording.For another example, in the ORACLE database, also provide SEQUENCE mechanism, realized generating from the unique identifier that increases mechanism.When needs use when increasing identifier, can from relevant SEQUENCE, obtain ever-increasing sequential value.
Another kind is to use random algorithm to generate unique identifier, for example use UUID (UniversalUnique Identifier, the world unifies identifier) algorithm or GUID (Global Unique Identifier, the unified identifier in the whole world) algorithm generates unique identifier.
Utilizing random algorithm to generate unique identifier, mainly is to utilize time and the current software and hardware information of computing machine to produce random number.Therefore, each identifier that generates is fully inequality in different computing machines, and this has just guaranteed the uniqueness of identifier.
For example, at first use the GUID algorithm to generate the identifier the beginning part with random number, next information such as the timestamp of using system, state of runtime machine and hardware characteristics increase the randomness of sign.Can guarantee that so any in the world two signs that computing machine generated all are unique.It needs to be noted, though comprised the timestamp of system in the unique identifier that uses the GUID algorithm to generate, but owing to what be positioned at this identifier the beginning part is random number, so identifier does not meet the natural order of data recording, only just guarantees the uniqueness of identifier.
In the process that realizes the application, the inventor finds that there is following shortcoming in prior art:
1. the shortcoming that increases mechanism generation unique identifier certainly of utilizing database to provide.
The identifier that increases the mechanism generation certainly that utilizes database to provide not is that the whole world is unique, does not have uniqueness:
Under single database situation, increase mechanism certainly and can guarantee unique mark.Yet under distributed multiple database environment, can't guarantee the sign uniqueness between the database.This just causes cutting apart again between distributed data base or during mobile data, can face very complicated identification collision problem of management.
For example, use MS SQL Server or ORACLE data increase mechanism certainly the time, the sign uniqueness problem in the own company can be controlled by formulating unified strategy.But in case will carry out exchanges data with other company the time, the problem of a plurality of identical unique identifiers will occur existing, its root just is that from increasing the sign that mechanism produces not be globally unique.
Again for example, different MS SQL Server or ORACLE data servers be can do by myself maintenance one cover from the increasing sequence data.But for distributed database storing, the data of same data acquisition can be distributed in a plurality of databases and store.This just requires each database and is produced increase certainly sign will be different with the sign that other databases are produced, otherwise can produce the conflict of sign uniqueness.And the database mechanism that increases is not certainly separately considered collision problem with other databases.Therefore, in order still to use data from increasing mechanism under distributed storage environment, that must stipulate each database increases strategy certainly, and each database produces from increasing sign by the rule of not conflicting mutually.Simultaneously, when needs increase new stored data base, perhaps with the record of database separate storage again, perhaps with partial data when data move on to another database, a whole set of sign may be carried out once big adjustment again from the control strategy.These bring many problems and trouble all for the exploitation of distributed storage.
2. utilize random algorithm to generate the shortcoming of unique identifier
The identifier that utilizes random algorithm to generate does not meet the natural order of data recording, does not have order:
The unique identifier of Chan Shenging does not have certain order at random, and is irrelevant with the natural order of data recording.B+ tree logical order and physical sequential that retrieval is relevant are inequality, thereby cause data retrieval efficient low more.And the caching mechanism that relates to when data read or retrieval mostly is successional caching mechanism, and there is not continuity in the unique identifier that utilizes random algorithm to generate, therefore, reads or retrieves such unique identifier and cause buffer efficiency lower.
For example, the identifier of GUID or UUID generation is a completely random.When inserting data-base recording, the physical location of last insertion record and the physical location of a back insertion are generally all very approaching.But the logical order of these two records is relevant with the order of sign, and the identifier completely random of twice generation, this has just caused the logical order of record different fully with physical sequential, be reflected on the B+ tree arrangement architecture of the required index of search records two physically adjacent nodes non-conterminous fully in logic.Thereby when causing retrieve data, often need significantly to carry out the pointer skip operation on indexed file or the data file, influence retrieval rate.
Summary of the invention
Method and device that the embodiment of the present application provides a kind of unique identifier of database record to generate have solved the uniqueness of unique identifier and the problem that order can't realize simultaneously, have guaranteed the order of identifier when guaranteeing the identifier uniqueness.
The method that the embodiment of the present application provides a kind of unique identifier of database record to generate may further comprise the steps:
Obtain system time;
According to described system time rise time partial character string;
Generate the random partial character string;
Described time portion character string and described random partial character string are spliced into unique identifier, and described time portion character string is positioned at the beginning position of described unique identifier;
Described unique identifier is distributed to the major key of tables of data as described tables of data.
Wherein, describedly comprise according to described system time rise time partial character string:
Obtain time portion value to be converted according to described system time;
Described time portion value to be converted is converted to described time portion character string.
Wherein, describedly time portion value to be converted be converted to described time portion character string comprise:
Described time portion value to be converted is converted to first character in the described time portion character string, and described first character is any one character among the A-Z;
Described time portion value to be converted is converted to second character in the described time portion character string to a last character, and described second character is any one character among 0-9 and/or the A-Z to every character in the last character;
Described first character is spliced into described time portion character string to a last character.
Wherein, describedly described time portion value to be converted is converted to first character comprises in the described time portion character string:
Calculate the convertible value of described first character correspondence according to described time portion value to be converted;
The convertible value of described first character correspondence of calculating is converted to any one character among the described A-Z.
Wherein, described second character that described time portion value to be converted is converted in the described time portion character string comprises to a last character:
Calculate the convertible value of described second character according to described time portion value to be converted to a last character correspondence;
Described second character of calculating is converted to any one character among described 0-9 and/or the A-Z to the convertible value of a last character correspondence.
Wherein, describedly time portion value to be converted be converted to described time portion character string comprise:
Described time portion value to be converted is converted to first character in the described time portion character string to a last character, and described first character is any one character among 0-9 and/or the A-Z to a last character;
Described first character is spliced into described time portion character string to a last character.
Wherein, described first character that described time portion value to be converted is converted in the described time portion character string comprises to a last character:
Calculate the convertible value of described first character according to described time portion value to be converted to a last character correspondence;
Described first character of calculating is converted to any one character among described 0-9 and/or the A-Z to the convertible value of a last character correspondence.
Wherein, described generation random partial character string comprises:
Generate random number;
Obtain random partial value to be converted according to described random number;
Described random partial value to be converted is converted to described random partial character string.
Wherein, describedly random partial value to be converted be converted to described random partial character string comprise:
Described random partial value to be converted is converted to first character in the described random partial character string to a last character, and described first character is any one character among 0-9 and/or the A-Z to a last character;
Described first character is spliced into described random partial character string to a last character.
Wherein, described first character that described random partial value to be converted is converted in the described random partial character string comprises to a last character:
Calculate the convertible value of described first character according to described random partial value to be converted to a last character correspondence;
Described first character of calculating is converted to any one character among described 0-9 and/or the A-Z to the convertible value of a last character correspondence.
The device that the embodiment of the present application provides a kind of fulfillment database record unique identifier to generate, comprise system time acquisition module, time portion character string generation module, random partial character string generation module, character string concatenation module and identifier allocation module, wherein
Described system time acquisition module is used to obtain system time;
Described time portion character string generation module is connected with described system time acquisition module, is used for the system time rise time partial character string of obtaining according to described system time acquisition module;
Described random partial character string generation module is used to generate the random partial character string;
Described character string concatenation module, be connected respectively with described random partial character string generation module with described time portion character string generation module, be used for the time portion character string of described time portion character string generation module generation and the random partial character string of described random partial character string generation module generation are spliced into unique identifier, described time portion character string is positioned at the beginning position of described unique identifier;
Described identifier allocation module is connected with described character string concatenation module, is used for the unique identifier that described character string concatenation module obtains is distributed to the major key of tables of data as described tables of data.
Wherein, described time portion character string generation module comprises time portion value acquiring unit to be converted and time portion character string acquiring unit, wherein,
Described time portion value acquiring unit to be converted is used for according to described system time acquisition time part value to be converted;
Described time portion character string acquiring unit is connected with described time portion value acquiring unit to be converted, is used for the time portion value to be converted that described time portion value acquiring unit to be converted obtains is converted to described time portion character string.
Wherein, described time portion character string acquiring unit comprises that first obtains subelement, second and obtain subelement and first and handle subelement, wherein,
Described first obtains subelement, is used for described time portion value to be converted is converted to first character of described time portion character string, and described first character is any one character among the A-Z;
Described second obtains subelement, second character that is used for described time portion value to be converted is converted to described time portion character string be to a last character, and described second character is any one character among 0-9 and/or the A-Z to every character in the last character;
Described first handles subelement, obtain subelement and described second and obtain subelement and be connected respectively with described first, be used for obtaining subelement and described second and obtain first character that subelement obtains and be spliced into described time portion character string to a last character with described first.
Wherein, described first obtains subelement specifically is used for, and calculates the convertible value of described first character correspondence according to described time portion value to be converted; The convertible value of described first character correspondence of calculating is converted to any one character among the described A-Z.
Wherein, described second obtains subelement specifically is used for, and calculates the convertible value of described second character to a last character correspondence according to described time portion value to be converted; Described second character of calculating is converted to any one character among described 0-9 and/or the A-Z to the convertible value of a last character correspondence.
Wherein, described time portion character string acquiring unit comprises that the 3rd obtains the subelement and the second processing subelement, wherein,
The described the 3rd obtains subelement, and first character that is used for described time portion value to be converted is converted to described time portion character string be to a last character, and described first character is any one character among 0-9 and/or the A-Z to a last character;
Described second handles subelement, obtains subelement and is connected with the described the 3rd, is used for obtaining first character that subelement obtains with the described the 3rd and is spliced into described time portion character string to a last character.
Wherein, the described the 3rd obtains subelement specifically is used for, and calculates the convertible value of described first character to a last character correspondence according to described time portion value to be converted; Described first character of calculating is converted to any one character among described 0-9 and/or the A-Z to the convertible value of a last character correspondence.
Wherein, described random partial character string generation module comprises random number generation unit, random partial value acquiring unit to be converted and random partial character string acquiring unit, wherein,
Described random number generation unit is used to generate random number;
Described random partial value acquiring unit to be converted is connected with described random number generation unit, is used for obtaining random partial value to be converted according to the random number that described random number generation unit generates;
Described random partial character string acquiring unit is connected with described random partial value acquiring unit to be converted, is used for the random partial value to be converted that described random partial value acquiring unit to be converted obtains is converted to described random partial character string.
Wherein, described random partial character string acquiring unit comprises that the 4th obtains subelement and the 3rd processing subelement, wherein,
The described the 4th obtains subelement, and first character that is used for described random partial value to be converted is converted to described random partial character string be to a last character, and described first character is any one character among 0-9 and/or the A-Z to a last character;
The described the 3rd handles subelement, obtains subelement and is connected with the described the 4th, is used for obtaining first character that subelement obtains with the described the 4th and is spliced into described random partial character string to a last character.
Wherein, the described the 4th obtains subelement specifically is used for, and calculates the convertible value of described first character to a last character correspondence according to described random partial value to be converted; Described first character of calculating is converted to any one character among described 0-9 and/or the A-Z to the convertible value of a last character correspondence.
In the embodiment of the present application, be spliced into unique identifier by time portion character string and the random partial character string that will generate, and the time portion character string is placed the beginning position of unique identifier, solve the uniqueness of unique identifier and the problem that order can't realize simultaneously, when guaranteeing the identifier uniqueness, guaranteed the order of identifier.
Description of drawings
In order to be illustrated more clearly in the embodiment of the present application or technical scheme of the prior art, to do one to the accompanying drawing of required use in embodiment or the description of the Prior Art below introduces simply, apparently, accompanying drawing in describing below only is some embodiment of the application, for those of ordinary skills, under the prerequisite of not paying creative work, can also obtain other accompanying drawing according to these accompanying drawings.
Fig. 1 is the process flow diagram of the method that a kind of unique identifier of database record generates in the embodiment of the present application one;
Fig. 2 is the process flow diagram of a kind of method of rise time partial character string in the embodiment of the present application one;
Fig. 3 is a kind of process flow diagram that time portion value to be converted is converted to the method for time portion character string in the embodiment of the present application one;
Fig. 4 is a kind of process flow diagram that time portion value to be converted is converted to the method for time portion character string in the embodiment of the present application one;
Fig. 5 is a kind of process flow diagram that time portion value to be converted is converted to the method for time portion character string in the embodiment of the present application one;
Fig. 6 is a kind of process flow diagram that generates the method for random partial character string in the embodiment of the present application one;
Fig. 7 is a kind of process flow diagram that random partial value to be converted is converted to the method for random partial character string in the embodiment of the present application one;
Fig. 8 is the process flow diagram of the method that a kind of unique identifier of database record generates in the embodiment of the present application two;
Fig. 9 is the process flow diagram of the method that a kind of unique identifier of database record generates in the embodiment of the present application three;
Figure 10 is the process flow diagram of the method that a kind of unique identifier of database record generates in the embodiment of the present application four;
Figure 11 is the process flow diagram of the method that a kind of unique identifier of database record generates in the embodiment of the present application five;
Figure 12 is the process flow diagram of the method that a kind of unique identifier of database record generates in the embodiment of the present application six;
Figure 13 is the process flow diagram of the method that a kind of unique identifier of database record generates in the embodiment of the present application seven;
Figure 14 is the structural drawing of the device that a kind of fulfillment database record unique identifier generates in the embodiment of the present application eight;
Figure 15 is the structural drawing of a kind of time portion character string generation module in the embodiment of the present application eight;
Figure 16 is the structural drawing of a kind of time portion character string acquiring unit in the embodiment of the present application eight;
Figure 17 is the structural drawing of a kind of time portion character string acquiring unit in the embodiment of the present application eight;
Figure 18 is the structural drawing of a kind of random partial character string generation module in the embodiment of the present application eight;
Figure 19 is the structural drawing of a kind of random partial character string acquiring unit in the embodiment of the present application eight.
Embodiment
For the purpose, technical scheme and the advantage that make the application is clearer, the application is described in detail below in conjunction with the drawings and specific embodiments.Obviously, described embodiment only is the application's part embodiment, rather than whole embodiment.Based on the embodiment among the application, those of ordinary skills are not making the every other embodiment that is obtained under the creative work prerequisite, all belong to the scope of the application's protection.
Among the application, by a kind of unique identifier of database record generation method and device are provided, be spliced into unique identifier by time portion character string and the random partial character string that will generate, and the time portion character string is placed the beginning position of unique identifier, solve the uniqueness of unique identifier and the problem that order can't realize simultaneously, when guaranteeing the identifier uniqueness, guaranteed the order of identifier.
Below in conjunction with drawings and Examples, the application's embodiment is described in further detail:
The method that the embodiment of the present application one provides a kind of unique identifier of database record to generate as shown in Figure 1, may further comprise the steps:
Step 101 is obtained system time and according to system time rise time partial character string.
Step 102 generates the random partial character string.
Step 103 is spliced into unique identifier with time portion character string and random partial character string, and the time portion character string is positioned at the beginning position of unique identifier.
Step 104 is distributed to the major key of tables of data as tables of data with unique identifier.Concrete, every tables of data in the database all has fixing primary key column, and each major key in this primary key column is in order to each line item of unique identification data table.Then unique identifier being distributed to tables of data is about to unique identifier as the process of the major key of tables of data and is written in the capable primary key column of corresponding data.
Wherein, step 101 and step 102 do not have inevitable sequencing.Be that the process of rise time partial character string and random partial character string can walk abreast and carries out, also can successively carry out according to concrete being provided with.
The embodiment of the present application one also provides a kind of method of rise time partial character string, as shown in Figure 2, may further comprise the steps:
Step 201 is according to system time acquisition time part value to be converted.
When the method for using present embodiment to provide, need set in advance a system time is timing zero point, and the millisecond round values of this timing correspondence at zero point is 0.After having obtained system time, the system time that the system time that obtains is corresponding with timing zero point subtracts each other and difference is accurate to millisecond, obtains the millisecond round values of system time correspondence.After obtaining the millisecond round values of system time correspondence, can be directly with the millisecond round values of system time correspondence directly as time portion value to be converted, also the millisecond round values of system time correspondence can be multiply by the time portion conversion coefficient, obtain time portion value to be converted.
Step 202 is converted to the time portion character string with time portion value to be converted.
Concrete, can adopting as shown in Figure 3, step is converted to the time portion character string with time portion value to be converted.
Step 301 is converted to first character in the time portion character string with time portion value to be converted, and first character is any one character among the A-Z.
Step 302 is converted to second character in the time portion character string to a last character with time portion value to be converted, and second character is any one character among 0-9 and/or the A-Z to every character in the last character.
For example: if the total eight bit character of time portion character string.Can time portion value to be converted be divided exactly with 78364164096 (36 7 powers) earlier, get 26 mould (getting remainder after promptly dividing exactly 26) again, obtain an integer between 0 to 25, i.e. the convertible value of first character correspondence.Then, with obtain 0 to 25 between an integer be converted to the character of A-Z, concrete transformation rule be 0 corresponding A, 1 corresponding B ... 25 corresponding Z.7 powers of earlier time portion value to be converted being divided exactly with 36 can guarantee that the figure place of first character string in computing is higher than other seven character strings, and promptly in the eight bit character string, the variation of first least easy system for tracking time of character changes.
Second can be adopted following method to obtain to eight bit character: earlier time portion value to be converted is divided exactly 6 powers with 36,36 5 powers, 36 4 powers, 36 3 powers, 36 2 powers, 36 1 power, 36 0 power respectively, then with total respectively with 36 deliverys, obtain the integer between 70 to 35, promptly second character is to the convertible round values of eight bit character correspondence.Then, the integer between obtain 70 to 35 is converted to the character of 0-9 and/or A-Z, concrete transformation rule is the corresponding character 0-9 of round values 0-9, the corresponding character A-Z of round values 10-35.
Step 303 is spliced into the time portion character string with the time portion character.
For example, second character that obtains in first character obtaining in the step 301 and the step 302 can be spliced into 8 long character strings to eight bit character.
Concrete, also can adopting as shown in Figure 4, step is converted to the time portion character string with time portion value to be converted.
Step 401 is converted to second character in the time portion character string to a last character with time portion value to be converted, and second character is any one character among 0-9 and/or the A-Z to every character in the last character.
Step 402 is converted to first character in the time portion character string with time portion value to be converted, and first character is any one character among the A-Z.
Step 403 is spliced into the time portion character string with the time portion character.
For example, first character that second character obtaining in the step 401 obtains in eight bit character and the step 402 can be spliced into 8 long character strings.
Concrete, also can adopting as shown in Figure 5, step is converted to the time portion character string with time portion value to be converted.
Step 501 is converted to first character in the time portion character string to a last character with time portion value to be converted, and first character is any one character among 0-9 and/or the A-Z to a last character.
For example, if the time portion character string has eight bit character, first can be adopted following method to obtain to eight bit character: can earlier time portion value to be converted be divided exactly 7 powers with 36,36 6 powers, 36 5 powers, 36 4 powers, 36 3 powers, 36 2 powers, 36 1 power, 36 0 power respectively, then with total respectively with 36 deliverys, obtain the integer between 80 to 35, promptly first character is to the convertible round values of eight bit character correspondence.Then, the integer between obtain 80 to 35 is converted to the character of 0-9 and/or A-Z, concrete transformation rule is the corresponding character 0-9 of round values 0-9, the corresponding character A-Z of round values 10-35.
Step 502 is spliced into the time portion character string with the time portion character.
For example, first character that obtains in the step 501 can be spliced into 8 long character strings to eight bit character.
The embodiment of the present application one also provides a kind of method that generates the random partial character string, as shown in Figure 6, may further comprise the steps:
Step 601 generates random number.Concrete, can adopt UUID algorithm or GUID algorithm to generate this random number.
For example, if the random partial character string has 12 characters, and every character be among 0-9 and/or the A-Z any one character then.Then can generate one 0 to 4738381338321616896 random integers between (36 12 powers), can guarantee that like this random number space is maximum and can not produce unnecessary random number.
Step 602 is obtained random partial value to be converted according to random number.Can also the random number that generates can be multiply by the random partial conversion coefficient with random number directly as random partial value to be converted, obtain random partial value to be converted.For example, the random partial conversion coefficient can be set at 1, the round values that obtains in the step 601 be multiply by 1 after, the time that obtains value to be converted at random.
Step 603 is converted to the random partial character string with the random partial that obtains value to be converted.
Concrete, can adopting as shown in Figure 7, step is converted to the random partial character string with random partial value to be converted.
Step 701 is converted to first character in the random partial character string to a last character with random partial value to be converted, and first character is any one character among 0-9 and/or the A-Z to a last character.
For example, if the random partial character string has 12 characters, first to the 12 character can adopt following method to obtain: can earlier random partial value to be converted be divided exactly 11 powers with 36,36 10 powers, 36 9 powers, 36 8 powers, 36 7 powers, 36 6 powers, 36 5 powers, 36 4 powers, 36 3 powers, 36 2 powers, 36 1 power, 36 0 power respectively, then with total respectively with 36 deliverys, obtain the integer between 12 0 to 35, i.e. the convertible round values of 12 character correspondences of first character to the.Then, the integer between obtain 12 0 to 35 is converted to the character of 0-9 and/or A-Z, concrete transformation rule is the corresponding character 0-9 of round values 0-9, the corresponding character A-Z of round values 10-35.
Step 702 is spliced into the random partial character string with the random partial character.
For example, 12 characters of first character to that obtain in the step 701 can be spliced into 12 long character strings.
In the embodiment of the present application one, be spliced into unique identifier by time portion character string and the random partial character string that will generate, and the time portion character string is placed the beginning position of unique identifier, solve the uniqueness of unique identifier and the problem that order can't realize simultaneously, when guaranteeing the identifier uniqueness, guaranteed the order of identifier.
The method that the embodiment of the present application two provides a kind of unique identifier of database record to generate is timing zero point when setting in advance on September 9th, 1,999 zero, as shown in Figure 8, may further comprise the steps:
Step 801 is obtained the round values of system time correspondence, when current system time is on September 9th, 1,999 zero.Then the round values of system time correspondence is 0.
Step 802 multiply by time portion conversion coefficient 0.5 with the round values of system time correspondence, obtains time portion value to be converted.Promptly the round values of obtaining with step 801 multiply by 0.5, and obtaining time portion value to be converted is 0.
Step 803 is according to the convertible value of first character correspondence of the time portion that obtains in the step 802 value calculating to be converted.Time portion value to be converted can be divided exactly with 78364164096 (36 7 powers), get 26 mould again, obtain 0, i.e. the convertible value of first character correspondence.
Step 804 is converted to character among the A-Z with the convertible value of first character correspondence calculating.Concrete transformation rule be 0 corresponding A, 1 corresponding B ... 25 corresponding Z, then transformation result is " A ".
Step 805 is calculated the convertible value of second character to a last character correspondence according to the time portion that obtains in the step 802 value to be converted.Time portion value to be converted can be divided exactly 6 powers with 36,36 5 powers, 36 4 powers, 36 3 powers, 36 2 powers, 36 1 power, 36 0 power respectively, then with total respectively with 36 deliverys, obtain 7 integers successively, be respectively " 0 ", " 0 ", " 0 ", " 0 ", " 0 ", " 0 ", " 0 ".
Step 806 is converted to the character string of being made up of the character among 0-9 and/or the A-Z with second character calculating to the convertible value of a last character correspondence.Concrete transformation rule is the corresponding character 0-9 of round values 0-9, and the corresponding character A-Z of round values 10-35 is spliced into 7 long character strings afterwards and is " 0000000 ".
Step 807 is spliced into 8 long character strings with second character that obtains in first character obtaining in the step 804 and the step 806 to eight bit character, and the result is " A0000000 ".
Step 808 generates random number.Can generate one 0 to 4738381338321616896 random integers between (36 12 powers), for example, the random number of generation is 2656690246482105794.
Step 809 multiply by random partial conversion coefficient 1 with the random number that generates, and obtaining random partial value to be converted is 2656690246482105794.
Step 810 is converted to the random partial character string with random partial value to be converted, and first character wherein is character among 0-9 and/or the A-Z to a last character.Promptly, earlier random partial value to be converted is divided exactly 11 powers with 36,36 10 powers, 36 9 powers, 36 8 powers, 36 7 powers, 36 6 powers, 36 5 powers, 36 4 powers, 36 3 powers, 36 2 powers, 36 1 power, 36 0 power respectively, then with total respectively with 36 deliverys, obtain the integer between 12 0 to 35, i.e. the convertible round values of 12 character correspondences of first character to the.Then, integer between obtain 12 0 to 35 is converted to the character of 0-9 and/or A-Z, concrete transformation rule is the corresponding character 0-9 of round values 0-9, the corresponding character A-Z of round values 10-35, and the character that obtains first to the 12 is followed successively by " K6MU3EHXZK5E ".
Step 811 is spliced into 12 long character strings with 12 characters of first character to that obtain in the step 810, and the result is " K6MU3EHXZK5E ".
Step 812, the random partial character string that time portion character string that step 807 is obtained and step 811 obtain is spliced into unique identifier, and the time portion character string is positioned at the beginning position of unique identifier.The unique identifier that splicing obtains is " A0000000K6MU3EHXZK5E ".
After obtaining unique identifier, unique identifier need be distributed to the major key of tables of data as tables of data.Wherein, step 801-807 does not have inevitable sequencing with step 808-811.Also can first execution in step 808-811, execution in step 801-807, execution in step 812 at last again.Simultaneously executed in parallel step 801-807 and step 808-811, after step 807 and step 811 all are finished, last execution in step 812.
The method that the embodiment of the present application three provides a kind of unique identifier of database record to generate is timing zero point when setting in advance on September 9th, 1,999 zero, as shown in Figure 9, may further comprise the steps:
Step 901 is obtained the round values of system time correspondence, current system time be on September 9th, 1999 for the moment.Then the round values of system time correspondence is 3600000.
Step 902 multiply by time portion conversion coefficient 0.5 with the round values of system time correspondence, obtains time portion value to be converted.Promptly the round values of obtaining with step 901 multiply by 0.5, and obtaining time portion value to be converted is 1800000.
Step 903 is according to the convertible value of first character correspondence of the time portion that obtains in the step 902 value calculating to be converted.Time portion value to be converted can be divided exactly with 78364164096 (36 7 powers), get 26 mould again, obtain 0, i.e. the convertible value of first character correspondence.
Step 904 is converted to character among the A-Z with the convertible value of first character correspondence calculating.Concrete transformation rule be 0 corresponding A, 1 corresponding B ... 25 corresponding Z, then transformation result is " A ".
Step 905 is calculated the convertible value of second character to a last character correspondence according to the time portion that obtains in the step 902 value to be converted.Time portion value to be converted can be divided exactly 6 powers with 36,36 5 powers, 36 4 powers, 36 3 powers, 36 2 powers, 36 1 power, 36 0 power respectively, then with total respectively with 36 deliverys, obtain 7 integers successively, be respectively " 0 ", " 0 ", " 1 ", " 2 ", " 20 ", " 32 ", " 0 ".
Step 906 is converted to any one character among described 0-9 and/or the A-Z with second character calculating to the convertible value of a last character correspondence.Concrete transformation rule is the corresponding character 0-9 of round values 0-9, and the corresponding character A-Z of round values 10-35 obtains second character and is followed successively by " 0012KW0 " to a last character (eight bit character).
Step 907 is spliced into 8 long character strings with second character that obtains in first character obtaining in the step 904 and the step 906 to eight bit character, and the result is " A0012KW0 ".
Step 908 generates random number.Can generate one 0 to 4738381338321616896 random integers between (36 12 powers), for example, the random number of generation is 2316270079877052556.
Step 909 multiply by random partial conversion coefficient 1 with the random number that generates, and obtaining random partial value to be converted is 2316270079877052556
Step 910 is converted to the random partial character string with random partial value to be converted, and first character wherein is any one character among 0-9 and/or the A-Z to a last character.Promptly, earlier random partial value to be converted is divided exactly 11 powers with 36,36 10 powers, 36 9 powers, 36 8 powers, 36 7 powers, 36 6 powers, 36 5 powers, 36 4 powers, 36 3 powers, 36 2 powers, 36 1 power, 36 0 power respectively, then with total respectively with 36 deliverys, obtain the integer between 12 0 to 35, i.e. the convertible round values of 12 character correspondences of first character to the.Then, integer between obtain 12 0 to 35 is converted to the character of 0-9 and/or A-Z, concrete transformation rule is the corresponding character 0-9 of round values 0-9, the corresponding character A-Z of round values 10-35, and the character that obtains first to the 12 is followed successively by " HLIX7SWLKQKS ".
Step 911 is spliced into 12 long character strings with 12 characters of first character to that obtain in the step 910, and the result is " HLIX7SWLKQKS ".
Step 912, the random partial character string that time portion character string that step 907 is obtained and step 911 obtain is spliced into unique identifier, and the time portion character string is positioned at the beginning position of unique identifier.The unique identifier that splicing obtains is " A0012KW0HLIX7SWLKQKS ".
After obtaining unique identifier, unique identifier need be distributed to the major key of tables of data as tables of data.Wherein, step 901-907 does not have inevitable sequencing with step 908-911.Also can first execution in step 908-911, execution in step 901-907, execution in step 912 at last again.Simultaneously executed in parallel step 901-907 and step 908-911, after step 907 and step 911 all are finished, last execution in step 912.
The method that the embodiment of the present application four provides a kind of unique identifier of database record to generate is timing zero point when setting in advance on September 9th, 1,999 zero, as shown in figure 10, may further comprise the steps:
Step 1001 is obtained the round values of system time correspondence, and current system time is 2 o'clock on the 9th September in 1999.Then the round values of system time correspondence is 7200000.
Step 1002 multiply by time portion conversion coefficient 0.5 with the round values of system time correspondence, obtains time portion value to be converted.Promptly the round values of obtaining with step 1001 multiply by 0.5, and obtaining time portion value to be converted is 3600000.
Step 1003 is according to the convertible value of first character correspondence of the time portion that obtains in the step 1002 value calculating to be converted.Time portion value to be converted can be divided exactly with 78364164096 (36 7 powers), get 26 mould again, obtain, i.e. the convertible value 3600000 of first character correspondence.
Step 1004 is converted to character among the A-Z with the convertible value of first character correspondence calculating.Concrete transformation rule be 0 corresponding A, 1 corresponding B ... 25 corresponding Z, then transformation result is " A "
Step 1005 is calculated the convertible value of second character to a last character correspondence according to the time portion that obtains in the step 1002 value to be converted.Time portion value to be converted can be divided exactly 6 powers with 36,36 5 powers, 36 4 powers, 36 3 powers, 36 2 powers, 36 1 power, 36 0 power respectively, then with total respectively with 36 deliverys, obtain 7 integers successively, be respectively " 0 ", " 0 ", " 2 ", " 5 ", " 5 ", " 28 ", " 0 ".
Step 1006 is converted to any one character among described 0-9 and/or the A-Z with second character calculating to the convertible value of a last character correspondence.Concrete transformation rule is the corresponding character 0-9 of round values 0-9, and the corresponding character A-Z of round values 10-35 obtains second character and is followed successively by " 00255S0 " to a last character (eight bit character).
Step 1007 is spliced into 8 long character strings with second character that obtains in first character obtaining in the step 1004 and the step 1006 to eight bit character, and the result is " A00255S0 ".
Step 1008 generates random number.Can generate one 0 to 4738381338321616896 random integers between (36 12 powers), for example, the random number of generation is 910359253433179823.
Step 1009 multiply by random partial conversion coefficient 1 with the random number that generates, and obtaining random partial value to be converted is 910359253433179823.
Step 1010 is converted to the random partial character string with random partial value to be converted, and first character wherein is any one character among 0-9 and/or the A-Z to a last character.Promptly, earlier random partial value to be converted is divided exactly 11 powers with 36,36 10 powers, 36 9 powers, 36 8 powers, 36 7 powers, 36 6 powers, 36 5 powers, 36 4 powers, 36 3 powers, 36 2 powers, 36 1 power, 36 0 power respectively, then with total respectively with 36 deliverys, obtain the integer between 12 0 to 35, i.e. the convertible round values of 12 character correspondences of first character to the.Then, integer between obtain 12 0 to 35 is converted to the character of 0-9 and/or A-Z, concrete transformation rule is the corresponding character 0-9 of round values 0-9, the corresponding character A-Z of round values 10-35, and the character that obtains first to the 12 is followed successively by " 6WZRF7IYQD2N ".
Step 1011 is spliced into 12 long character strings with 12 characters of first character to that obtain in the step 1010, and the result is " 6WZRF7IYQD2N "
Step 1012, the random partial character string that time portion character string that step 1007 is obtained and step 1011 obtain is spliced into unique identifier, and the time portion character string is positioned at the beginning position of unique identifier.The unique identifier that splicing obtains is " A00255S06WZRF7IYQD2N ".
After obtaining unique identifier, unique identifier need be distributed to the major key of tables of data as tables of data.Wherein, step 1001-1007 does not have inevitable sequencing with step 1008-1011.Also can first execution in step 1008-1011, execution in step 1001-1007, execution in step 1012 at last again.Simultaneously executed in parallel step 1001-1007 and step 1008-1011, after step 1007 and step 1011 all are finished, last execution in step 1012.
Embodiment two, embodiment three and embodiment four adopt the identical identifier generting machanism to generate the unique identifier of 3 different systems under the time.When the system time among the embodiment two is on September 9th, 1,999 zero, the unique identifier that generates is " A0000000K6MU3EHXZK5E ", system time among the embodiment three is a period of time on September 9th, 1999, and the unique identifier of generation is " A0012KW0HLIX7SWLKQKS ".System time among the embodiment four is 2 o'clock on the 9th September in 1999, and the unique identifier of generation is " A00255S06WZRF7IYQD2N ".Conversion obtains because the beginning part (promptly starting eight characters) of these three unique identifiers is according to system time, so these three unique identifiers meet the natural order of data recording, has order.And back 12 characters that obtained by random number conversion have guaranteed the global uniqueness of identifier.
The method that the embodiment of the present application five provides a kind of unique identifier of database record to generate is timing zero point when setting in advance on September 9th, 1,999 zero, as shown in figure 11, may further comprise the steps:
Step 1101 is obtained the round values of system time correspondence, when current system time is on September 9th, 1,999 zero.Then the round values of system time correspondence is 0.
Step 1102 multiply by time portion conversion coefficient 0.5 with the round values of system time correspondence, obtains time portion value to be converted.Promptly the round values of obtaining with step 1101 multiply by 0.5, and obtaining time portion value to be converted is 0.
Step 1103 is converted to first character in the time portion character string to a last character with time portion value to be converted, and first character is any one character among 0-9 and/or the A-Z to a last character.Can earlier time portion value to be converted be divided exactly 7 powers with 36,36 6 powers, 36 5 powers, 36 4 powers, 36 3 powers, 36 2 powers, 36 1 power, 36 0 power respectively, then with total respectively with 36 deliverys, obtain the integer between 80 to 35.Then, the integer between obtain 80 to 35 is converted to the character of 0-9 and/or A-Z, concrete transformation rule is the corresponding character 0-9 of round values 0-9, the corresponding character A-Z of round values 10-35.Then first character of Huo Deing is followed successively by " 00000000 " to eight bit character.
Step 1104 is spliced into 8 long character strings with first character that obtains in the step 1103 to eight bit character, and the result is " 00000000 ".
Step 1105 generates random number.Can generate one 0 to 4738381338321616896 random integers between (36 12 powers), for example, the random number of generation is 1374370047210628002.
Step 1106 multiply by random partial conversion coefficient 1 with the random number that generates, and obtaining random partial value to be converted is 1374370047210628002.
Step 1107 is converted to first character in the random partial character string to a last character with random partial value to be converted, and first character is any one character among 0-9 and/or the A-Z to a last character.Promptly, earlier random partial value to be converted is divided exactly 11 powers with 36,36 10 powers, 36 9 powers, 36 8 powers, 36 7 powers, 36 6 powers, 36 5 powers, 36 4 powers, 36 3 powers, 36 2 powers, 36 1 power, 36 0 power respectively, then with total respectively with 36 deliverys, obtain the integer between 12 0 to 35, i.e. the convertible round values of 12 character correspondences of first character to the.Then, integer between obtain 12 0 to 35 is converted to the character of 0-9 and/or A-Z, concrete transformation rule is the corresponding character 0-9 of round values 0-9, the corresponding character A-Z of round values 10-35, and the character that obtains first to the 12 is followed successively by " AFWLIRFI5NDU ".
Step 1108 is spliced into 12 long character strings with 12 characters of first character to that obtain in the step 1107, and the result is " AFWLIRFI5NDU ".
Step 1109, the random partial character string that time portion character string that step 1104 is obtained and step 1108 obtain is spliced into unique identifier, and the time portion character string is positioned at the beginning position of unique identifier.The unique identifier that splicing obtains is " 00000000AFWLIRFI5NDU ".
After obtaining unique identifier, unique identifier need be distributed to the major key of tables of data as tables of data.Wherein, step 1101-1104 does not have inevitable sequencing with step 1105-1108.Also can first execution in step 1105-1108, execution in step 1101-1104, execution in step 1109 at last again.Simultaneously executed in parallel step 1101-1104 and step 1105-1108, after step 1104 and step 1108 all are finished, last execution in step 1109.
The method that the embodiment of the present application six provides a kind of unique identifier of database record to generate is timing zero point when setting in advance on September 9th, 1,999 zero, as shown in figure 12, may further comprise the steps:
Step 1201 is obtained the round values of system time correspondence, current system time be on September 9th, 1999 for the moment.Then the round values of system time correspondence is 3600000.
Step 1202 multiply by time portion conversion coefficient 0.5 with the round values of system time correspondence, obtains time portion value to be converted.Promptly the round values of obtaining with step 1201 multiply by 0.5, and obtaining time portion value to be converted is 1800000.
Step 1203 is converted to first character in the time portion character string to a last character with time portion value to be converted, and first character is any one character among 0-9 and/or the A-Z to a last character.Can earlier time portion value to be converted be divided exactly 7 powers with 36,36 6 powers, 36 5 powers, 36 4 powers, 36 3 powers, 36 2 powers, 36 1 power, 36 0 power respectively, then with total respectively with 36 deliverys, obtain the integer between 80 to 35.Then, the integer between obtain 80 to 35 is converted to the character of 0-9 and/or A-Z, concrete transformation rule is the corresponding character 0-9 of round values 0-9, the corresponding character A-Z of round values 10-35.Then first character of Huo Deing is followed successively by " 00012KW0 " to eight bit character.
Step 1204 is spliced into 8 long character strings with first character that obtains in the step 1203 to eight bit character, and the result is " 00012KW0 ".
Step 1205 generates random number.Can generate one 0 to 4738381338321616896 random integers between (36 12 powers), for example, the random number of generation is 2180336132633863188.
Step 1206 multiply by random partial conversion coefficient 1 with the random number that generates, and obtaining random partial value to be converted is 2180336132633863188.
Step 1207 is converted to first character in the random partial character string to a last character with random partial value to be converted, and first character is any one character among 0-9 and/or the A-Z to a last character.Promptly, earlier random partial value to be converted is divided exactly 11 powers with 36,36 10 powers, 36 9 powers, 36 8 powers, 36 7 powers, 36 6 powers, 36 5 powers, 36 4 powers, 36 3 powers, 36 2 powers, 36 1 power, 36 0 power respectively, then with total respectively with 36 deliverys, obtain the integer between 12 0 to 35, i.e. the convertible round values of 12 character correspondences of first character to the.Then, integer between obtain 12 0 to 35 is converted to the character of 0-9 and/or A-Z, concrete transformation rule is the corresponding character 0-9 of round values 0-9, the corresponding character A-Z of round values 10-35, and the character that obtains first to the 12 is followed successively by " GKCGNJMVHPUC ".
Step 1208 is spliced into 12 long character strings with 12 characters of first character to that obtain in the step 1207, and the result is " GKCGNJMVHPUC ".
Step 1209, the random partial character string that time portion character string that step 1204 is obtained and step 1208 obtain is spliced into unique identifier, and the time portion character string is positioned at the beginning position of unique identifier.The unique identifier that splicing obtains is " 00012KW0GKCGNJMVHPUC ".
After obtaining unique identifier, unique identifier need be distributed to the major key of tables of data as tables of data.Wherein, step 1201-1204 does not have inevitable sequencing with step 1205-1208.Also can first execution in step 1205-1208, execution in step 1201-1204, execution in step 1209 at last again.Simultaneously executed in parallel step 1201-1204 and step 1205-1208, after step 1204 and step 1208 all are finished, last execution in step 1209.
The method that the embodiment of the present application seven provides a kind of unique identifier of database record to generate is timing zero point when setting in advance on September 9th, 1,999 zero, as shown in figure 13, may further comprise the steps:
Step 1301 is obtained the round values of system time correspondence, and current system time is 2 o'clock on the 9th September in 1999.Then the round values of system time correspondence is 7200000.
Step 1302 multiply by time portion conversion coefficient 0.5 with the round values of system time correspondence, obtains time portion value to be converted.Promptly the round values of obtaining with step 1301 multiply by 0.5, and obtaining time portion value to be converted is 3600000.
Step 1303 is converted to first character in the time portion character string to a last character with time portion value to be converted, and first character is any one character among 0-9 and/or the A-Z to a last character.Can earlier time portion value to be converted be divided exactly 7 powers with 36,36 6 powers, 36 5 powers, 36 4 powers, 36 3 powers, 36 2 powers, 36 1 power, 36 0 power respectively, then with total respectively with 36 deliverys, obtain the integer between 80 to 35.Then, the integer between obtain 80 to 35 is converted to the character of 0-9 and/or A-Z, concrete transformation rule is the corresponding character 0-9 of round values 0-9, the corresponding character A-Z of round values 10-35.Then first character of Huo Deing is followed successively by " 000255S0 " to eight bit character.
Step 1304 is spliced into 8 long character strings with first character that obtains in the step 1303 to eight bit character, and the result is " 000255S0 ".
Step 1305 generates random number.Can generate one 0 to 4738381338321616896 random integers between (36 12 powers), for example, the random number of generation is 497228203135368276.
Step 1306 multiply by random partial conversion coefficient 1 with the random number that generates, and obtaining random partial value to be converted is 497228203135368276.
Step 1307 is converted to first character in the random partial character string to a last character with random partial value to be converted, and first character is any one character among 0-9 and/or the A-Z to a last character.Promptly, earlier random partial value to be converted is divided exactly 11 powers with 36,36 10 powers, 36 9 powers, 36 8 powers, 36 7 powers, 36 6 powers, 36 5 powers, 36 4 powers, 36 3 powers, 36 2 powers, 36 1 power, 36 0 power respectively, then with total respectively with 36 deliverys, obtain the integer between 12 0 to 35, i.e. the convertible round values of 12 character correspondences of first character to the.Then, integer between obtain 12 0 to 35 is converted to the character of 0-9 and/or A-Z, concrete transformation rule is the corresponding character 0-9 of round values 0-9, the corresponding character A-Z of round values 10-35, and the character that obtains first to the 12 is followed successively by " 3RZWOR3J1AVO ".
Step 1308 is spliced into 12 long character strings with 12 characters of first character to that obtain in the step 1307, and the result is " 3RZWOR3J1AVO ".
Step 1309, the random partial character string that time portion character string that step 1304 is obtained and step 1308 obtain is spliced into unique identifier, and the time portion character string is positioned at the beginning position of unique identifier.The unique identifier that splicing obtains is " 000255S03RZWOR3J1AVO ".
After obtaining unique identifier, unique identifier need be distributed to the major key of tables of data as tables of data.Wherein, step 1301-1304 does not have inevitable sequencing with step 1305-1308.Also can first execution in step 1305-1308, execution in step 1301-1304, execution in step 1309 at last again.Simultaneously executed in parallel step 1301-1304 and step 1305-1308, after step 1304 and step 1308 all are finished, last execution in step 1309.
Embodiment five, embodiment six and embodiment seven adopt the identical identifier generting machanism to generate the unique identifier of 3 different systems under the time.When the system time among the embodiment five is on September 9th, 1,999 zero, the unique identifier that generates is " 00000000AFWLIRFI5NDU ", system time among the embodiment six is a period of time on September 9th, 1999, and the unique identifier of generation is " 00012KW0GKCGNJMVHPUC ".System time among the embodiment seven is 2 o'clock on the 9th September in 1999, and the unique identifier of generation is " 000255S03RZWOR3J1AVO ".Conversion obtains because the beginning part (promptly starting eight characters) of these three unique identifiers is according to system time, so these three unique identifiers meet the natural order of data recording, has order.And back 12 characters that obtained by random number conversion have guaranteed the global uniqueness of identifier.
The embodiment of the present application eight provides a kind of device of realizing that unique identifier generates, as shown in figure 14, comprising:
System time acquisition module 4 is used to obtain system time;
Time portion character string generation module 1 is connected with system time acquisition module 4, is used for the system time rise time partial character string of obtaining according to system time acquisition module 4;
Random partial character string generation module 2 is used to generate the random partial character string;
Character string concatenation module 3, be connected respectively with random partial character string generation module 2 with time portion character string generation module 1, be used for the time portion character string of time portion character string generation module 1 generation and the random partial character string of random partial character string generation module 2 generations are spliced into unique identifier, described time portion character string is positioned at the beginning position of described unique identifier;
Identifier allocation module 5 is connected with character string concatenation module 3, is used for the unique identifier that character string concatenation module 3 obtains is distributed to the major key of tables of data as tables of data.
Wherein, the concrete structure of time portion character string generation module 1 can comprise as shown in figure 15: time portion value acquiring unit 11 to be converted and time portion character string acquiring unit 12, wherein,
Time portion value acquiring unit 11 to be converted is used for obtaining time portion value to be converted according to system time;
Time portion character string acquiring unit 12 is connected with time portion value acquiring unit 11 to be converted, is used for the time portion value to be converted that time portion value acquiring unit 11 to be converted obtains is converted to described time portion character string.
Wherein, the concrete structure of time portion character string acquiring unit 12 can comprise as shown in figure 16: first obtains subelement 121, second obtains the subelement 122 and the first processing subelement 123, wherein,
First obtains subelement 121, is used for described time portion value to be converted is converted to first character of described time portion character string, and described first character is any one character among the A-Z;
Second obtains subelement 122, second character that is used for described time portion value to be converted is converted to described time portion character string be to a last character, and described second character is any one character among 0-9 and/or the A-Z to every character in the last character;
First handles subelement 123, obtain subelement 121 and second and obtain subelement 122 and be connected respectively with first, be used for obtaining subelement 121 and second and obtain first character that subelement 122 obtains and be spliced into described time portion character string to a last character with first.
Wherein, first obtains subelement 121 specifically is used for, and calculates the convertible value of described first character correspondence according to described time portion value to be converted; The convertible value of described first character correspondence of calculating is converted to any one character among the described A-Z.
Wherein, second obtains subelement 122 specifically is used for, and calculates the convertible value of described second character to a last character correspondence according to described time portion value to be converted; Described second character of calculating is converted to any one character among described 0-9 and/or the A-Z to the convertible value of a last character correspondence.
Wherein, the concrete structure of time portion character string acquiring unit 12 can comprise as shown in figure 17: the 3rd obtains subelement 124 and second handles subelement 125, wherein,
The 3rd obtains subelement 124, and first character that is used for described time portion value to be converted is converted to described time portion character string be to a last character, and described first character is any one character among 0-9 and/or the A-Z to a last character;
Second handles subelement 125, obtains subelement 124 and is connected with the 3rd, is used for obtaining first character that subelement 124 obtains with the 3rd and is spliced into described time portion character string to a last character.
Wherein, the 3rd obtains subelement 124 specifically is used for, and calculates the convertible value of described first character to a last character correspondence according to described time portion value to be converted; Described first character of calculating is converted to any one character among described 0-9 and/or the A-Z to the convertible value of a last character correspondence.
Wherein, the concrete structure of random partial character string generation module 2 can comprise as shown in figure 18: random number generation unit 21, random partial value acquiring unit 22 to be converted and random partial character string acquiring unit 23, wherein,
Random number generation unit 21 is used to generate random number;
Random partial value acquiring unit 22 to be converted is connected with random number generation unit 21, is used for obtaining random partial value to be converted according to the random number that random number generation unit 21 generates;
Random partial character string acquiring unit 23 is connected with random partial value acquiring unit 22 to be converted, is used for the random partial value to be converted that random partial value acquiring unit 22 to be converted obtains is converted to described random partial character string.
Wherein, the concrete structure of random partial character string acquiring unit 23 can comprise as shown in figure 19: the 4th obtains subelement and the 3rd handles subelement, wherein,
The 4th obtains subelement 231, and first character that is used for described random partial value to be converted is converted to described random partial character string be to a last character, and described first character is any one character among 0-9 and/or the A-Z to a last character;
The 3rd handles subelement 232, obtains subelement 231 and is connected with the 4th, is used for obtaining first character that subelement 231 obtains with the 4th and is spliced into described random partial character string to a last character.
Wherein, the 4th obtains subelement 231 specifically is used for, and calculates the convertible value of described first character to a last character correspondence according to described random partial value to be converted; Described first character of calculating is converted to any one character among described 0-9 and/or the A-Z to the convertible value of a last character correspondence.
Among the application's the embodiment, be spliced into unique identifier by time portion character string and the random partial character string that will generate, and the time portion character string is placed the beginning position of unique identifier, solve the uniqueness of unique identifier and the problem that order can't realize simultaneously, when guaranteeing the identifier uniqueness, guaranteed the order of identifier.
For the convenience of describing, the each several part of the above device is divided into various modules with function or the unit is described respectively.Certainly, when implementing the application, can in same or a plurality of softwares or hardware, realize the function of each module or unit.
Through the above description of the embodiments, those skilled in the art can be well understood to the application and can realize by the mode that software adds essential general hardware platform, can certainly pass through hardware, but the former is better embodiment under a lot of situation.Based on such understanding, the part that the application's technical scheme contributes to prior art in essence in other words can embody with the form of software product, this computer software product is stored in the storage medium, comprise that some instructions are with so that a computer equipment (can be a personal computer, server, the perhaps network equipment etc.) carry out the described method of each embodiment of the application.
It will be appreciated by those skilled in the art that accompanying drawing is the synoptic diagram of a preferred embodiment, module in the accompanying drawing or flow process might not be that enforcement the application is necessary.
It will be appreciated by those skilled in the art that the module in the device among the embodiment can be distributed in the device of embodiment according to the embodiment description, also can carry out respective change and be arranged in the one or more devices that are different from present embodiment.The module of the foregoing description can be merged into a module, also can further split into a plurality of submodules.
Above-mentioned the embodiment of the present application sequence number is not represented the quality of embodiment just to description.
More than disclosed only be several specific embodiments of the application, still, the application is not limited thereto, any those skilled in the art can think variation all should fall into the application's protection domain.

Claims (20)

1, a kind of method of unique identifier of database record generation, this unique identifier is used as the major key of tables of data, it is characterized in that, may further comprise the steps:
Obtain system time;
According to described system time rise time partial character string;
Generate the random partial character string;
Described time portion character string and described random partial character string are spliced into unique identifier, and described time portion character string is positioned at the beginning position of described unique identifier;
Described unique identifier is distributed to the major key of tables of data as described tables of data.
2, the method for claim 1 is characterized in that, describedly comprises according to described system time rise time partial character string:
Obtain time portion value to be converted according to described system time;
Described time portion value to be converted is converted to described time portion character string.
3, method as claimed in claim 2 is characterized in that, describedly time portion value to be converted is converted to described time portion character string comprises:
Described time portion value to be converted is converted to first character in the described time portion character string, and described first character is any one character among the A-Z;
Described time portion value to be converted is converted to second character in the described time portion character string to a last character, and described second character is any one character among 0-9 and/or the A-Z to every character in the last character;
Described first character is spliced into described time portion character string to a last character.
4, method as claimed in claim 3 is characterized in that, describedly described time portion value to be converted is converted to first character comprises in the described time portion character string:
Calculate the convertible value of described first character correspondence according to described time portion value to be converted;
The convertible value of described first character correspondence of calculating is converted to any one character among the described A-Z.
5, method as claimed in claim 3 is characterized in that, described second character that described time portion value to be converted is converted in the described time portion character string comprises to a last character:
Calculate the convertible value of described second character according to described time portion value to be converted to a last character correspondence;
Described second character of calculating is converted to any one character among described 0-9 and/or the A-Z to the convertible value of a last character correspondence.
6, method as claimed in claim 2 is characterized in that, describedly time portion value to be converted is converted to described time portion character string comprises:
Described time portion value to be converted is converted to first character in the described time portion character string to a last character, and described first character is any one character among 0-9 and/or the A-Z to a last character;
Described first character is spliced into described time portion character string to a last character.
7, method as claimed in claim 6 is characterized in that, described first character that described time portion value to be converted is converted in the described time portion character string comprises to a last character:
Calculate the convertible value of described first character according to described time portion value to be converted to a last character correspondence;
Described first character of calculating is converted to any one character among described 0-9 and/or the A-Z to the convertible value of a last character correspondence.
8, the method for claim 1 is characterized in that, described generation random partial character string comprises:
Generate random number;
Obtain random partial value to be converted according to described random number;
Described random partial value to be converted is converted to described random partial character string.
9, method as claimed in claim 8 is characterized in that, describedly random partial value to be converted is converted to described random partial character string comprises:
Described random partial value to be converted is converted to first character in the described random partial character string to a last character, and described first character is any one character among 0-9 and/or the A-Z to a last character;
Described first character is spliced into described random partial character string to a last character.
10, method as claimed in claim 9 is characterized in that, described first character that described random partial value to be converted is converted in the described random partial character string comprises to a last character:
Calculate the convertible value of described first character according to described random partial value to be converted to a last character correspondence;
Described first character of calculating is converted to any one character among described 0-9 and/or the A-Z to the convertible value of a last character correspondence.
11, a kind of device of realizing that unique identifier generates is characterized in that, comprises system time acquisition module, time portion character string generation module, random partial character string generation module, character string concatenation module and identifier allocation module, wherein,
Described system time acquisition module is used to obtain system time;
Described time portion character string generation module is connected with described system time acquisition module, is used for the system time rise time partial character string of obtaining according to described system time acquisition module;
Described random partial character string generation module is used to generate the random partial character string;
Described character string concatenation module, be connected respectively with described random partial character string generation module with described time portion character string generation module, be used for the time portion character string of described time portion character string generation module generation and the random partial character string of described random partial character string generation module generation are spliced into unique identifier, described time portion character string is positioned at the beginning position of described unique identifier;
Described identifier allocation module is connected with described character string concatenation module, is used for the unique identifier that described character string concatenation module obtains is distributed to the major key of tables of data as described tables of data.
12, device as claimed in claim 11 is characterized in that, described time portion character string generation module comprises time portion value acquiring unit to be converted and time portion character string acquiring unit, wherein,
Described time portion value acquiring unit to be converted is used for according to described system time acquisition time part value to be converted;
Described time portion character string acquiring unit is connected with described time portion value acquiring unit to be converted, is used for the time portion value to be converted that described time portion value acquiring unit to be converted obtains is converted to described time portion character string.
13, device as claimed in claim 12 is characterized in that, described time portion character string acquiring unit comprises that first obtains subelement, second and obtain subelement and first and handle subelement, wherein,
Described first obtains subelement, is used for described time portion value to be converted is converted to first character of described time portion character string, and described first character is any one character among the A-Z;
Described second obtains subelement, second character that is used for described time portion value to be converted is converted to described time portion character string be to a last character, and described second character is any one character among 0-9 and/or the A-Z to every character in the last character;
Described first handles subelement, obtain subelement and described second and obtain subelement and be connected respectively with described first, be used for obtaining subelement and described second and obtain first character that subelement obtains and be spliced into described time portion character string to a last character with described first.
14, device as claimed in claim 13 is characterized in that, described first obtains subelement specifically is used for, and calculates the convertible value of described first character correspondence according to described time portion value to be converted; The convertible value of described first character correspondence of calculating is converted to any one character among the described A-Z.
15, device as claimed in claim 13 is characterized in that, described second obtains subelement specifically is used for, and calculates the convertible value of described second character to a last character correspondence according to described time portion value to be converted; Described second character of calculating is converted to any one character among described 0-9 and/or the A-Z to the convertible value of a last character correspondence.
16, device as claimed in claim 12 is characterized in that, described time portion character string acquiring unit comprises that the 3rd obtains the subelement and the second processing subelement, wherein,
The described the 3rd obtains subelement, and first character that is used for described time portion value to be converted is converted to described time portion character string be to a last character, and described first character is any one character among 0-9 and/or the A-Z to a last character;
Described second handles subelement, obtains subelement and is connected with the described the 3rd, is used for obtaining first character that subelement obtains with the described the 3rd and is spliced into described time portion character string to a last character.
17, device as claimed in claim 16 is characterized in that, the described the 3rd obtains subelement specifically is used for, and calculates the convertible value of described first character to a last character correspondence according to described time portion value to be converted; Described first character of calculating is converted to any one character among described 0-9 and/or the A-Z to the convertible value of a last character correspondence.
18, device as claimed in claim 11 is characterized in that, described random partial character string generation module comprises random number generation unit, random partial value acquiring unit to be converted and random partial character string acquiring unit, wherein,
Described random number generation unit is used to generate random number;
Described random partial value acquiring unit to be converted is connected with described random number generation unit, is used for obtaining random partial value to be converted according to the random number that described random number generation unit generates;
Described random partial character string acquiring unit is connected with described random partial value acquiring unit to be converted, is used for the random partial value to be converted that described random partial value acquiring unit to be converted obtains is converted to described random partial character string.
19, device as claimed in claim 18 is characterized in that, described random partial character string acquiring unit comprises that the 4th obtains subelement and the 3rd processing subelement, wherein,
The described the 4th obtains subelement, and first character that is used for described random partial value to be converted is converted to described random partial character string be to a last character, and described first character is any one character among 0-9 and/or the A-Z to a last character;
The described the 3rd handles subelement, obtains subelement and is connected with the described the 4th, is used for obtaining first character that subelement obtains with the described the 4th and is spliced into described random partial character string to a last character.。
20, device as claimed in claim 19 is characterized in that, the described the 4th obtains subelement specifically is used for, and calculates the convertible value of described first character to a last character correspondence according to described random partial value to be converted; Described first character of calculating is converted to any one character among described 0-9 and/or the A-Z to the convertible value of a last character correspondence.
CN200910130809A 2009-04-15 2009-04-15 A method and a device for generating unique identifier of database record Pending CN101533414A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN200910130809A CN101533414A (en) 2009-04-15 2009-04-15 A method and a device for generating unique identifier of database record

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN200910130809A CN101533414A (en) 2009-04-15 2009-04-15 A method and a device for generating unique identifier of database record

Publications (1)

Publication Number Publication Date
CN101533414A true CN101533414A (en) 2009-09-16

Family

ID=41104018

Family Applications (1)

Application Number Title Priority Date Filing Date
CN200910130809A Pending CN101533414A (en) 2009-04-15 2009-04-15 A method and a device for generating unique identifier of database record

Country Status (1)

Country Link
CN (1) CN101533414A (en)

Cited By (19)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101976241A (en) * 2010-09-26 2011-02-16 用友软件股份有限公司 Method and system for generating identification code
CN102156717A (en) * 2011-03-25 2011-08-17 中国有色矿业集团有限公司 Method and device for mapping entity object into database
CN102880705A (en) * 2012-09-28 2013-01-16 用友软件股份有限公司 Database primary key generating device and database primary key generating method
CN103020268A (en) * 2012-12-26 2013-04-03 大唐软件技术股份有限公司 Serial number applying method and system of relational database
CN103257977A (en) * 2012-02-21 2013-08-21 阿里巴巴集团控股有限公司 Method and device for obtaining identification numbers
CN103365884A (en) * 2012-03-30 2013-10-23 上海申通地铁集团有限公司 Data storage method and data search method
CN103810557A (en) * 2012-11-15 2014-05-21 航天信息股份有限公司 Invoice verification code generation method and device
CN103823810A (en) * 2012-11-19 2014-05-28 中国电信股份有限公司 Method, device and system for generating unique keys in distributed system
CN104866601A (en) * 2015-06-01 2015-08-26 走遍世界(北京)信息技术有限公司 Serial number generating method and device
WO2016004813A1 (en) * 2014-07-07 2016-01-14 阿里巴巴集团控股有限公司 Data storage method, query method and device
CN106776932A (en) * 2016-12-01 2017-05-31 湖北荆楚网络科技股份有限公司 A kind of method that unique ID is generated in distributed system
CN107767132A (en) * 2016-08-23 2018-03-06 百度在线网络技术(北京)有限公司 Method and apparatus for generating prepaid card password
CN108572964A (en) * 2017-03-09 2018-09-25 武汉斗鱼网络科技有限公司 A kind of method and device generating filename
CN108647193A (en) * 2018-04-20 2018-10-12 河南中烟工业有限责任公司 A kind of unique identifier generation method can be applied to distributed system and device
CN108984639A (en) * 2018-06-22 2018-12-11 联想(北京)有限公司 The data processing method and device of server cluster
CN109977274A (en) * 2019-03-31 2019-07-05 杭州复杂美科技有限公司 A kind of data query and verification method, system, equipment and storage medium
CN110019336A (en) * 2017-10-30 2019-07-16 北京京东尚科信息技术有限公司 A kind of method and apparatus for inquiring data
CN111708538A (en) * 2020-05-29 2020-09-25 平安医疗健康管理股份有限公司 Transaction circulation method, device, computer equipment and computer readable storage medium
CN113792036A (en) * 2021-01-15 2021-12-14 北京沃东天骏信息技术有限公司 Service data processing method, device, medium and electronic equipment

Cited By (29)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101976241B (en) * 2010-09-26 2013-01-09 用友软件股份有限公司 Method and system for generating identification code
CN101976241A (en) * 2010-09-26 2011-02-16 用友软件股份有限公司 Method and system for generating identification code
CN102156717A (en) * 2011-03-25 2011-08-17 中国有色矿业集团有限公司 Method and device for mapping entity object into database
CN102156717B (en) * 2011-03-25 2013-07-03 中国有色矿业集团有限公司 Method and device for mapping entity object into database
CN103257977A (en) * 2012-02-21 2013-08-21 阿里巴巴集团控股有限公司 Method and device for obtaining identification numbers
CN103365884A (en) * 2012-03-30 2013-10-23 上海申通地铁集团有限公司 Data storage method and data search method
CN102880705A (en) * 2012-09-28 2013-01-16 用友软件股份有限公司 Database primary key generating device and database primary key generating method
CN102880705B (en) * 2012-09-28 2015-09-02 用友软件股份有限公司 Database key generating apparatus and database key generation method
CN103810557A (en) * 2012-11-15 2014-05-21 航天信息股份有限公司 Invoice verification code generation method and device
CN103823810A (en) * 2012-11-19 2014-05-28 中国电信股份有限公司 Method, device and system for generating unique keys in distributed system
CN103020268A (en) * 2012-12-26 2013-04-03 大唐软件技术股份有限公司 Serial number applying method and system of relational database
WO2016004813A1 (en) * 2014-07-07 2016-01-14 阿里巴巴集团控股有限公司 Data storage method, query method and device
US10489372B2 (en) 2014-07-07 2019-11-26 Alibaba Group Holding Limited Data storage methods, query methods, and apparatuses thereof
CN104866601A (en) * 2015-06-01 2015-08-26 走遍世界(北京)信息技术有限公司 Serial number generating method and device
CN107767132A (en) * 2016-08-23 2018-03-06 百度在线网络技术(北京)有限公司 Method and apparatus for generating prepaid card password
CN107767132B (en) * 2016-08-23 2022-01-14 百度在线网络技术(北京)有限公司 Method and device for generating rechargeable card password
CN106776932A (en) * 2016-12-01 2017-05-31 湖北荆楚网络科技股份有限公司 A kind of method that unique ID is generated in distributed system
CN108572964B (en) * 2017-03-09 2022-01-04 武汉斗鱼网络科技有限公司 Method and device for generating file name
CN108572964A (en) * 2017-03-09 2018-09-25 武汉斗鱼网络科技有限公司 A kind of method and device generating filename
CN110019336A (en) * 2017-10-30 2019-07-16 北京京东尚科信息技术有限公司 A kind of method and apparatus for inquiring data
CN110019336B (en) * 2017-10-30 2021-04-30 北京京东尚科信息技术有限公司 Method and device for querying data
CN108647193A (en) * 2018-04-20 2018-10-12 河南中烟工业有限责任公司 A kind of unique identifier generation method can be applied to distributed system and device
CN108647193B (en) * 2018-04-20 2021-11-19 河南中烟工业有限责任公司 Unique identifier generation method and device applicable to distributed system
CN108984639A (en) * 2018-06-22 2018-12-11 联想(北京)有限公司 The data processing method and device of server cluster
CN108984639B (en) * 2018-06-22 2021-12-24 联想(北京)有限公司 Data processing method and device for server cluster
CN109977274A (en) * 2019-03-31 2019-07-05 杭州复杂美科技有限公司 A kind of data query and verification method, system, equipment and storage medium
CN111708538A (en) * 2020-05-29 2020-09-25 平安医疗健康管理股份有限公司 Transaction circulation method, device, computer equipment and computer readable storage medium
CN111708538B (en) * 2020-05-29 2022-03-22 平安医疗健康管理股份有限公司 Transaction circulation method, device, computer equipment and computer readable storage medium
CN113792036A (en) * 2021-01-15 2021-12-14 北京沃东天骏信息技术有限公司 Service data processing method, device, medium and electronic equipment

Similar Documents

Publication Publication Date Title
CN101533414A (en) A method and a device for generating unique identifier of database record
US10628449B2 (en) Method and apparatus for processing database data in distributed database system
CN106682077B (en) Mass time sequence data storage implementation method based on Hadoop technology
CN110704398B (en) Database migration method and device from MySQL to Oracle and computer equipment
US11074246B2 (en) Cluster-based random walk processing
CN101504672A (en) Method and system for dynamically configuring physical data table
CN106886535A (en) A kind of data pick-up method and apparatus for being adapted to multiple data sources
CN110287251B (en) MongoDB-HBase distributed high fault-tolerant data real-time synchronization method
CN110245134B (en) Increment synchronization method applied to search service
CN105447166A (en) Keyword based information search method and system
CN103914483A (en) File storage method and device and file reading method and device
CN112988702A (en) Heterogeneous data source real-time data transmission method and system, storage medium and terminal
CN110019111A (en) Data processing method, device, storage medium and processor
CN110263104A (en) JSON character string processing method and device
CN106547870A (en) Point table method and device of data base
CN108446115A (en) A kind of method and device of code reuse
CN113177090A (en) Data processing method and device
CN115599769A (en) Data migration method and device, electronic equipment and storage medium
CN104408183B (en) The data lead-in method and device of data system
CN115470284A (en) Method and device for importing multi-source heterogeneous data source into Janusgraph database
US8407255B1 (en) Method and apparatus for exploiting master-detail data relationships to enhance searching operations
CN102279886B (en) Method and equipment for processing metadata
CN105408893B (en) A kind of data processing and wiring method and relevant apparatus
CN102184286B (en) Method for generating instrument circuit diagram automatically
CN112463785B (en) Data quality monitoring method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 1136061

Country of ref document: HK

C12 Rejection of a patent application after its publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20090916