CN102270231A - Database index establishing method and device - Google Patents

Database index establishing method and device Download PDF

Info

Publication number
CN102270231A
CN102270231A CN 201110205033 CN201110205033A CN102270231A CN 102270231 A CN102270231 A CN 102270231A CN 201110205033 CN201110205033 CN 201110205033 CN 201110205033 A CN201110205033 A CN 201110205033A CN 102270231 A CN102270231 A CN 102270231A
Authority
CN
China
Prior art keywords
index
database
information
tables
acquisition module
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
CN 201110205033
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.)
Suzhou Codyy Network Technology Co Ltd
Original Assignee
Suzhou Codyy Network Technology 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 Suzhou Codyy Network Technology Co Ltd filed Critical Suzhou Codyy Network Technology Co Ltd
Priority to CN 201110205033 priority Critical patent/CN102270231A/en
Publication of CN102270231A publication Critical patent/CN102270231A/en
Pending legal-status Critical Current

Links

Images

Abstract

The invention provides a database index establishing method and device. The method comprises the following steps of: acquiring all database information; acquiring all data table information in each database; and obtaining index information according to the acquired data table information, and establishing an index file according to the index information, wherein the index information refers to an index statement carrying an index type, an index name and an index limiting condition.

Description

A kind of database index method for building up and device
Technical field
The present invention relates to database technology, relate in particular to a kind of database index method for building up and device.
Background technology
At present, can the derived data library structure and the file of the structure of database table by corresponding instrument, comprise in these structures and how to create the storehouse, how to create table.By the importing of this structured file, can create storehouse and table like a cork, simplification work.Yet shortage can derive the file of index structure at present.
Summary of the invention
The invention provides a kind of database index method for building up and device, to address the above problem.
The invention provides a kind of database index method for building up, may further comprise the steps.Obtain all database informations.Obtain all the tables of data information in each database.Obtain index information according to the tables of data information of obtaining, and set up index file according to index information.Wherein, index information refers to carry the index statement of index type, index name and index restrictive condition.
The present invention also provides a kind of database index apparatus for establishing, comprises that database information acquisition module, tables of data information acquisition module, index information acquisition module and index file set up module.Wherein, the database information acquisition module is used to obtain all database informations.Tables of data information acquisition module connects the database information acquisition module, is used for obtaining all tables of data information of each database.The index information acquisition module connects tables of data information acquisition module, is used for obtaining index information according to the tables of data information of obtaining.Index file is set up module, connects the index information acquisition module, is used for setting up index file according to index information.Wherein, index information refers to carry the index statement of index type, index name and index restrictive condition.
Compared to prior art, according to database index method for building up provided by the invention and device, need not to login database, only can obtain index information, and then learn whether index lacks or whether good from index file.In addition, in the leader follower replication Database Systems, need not to login other and create index from the storehouse one by one, can directly import index file and carry out index, thereby save the time.In addition, the change of index information only needs to carry out in the indexed file, and is easy to operate.
Description of drawings
Accompanying drawing described herein is used to provide further understanding of the present invention, constitutes the application's a part, and illustrative examples of the present invention and explanation thereof are used to explain the present invention, do not constitute improper qualification of the present invention.In the accompanying drawings:
Figure 1 shows that the process flow diagram of the database index method for building up that preferred embodiment according to the present invention provides;
Figure 2 shows that the synoptic diagram of the database index apparatus for establishing that preferred embodiment according to the present invention provides.
Embodiment
Hereinafter will describe the present invention with reference to the accompanying drawings and in conjunction with the embodiments in detail.Need to prove that under the situation of not conflicting, embodiment and the feature among the embodiment among the application can make up mutually.
Figure 1 shows that the process flow diagram of the database index method for building up that preferred embodiment according to the present invention provides.As shown in Figure 1, the database index method for building up that provides of preferred embodiment of the present invention comprises step 101~103.
In step 101, obtain all database informations.Particularly, obtain all database informations by order show databases.Simultaneously, these database informations are recorded in the array, for follow-up use.
In step 102, obtain all the tables of data information in each database.Particularly, by ordering each database of show tables poll to obtain all tables of data information.Simultaneously, these tables of data information are recorded in the another one array, for follow-up use.
In step 103, obtain index information according to the tables of data information of obtaining, and set up index file according to index information.Wherein, index information refers to carry the index statement of index type, index name and index restrictive condition.
Following is that example is elaborated with database people.
Comprise tables of data teacher and tables of data student among the database people.Wherein, tables of data teacher information is as follows.
Teacher ID Int Primary
Teacher's name Char Not?null
Teacher's age Datetime Not?null
The teacher address Char(20) Not?Null
In addition, can obtain following index information by order show create table teacher.
|teacher|CREATE?TABLE`teacher`(
`id`int(11)NOT?NULL?AUTO_INCREMENT,
`teacher_name`varchar(64)NOT?NULL,
`teacher_birth`datetime?NOT?NULL,
`teacher_addr`varchar(16)NOT?NULL,
PRIMARY?KEY(`id`),
KEY`inx_teacher_name`(`teacher_name`(10))
)ENGINE=MyISAM?DEFAULT?CHARSET=gbk|
In addition, can obtain following index information by order show index from teacher.
|Table |Non_unique|Key_name|Seq_in_index|Column_name?|Collation|Cardinality|Sub_part|Packed|Null|Index_type|Comment|
|teacher| 0|PRIMARY | 1|id A | 0| NULL|NULL | |BTREE | |
|teacher|1|ins_stu_name| 1|teacher_name|A | NULL| 10|NULL | |BTREE | |
In addition, tables of data student information is as follows.
Student ID Int Primary
Student name Char Not?null
Student's hobby Varchar Null
The student residence Char Not?null
Date of birth Datetime Not?null
Wherein, can obtain following index information by order show createtable student.
|student|CREATE?TABLE`student`(
`birthtime`datetime?NOT?NULL,
`id`int(11)NOT?NULL?AUTO_INCREMENT,
`stu_name`varchar(64)DEFAULT?NULL,
`stu_addr`varchar(256)DEFAULT?NULL,
`stu_hobby`varchar(16)DEFAULT?NULL,
PRIMARY?KEY(`id`),
KEY`inx_stu_name`(`stu_name`(10)),
FULLTEXT?KEY`inx_stu_addr`(`stu_addr`)
)ENGINE=MyISAM?DEFAULT?CHARSET=gbk|
In addition, can obtain following index information by order show index from student.
|Table |Non_unique|Key_name |Seq_in_index|Column_name|Collation|Cardinality|Sub_part|Packed|Null|Index_type|Comment
|student| 0|PRIMARY | 1|id |A | 0| NULL|NULL | |BTREE
|student| 1|inx_stu_name| 1|stu_name |A | NULL| 10|NULL |YES |BTREE |student
| 1|inx_stu_addr| 1|stu_addr |NULL | NULL| NULL|NULL |YES |FULLTEXT | |
Can analyze type, name and the index restrictive condition of index according to above-mentioned index information, setting up index file people.inx, and the concrete manifestation mode is:
create?fulltext?index?inx_stu_addr?on?student(stu_addr);
create?index?inx_stu_name?on?student(stu_name(10));
create?index?inx_teacher_name?on?teacher(teacher_name(10))。
Can draw which index by the index file of setting up needs to set up, and whether the index of foundation is reasonable.In addition, in the leader follower replication database, master data base only is responsible for insertion, and is responsible for inquiry from database.Therefore, master data base is not generally set up index, and must set up index from database.A plurality of during when existing from database, can be therein one from database, set up index file, other can import the index file of foundation from database, and operate by above-mentioned index file.
Figure 2 shows that the synoptic diagram of the database index apparatus for establishing that preferred embodiment according to the present invention provides.As shown in Figure 2, the database index apparatus for establishing that provides of preferred embodiment of the present invention comprises that database information acquisition module 10, tables of data information acquisition module 11, index information acquisition module 12 and index file set up module 13.Wherein, database information acquisition module 10 is used to obtain all database informations.Tables of data information acquisition module 11 connects database information acquisition module 10, is used for obtaining all tables of data information of each database.Index information acquisition module 12 connects tables of data information acquisition module 11, is used for obtaining index information according to the tables of data information of obtaining.Index file is set up module 13 and is connected index information acquisition module 12, is used for setting up index file according to index information.Wherein, index information refers to carry the index statement of index type, index name and index restrictive condition.In addition, database information and tables of data information are saved to array respectively.About the detailed process that database index is set up, ditto described.So repeat no more in this.
In sum, preferred embodiment provides according to the present invention database index method for building up and device need not to login database, only can obtain index information from index file, and then learn whether index lacks or whether good.In addition, in the leader follower replication Database Systems, need not to login other and create index from the storehouse one by one, can directly import index file and carry out index, thereby save the time.In addition, the change of index information only needs to carry out in the indexed file, and is easy to operate.
The above is the preferred embodiments of the present invention only, is not limited to the present invention, and for a person skilled in the art, the present invention can have various changes and variation.Within the spirit and principles in the present invention all, any modification of being done, be equal to replacement, improvement etc., all should be included within protection scope of the present invention.

Claims (7)

1. a database index method for building up is characterized in that, may further comprise the steps:
Obtain all database informations;
Obtain all the tables of data information in each database;
Obtain index information according to the tables of data information of obtaining, and set up index file according to described index information,
Wherein, described index information refers to carry the index statement of index type, index name and index restrictive condition.
2. database index method for building up according to claim 1 is characterized in that, obtains all database informations by order show databases.
3. database index method for building up according to claim 1 is characterized in that, obtains all tables of data information in each database by order show tables.
4. database index method for building up according to claim 1 is characterized in that, at each tables of data, by order show index from tables of data title and order show create table tables of data title, obtains index information.
5. database index method for building up according to claim 1 is characterized in that, described database information and described tables of data information are saved to array respectively.
6. a database index apparatus for establishing is characterized in that, comprising:
The database information acquisition module is used to obtain all database informations;
Tables of data information acquisition module connects described database information acquisition module, is used for obtaining all tables of data information of each database;
The index information acquisition module connects described tables of data information acquisition module, is used for obtaining index information according to the tables of data information of obtaining; And
Index file is set up module, connects described index information acquisition module, be used for setting up index file according to described index information,
Wherein, described index information refers to carry the index statement of index type, index name and index restrictive condition.
7. database index apparatus for establishing according to claim 6 is characterized in that, described database information and described tables of data information are saved to array respectively.
CN 201110205033 2011-07-21 2011-07-21 Database index establishing method and device Pending CN102270231A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN 201110205033 CN102270231A (en) 2011-07-21 2011-07-21 Database index establishing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN 201110205033 CN102270231A (en) 2011-07-21 2011-07-21 Database index establishing method and device

Publications (1)

Publication Number Publication Date
CN102270231A true CN102270231A (en) 2011-12-07

Family

ID=45052536

Family Applications (1)

Application Number Title Priority Date Filing Date
CN 201110205033 Pending CN102270231A (en) 2011-07-21 2011-07-21 Database index establishing method and device

Country Status (1)

Country Link
CN (1) CN102270231A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103150397A (en) * 2013-03-26 2013-06-12 北京经纬恒润科技有限公司 Establishing method for data index, and data searching method and system
CN106776702A (en) * 2016-11-11 2017-05-31 北京奇虎科技有限公司 A kind of method and apparatus for processing the index in master-slave mode Database Systems
CN109241047A (en) * 2017-07-07 2019-01-18 深圳市辉宏技术有限公司 A kind of index establishing method, the apparatus and system of HTM database

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
《MySQL入门很简单》 20110131 黄缙华 等 在已经存在的表上创建索引 清华大学出版社 正文第119页到第121页第7.2.2节 1-7 , *

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103150397A (en) * 2013-03-26 2013-06-12 北京经纬恒润科技有限公司 Establishing method for data index, and data searching method and system
CN103150397B (en) * 2013-03-26 2016-03-16 北京经纬恒润科技有限公司 A kind of data directory creation method, data retrieval method and system
CN106776702A (en) * 2016-11-11 2017-05-31 北京奇虎科技有限公司 A kind of method and apparatus for processing the index in master-slave mode Database Systems
CN106776702B (en) * 2016-11-11 2021-03-05 北京奇虎科技有限公司 Method and device for processing indexes in master-slave database system
CN109241047A (en) * 2017-07-07 2019-01-18 深圳市辉宏技术有限公司 A kind of index establishing method, the apparatus and system of HTM database

Similar Documents

Publication Publication Date Title
CN104899295B (en) A kind of heterogeneous data source data relation analysis method
US8145653B2 (en) Using schemas to generate application specific business objects for use in an integration broker
CN101727535A (en) Cross indexing method for patients crossing system and system thereof
CN103368765B (en) A kind of privileges of management system adding method and device
CN110489699B (en) Asynchronous data acquisition method and system
US20120317078A1 (en) Replication Support for Structured Data
CN103678339A (en) Data backflow method and system and data access method and system in relational database
CN103488694A (en) Business data inquiry device and business data inquiry method
CN103810275A (en) Method and device for data interaction between non-relation type database and relation type database
CN102822819A (en) Managing data queries
CN102722537A (en) Database test data generation method and system thereof
CN101866350A (en) Report generation method and device as well as WEB server
CN102270231A (en) Database index establishing method and device
WO2007038014A3 (en) Provisional authority in a distributed database
CN103246704A (en) Mapping method for describing entity and relational data based on conventional data structure
CN106095824A (en) A kind of JSON format text imports the method for data base
CN102591960A (en) Agricultural economy electronic map data service interface method
CN108170752A (en) metadata management method and system based on template
CN103605733A (en) Page layout storage method based on JSON arrays
CN103246727A (en) Method for building multi-user forest resource spatial-temporal database
CN103177016B (en) Relevant database access method and device
CN104021216A (en) Message proxy server and information publish subscription method and system
CN103593182A (en) Method for reconfiguring software by using clustering mode
CN104572666A (en) Method for analyzing and importing Excel into database in batch based on Jxl
WO2007038408A2 (en) Metadata-based schema generator

Legal Events

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

Application publication date: 20111207