SQLite expert table separates and solves the problem of the size unchanged after SQLite expert deletes the table

Source: Internet
Author: User
Tags sqlite

Finally, to use the number attribution to the query, find a database file on the Internet. Size is more than 12M, compressed into a zip also has 1.9M, so for an apk size is very unfavorable, later looked at the database content, found that there is a lot of redundancy. In particular, Chinese characters occupy very large space, and find a way to separate a table on the Internet. Divided into two tables, two tables can be associated using a foreign key form. Here are a few table names: Tb_city, Mob_location, Tb_mobile, and finally to separate the table mob_location into Tb_city, tb_mobile on SQLite expert can use SQL statements, Here are just some of the key things I feel, such as creating a table, opening a new field database, setting the primary key, foreign keys these do not speak, for the SQLite expert do not know a friend can first Baidu under how to use. Inserts the queried data into the specified table. Remove the repeated

INSERT into tb_city (location, areacode) Select location, AreaCode from Mob_location Group by location

Query two tables at a time
SELECT * from Tb_city, mob_location where tb_city. [Location] = mob_location. [Location]

SELECT * from Tb_city, tb_mobile where tb_city. [_id] = Tb_mobile. [foreign_id] and Tb_mobile. [Number] = 1342797
The above statement is also applicable in Java code, as used in code:
String sql = "SELECT * from Tb_city, tb_mobile where tb_city. [_id] = Tb_mobile. [foreign_id] and Tb_mobile. [NUMBER] = "+ num;

Inserting data from two table queries into a table
Insert into Tb_mobile (foreign_id, number) Select Tb_city. [_id], mob_location. [_id] from tb_city, mob_location where tb_city. [Location] = mob_location. [Location]

Here, the table mob_location separated into tb_city, tb_mobile, at this time to see the database size of 16M, the table mob_location right-click Delete, but found that the size of the database no matter what changes. Later found to delete just put it into the cache. And did not empty, need to right-click on the database->vacuum, tap to empty, then to see the size of just a little more than 3M, so the capacity of a lot less, and then zip compression, but the effect of compression is not very ideal.

The database and code can be downloaded to the following link:

Http://pan.baidu.com/s/1sjFWJRv


SQLite expert table separates and solves the problem of the size unchanged after SQLite expert deletes the table

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.