CN109241064A - A kind of database insertion sort method - Google Patents

A kind of database insertion sort method Download PDF

Info

Publication number
CN109241064A
CN109241064A CN201811228134.3A CN201811228134A CN109241064A CN 109241064 A CN109241064 A CN 109241064A CN 201811228134 A CN201811228134 A CN 201811228134A CN 109241064 A CN109241064 A CN 109241064A
Authority
CN
China
Prior art keywords
data
sequence
serial number
referring
sort
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
CN201811228134.3A
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.)
Wuhan Dameng Database Co Ltd
Original Assignee
Wuhan Dameng Database Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Wuhan Dameng Database Co Ltd filed Critical Wuhan Dameng Database Co Ltd
Priority to CN201811228134.3A priority Critical patent/CN109241064A/en
Publication of CN109241064A publication Critical patent/CN109241064A/en
Pending legal-status Critical Current

Links

Landscapes

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

Abstract

The present invention discloses a kind of database insertion sort method, comprising the following steps: step S1, updates continuous serial number of the row's serial number of sort field since 1 according to sequence size;Step S2, all sequences number are expanded N times, N is the integer more than or equal to 2;Step S3, basis is inserted into data and is inserted into data referring to unique key assignments acquisition of data and referring to the sequence number of data, will be inserted into data Forward if necessary, then is revised as the sequence number for being inserted into data to subtract M referring to the sequence number of data;It will be inserted into data if necessary to move back, then the sequence number for being inserted into data is revised as the sequence number referring to data plus M;M is the integer greater than 0 and less than N;Step S4, continuous serial number of the row's serial number of sort field since 1 is updated according to sequence size again.The present invention is it is only necessary to know that being inserted into data and data insertion sort can be completed referring to the unique key assignments and moving direction of data.

Description

A kind of database insertion sort method
Technical field
The present invention relates to database sort technical fields, and in particular to a kind of database insertion sort method.
Background technique
In the database, design has sort field in some tables of data, the relative position for mark data.These data In operation system, it is desirable to provide the operation of data insertion sort, for changing the relative position of data.Such as when needs will When mobile data is inserted into behind certain reference data, needing to sort number is greater than or equal to the data of reference data sequence number one by one One is moved back, then data are inserted into the position of reference data.In this process, operating procedure data moved back one by one compared with More, step number is equal with the data volume to be moved.In whole process, the operation for modifying data is more, and frequent data are repaired Change operation, have a great impact to the performance of database, and time-consuming, performance is low for operation.
Summary of the invention
It is an object of the invention to overcome above-mentioned technical deficiency, a kind of database insertion sort method is provided, is solved existing The cumbersome technical problem of insertion sort in technology.
To reach above-mentioned technical purpose, technical solution of the present invention provides a kind of database insertion sort method, including with Lower step:
Step S1, continuous serial number of the row's serial number of sort field since 1 is updated according to sequence size;
Step S2, all sequences number are expanded N times, N is the integer more than or equal to 2;
Step S3, basis is inserted into data and is inserted into data and referring to the row of data referring to unique key assignments acquisition of data The sequence number for being inserted into data is then revised as described referring to number by serial number if necessary to be inserted into data Forward for described According to sequence number subtract M;If necessary to move back the data that are inserted into, then the sequence number for being inserted into data is revised as institute State the sequence number referring to data plus M;M is the integer greater than 0 and less than N;
Step S4, continuous serial number of the row's serial number of the sort field since 1 is updated according to sequence size again.
Compared with prior art, the beneficial effect comprise that the present invention is by expanding sequence number, to be inserted into behaviour Make, it is only necessary to know be inserted into data and referring to data unique key value and moving direction insertion sort can be completed.This The operation moved back one by one when data insertion in the prior art is omitted in invention, reduces operating procedure, it is only necessary to the step of several fixations Suddenly insertion sort operation can be completed, it is not related with the data volume to be moved.Reduce operating procedure, improves insertion sort Performance.
Detailed description of the invention
Fig. 1 is the flow chart of database insertion sort method provided by the invention.
Specific embodiment
In order to make the objectives, technical solutions, and advantages of the present invention clearer, with reference to the accompanying drawings and embodiments, right The present invention is further elaborated.It should be appreciated that the specific embodiments described herein are merely illustrative of the present invention, and It is not used in the restriction present invention.
Embodiment 1:
As shown in Figure 1, the embodiment of the present invention 1 provides a kind of database insertion sort method, comprising the following steps:
Step S1, continuous serial number of the row's serial number of sort field since 1 is updated according to sequence size;
Step S2, all sequences number are expanded N times, N is the integer more than or equal to 2;
Step S3, basis is inserted into data and is inserted into data and referring to the row of data referring to unique key assignments acquisition of data The sequence number for being inserted into data is then revised as described referring to number by serial number if necessary to be inserted into data Forward for described According to sequence number subtract M;If necessary to move back the data that are inserted into, then the sequence number for being inserted into data is revised as institute State the sequence number referring to data plus M;M is the integer greater than 0 and less than N;
Step S4, continuous serial number of the row's serial number of the sort field since 1 is updated according to sequence size again.
In the prior art, the method for the sort field insertion sort of database is usually, will be referring to data and its below Data all move back one, to vacate vacancy, then will be inserted into data insertion vacancy, final updating sequence number.This method The operation that moves back of more data is needed to be implemented, complex for operation step, data insertion speed is slow.It is dynamic in the insertion of frequent data sorting Demand is especially unable to satisfy when making.
Therefore, the present invention improves existing database insertion sort method.Database insertion provided by the invention Sort method, basic principle are as follows: first carrying out initialization sequence to sort field;Then expand the multiple of sequence number, so that Vacancy is vacated between the sequence number of two adjacent data, so as to the insertion of follow-up data;The sequence number for being inserted into data is repaired It is changed to referring to data sorting number plus M or subtracts M, so that being inserted on or below data insertion reference data, finally according to sequence Number size re-start the sequence of continuous serial number, realize insertion sort operation.Sequence number can change in operation, Unique identification reference data are unable to, unique key assignments, such as Major key are needed, to correspond to mark reference data, to be correctly inserted into It is inserted into data.Such as the age of modification someone, can only be modified according to identification card number, identification card number, that is, unique key at this time Value, and cannot be modified according to the age, because of people's more than one of the same age, do not have uniqueness.
Specifically, being described in detail by taking specific sort field as an example below.Initialization updates the sequence of sort field Number it is continuous serial number, initial sort field is as shown in the table:
Sequence number 1 2 3 4 5 6 7 8 9 10
Data One Two Three Four Five Six Seven Eight Nine Ten
Insertion sort target are as follows: be inserted into the data for arranging serial number 7 on the data of row's serial number 3.
All sequences number are first expanded 10 times, sort field is as shown in the table:
Sequence number 10 20 30 40 50 60 70 80 90 100
Data One Two Three Four Five Six Seven Eight Nine Ten
Sequence number 70 is revised as 30-1, i.e., 29, sort field is as shown in the table:
Sequence number 10 20 30 40 50 60 29 80 90 100
Data One Two Three Four Five Six Seven Eight Nine Ten
Finally update the continuous serial number of row's serial number of sort field again according to the size of sequence number, sort field is as follows:
Sequence number 1 2 3 4 5 6 7 8 9 10
Data One Two Seven Three Four Five Six Eight Nine Ten
Complete the insertion sort target data for arranging serial number 7 being inserted on the data of row's serial number 3.
The present invention substantially increases the speed of insertion sort method by the simple adjustment to insertion sort method, reduces The complexity of insertion sort.It is only necessary to know that insertion sort can be completed in the sequence number and moving direction referring to data, no It needs to call other business interfaces, it is not easy to make mistakes.
Preferably, the N is 10.
Sequence number is extended for original 10 times, so that vacancy is had more between the sequence number of adjacent data, convenient for being inserted into The insertion operation of data.
Preferably, the M takes 1.
Sequence number referring to data is added 1 certainly or subtracts 1 certainly and is assigned to the sequence number for being inserted into data, plus or minus one operation again It is very simple, it can further shorten the time of sequence insertion, improve sequence insertion speed.
Preferably, the step S1 specifically: row's serial number of sort field is updated since 1 according to sequence size Continuous serial number.
Continuous serial number since 1 is easy to understand, recognizes and operation.
Preferably, the step S4 specifically: update continuous sequence of the row's serial number of the sort field since 1 again Number.
Embodiment 2:
The embodiment of the present invention 2 provides a kind of computer storage medium, is stored thereon with computer program, the calculating When machine storage medium is executed by processor, database insertion sort method described in any of the above embodiment is realized.
Computer storage medium provided by the invention, for realizing above-mentioned database insertion sort method, therefore above-mentioned number According to the technical effect that library insertion sort method has, computer storage medium is likewise supplied with, and details are not described herein.
The above described specific embodiments of the present invention are not intended to limit the scope of the present invention..Any basis Any other various changes and modifications that technical concept of the invention is made should be included in the guarantor of the claims in the present invention It protects in range.

Claims (5)

1. a kind of database insertion sort method, which comprises the following steps:
Step S1, continuous serial number of the row's serial number of sort field since 1 is updated according to sequence size;
Step S2, all sequences number are expanded N times, N is the integer more than or equal to 2;
Step S3, basis is inserted into data and is inserted into data and referring to the sequence of data referring to unique key assignments acquisition of data Number, if necessary to be inserted into data Forward for described, then the sequence number for being inserted into data is revised as described referring to data Sequence number subtract M;If necessary to move back the data that are inserted into, then the sequence number for being inserted into data is revised as described Sequence number plus M referring to data;M is the integer greater than 0 and less than N;
Step S4, continuous serial number of the row's serial number of the sort field since 1 is updated according to sequence size again.
2. database insertion sort method according to claim 1, which is characterized in that the N takes 10.
3. database insertion sort method according to claim 1, which is characterized in that the M takes 1.
4. database insertion sort method according to claim 1, which is characterized in that the step S1 specifically: according to Sequence size updates continuous serial number of the row's serial number of sort field since 1.
5. a kind of computer storage medium, is stored thereon with computer program, which is characterized in that the computer storage medium quilt When processor executes, the database insertion sort method as described in claim 1-4 is any is realized.
CN201811228134.3A 2018-10-22 2018-10-22 A kind of database insertion sort method Pending CN109241064A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811228134.3A CN109241064A (en) 2018-10-22 2018-10-22 A kind of database insertion sort method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811228134.3A CN109241064A (en) 2018-10-22 2018-10-22 A kind of database insertion sort method

Publications (1)

Publication Number Publication Date
CN109241064A true CN109241064A (en) 2019-01-18

Family

ID=65080916

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811228134.3A Pending CN109241064A (en) 2018-10-22 2018-10-22 A kind of database insertion sort method

Country Status (1)

Country Link
CN (1) CN109241064A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112181995A (en) * 2020-11-06 2021-01-05 深圳视界信息技术有限公司 Data processing method, device and equipment of data table and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101175175A (en) * 2007-09-13 2008-05-07 深圳市融创天下科技发展有限公司 Dynamic customizing method for media player menu
US20160154835A1 (en) * 2014-12-02 2016-06-02 International Business Machines Corporation Compression-aware partial sort of streaming columnar data
CN108628892A (en) * 2017-03-21 2018-10-09 北京京东尚科信息技术有限公司 Method, apparatus, electronic equipment and the readable storage medium storing program for executing of ordered data storage

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101175175A (en) * 2007-09-13 2008-05-07 深圳市融创天下科技发展有限公司 Dynamic customizing method for media player menu
US20160154835A1 (en) * 2014-12-02 2016-06-02 International Business Machines Corporation Compression-aware partial sort of streaming columnar data
CN108628892A (en) * 2017-03-21 2018-10-09 北京京东尚科信息技术有限公司 Method, apparatus, electronic equipment and the readable storage medium storing program for executing of ordered data storage

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
代秀珍 等: "《Access2010项目教程》", 31 March 2016 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112181995A (en) * 2020-11-06 2021-01-05 深圳视界信息技术有限公司 Data processing method, device and equipment of data table and storage medium
CN112181995B (en) * 2020-11-06 2023-08-29 深圳数阔信息技术有限公司 Data processing method, device, equipment and storage medium of data table

Similar Documents

Publication Publication Date Title
CN106202548B (en) Date storage method, lookup method and device
CN101499069B (en) Internal memory database file updating method and apparatus
CN102929878B (en) A kind of databases comparison management method and device
CN111241093B (en) Dynamic storage expansion method based on database
CN103995879A (en) Data query method, device and system based on OLAP system
CN104063361A (en) Report design method and system
CN111143368A (en) Relational database data comparison method and system
CN111435347A (en) Efficient expansion method and system for relational table in database
CN105912678A (en) Data storage method, data reading method and corresponding system
CN104298769A (en) System and method for synchronizing discrepant data of common domain between databases
CN107229674A (en) A kind of data migration device, server and method
CN109241064A (en) A kind of database insertion sort method
CN104951565B (en) XM (extensible messaging client) L (extensible markup language) configuration maintenance method and system based on memory database
US11150993B2 (en) Method, apparatus and computer program product for improving inline pattern detection
CN104794130A (en) Inter-table correlation query method and device
CN108427736A (en) A method of for inquiring data
US7984072B2 (en) Three-dimensional data structure for storing data of multiple domains and the management thereof
CN112817984B (en) Data processing method and device, and data source acquisition method and device
CN103222220A (en) Network data method and equipment
CN103838703B (en) Method and apparatus for realizing signal transacting based on big points Fourier transformation
CN105760382A (en) Method and device for importing excel data into database
CN109408512A (en) A kind of database sort position moving method
CN114416884B (en) Method and device for connecting partition table
CN102193986B (en) Method of implementing online transaction in graphic database
CN102722543B (en) Method for storing files

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20190118