SQLite Modify table name, merge database (file)

Source: Internet
Author: User

修改表名:
ALTER TABLE orig_table_name RENAME TO tmp_table_name;

合并2个数据库的表:
1、先连接数据库A
ATTACH "c:\database_b\places.sqlite" AS SecondaryDB;   (若还要attach其它数据库,则 ATTACH "c:\database_b\third.sqlite" AS ThirdDB;
3、(若要将B中的某个表的数据追加到A中的某个表中,则: INSERT OR IGNORE INTO MyTable SELECT * FROM SecondaryDB.MyTable;  但条件是这2个表的id主键没有冲突,若有冲突,则修改B的主键)
4、然后:  COMMIT;
5、最后:  DETACH DATABASE SecondaryDB;


拷贝2个数据库的表:
1、先连接数据库A
ATTACH "c:\database_b\third.sqlite" AS ThirdDB;
SecondaryDB.oldTableInMyOtherDB;
4、 commit;
5、最后:  DETACH DATABASE SecondaryDB;

1、查看表的schema格式:  .schema tablename      或者 PRAGMA SecondaryDB.table_info(table_name);
2、对于attached数据库,若要查看它的表,则:  SELECT name FROM SecondaryDB.sqlite_master WHERE type=‘table‘;

SQLite Modify table name, merge database (file)

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.