首页 > 数据库技术 > 详细

Sqlite文件在ubunut的查看

时间:2018-11-09 18:47:05      阅读:193      评论:0      收藏:0      [点我收藏+]

 

 

 

 

1.

How to list the tables in a SQLite database file that was opened with ATTACH?

 

The .tables, and .schema "helper" functions don‘t look into ATTACHed databases: they just query the SQLITE_MASTER table for the "main" database. Consequently, if you used

ATTACH some_file.db AS my_db;

then you need to do

SELECT name FROM my_db.sqlite_master WHERE type=‘table‘;

Note that temporary tables don‘t show up with .tables either: you have to list sqlite_temp_masterfor that:

SELECT name FROM sqlite_temp_master WHERE type=‘table‘;
  
  • 81
    Only "SELECT name FROM sqlite_master WHERE type=‘table‘" works for me – vladkras Dec 15 ‘15 at 13:28
  • 2
    SELECT name FROM my_db.sqlite_master WHERE type=‘table‘; this does not work for me (for the attached DB) and it throws error as: no such table exist "my_db.sqlite_master" – kanika Jul 27 ‘16 at 7:16
  •  
    what you meant by temporary tables? Are there any when I just opened SQLite db file? – Ewoks May 7 ‘17 at 13:20
  •  
    Temporary tables are those created with CREATE TEMPORARY TABLE SQL commands. Their contents are dropped when the current database connection is closed, and they are never saved to a database file. – Anthony Williams May 8 ‘17 at 14:37
  • 1
    Under sqlite3 command mode and run ATTACH "some_file.db" AS my_db; It worked! – John_J Dec 25 

技术分享图片

 

技术分享图片

 

 技术分享图片

 

2.You could attach another database file from the SQLite shell:

sqlite> attach database ‘RelDb.sqlite‘ as RelDb;

sqlite> .databases
main: /db/UserDb.sqlite
RelDb: /db/RelDb_1.sqlite

sqlite> .tables
RelDb.collectionRelationship  contentStatus               
RelDb.contentRelationship     genres                      
RelDb.leagueRelationship      recordingFilter             
RelDb.localizedString         syncedContentStatus         
accountLevelSettings          syncedThumbs                
collectionActivity            thumbs                      

The tables from this 2nd database will be accessible via prefix of the database:

sqlite> select count(*) from RelDb.localizedString;
2442

Sqlite文件在ubunut的查看

原文:https://www.cnblogs.com/x-poior/p/9936459.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!