怎样才能看到SQLite中的表的结构?
我怎样才能看到SQLite中的表结构,因为desc是在Oracle? 
 在数据库文件上调用sqlite3实用程序,并使用其特殊的点命令: 
-   
.tables将列出表格 -   
.schema [tablename]将显示一个或多个表的CREATE语句 
还有许多其他有用的内build点命令 – 请参阅http://www.sqlite.org/sqlite.html上的文档,; 关于sqlite3的特殊命令部分。
例:
 sqlite> entropy:~/Library/Mail>sqlite3 Envelope\ Index SQLite version 3.6.12 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite> .tables addresses ews_folders subjects alarms feeds threads associations mailboxes todo_notes attachments messages todos calendars properties todos_deleted_log events recipients todos_server_snapshot sqlite> .schema alarms CREATE TABLE alarms (ROWID INTEGER PRIMARY KEY AUTOINCREMENT, alarm_id, todo INTEGER, flags INTEGER, offset_days INTEGER, reminder_date INTEGER, time INTEGER, argument, unrecognized_data BLOB); CREATE INDEX alarm_id_index ON alarms(alarm_id); CREATE INDEX alarm_todo_index ON alarms(todo); 
 还要注意,SQLite将数据库本身的模式和所有关于表的信息保存在一个名为sqlite_master的魔术表中 ,也可以对该表执行正常的SQL查询。 例如,上面的文档链接显示了如何使用普通的SQL命令(参见查询数据库模式 )来派生.schema和.tables命令的行为。 
 PRAGMA table_info(table_name); 
这将适用于:命令行和对连接的数据库执行时。
.schema TableName
TableName是表的名称
 你可以查询sqlite_master 
 SELECT sql FROM sqlite_master WHERE name='foo'; 
 这将返回一个create table SQL语句,例如: 
 $ sqlite3 mydb.sqlite sqlite> create table foo (id int primary key, name varchar(10)); sqlite> select sql from sqlite_master where name='foo'; CREATE TABLE foo (id int primary key, name varchar(10)) sqlite> .schema foo CREATE TABLE foo (id int primary key, name varchar(10)); sqlite> pragma table_info(foo) 0|id|int|0||1 1|name|varchar(10)|0||0 
您应该能够通过运行来查看架构
 .schema <table> 
您将通过键入以下命令来获得结构:
 .schema <tableName> 
如果你使用PHP,你可以这样做:
 <?php $dbname = 'base.db'; $db = new SQLite3($dbname); $sturturequery = $db->query("SELECT sql FROM sqlite_master WHERE name='foo'"); $table = $sturturequery->fetchArray(); echo '<pre>' . $table['sql'] . '</pre>'; $db->close(); ?> 
您可以使用名为SQLite Manager的Firefox插件清楚地查看数据库的结构。
我已经在PHP中实现了一个SQLite表模式parsing器。 你可以在这里检查:我实现了一个sqlite表分析器
https://github.com/maghead/sqlite-parser
语法遵循SQLite创build表语句语法: http : //www.sqlite.org/lang_createtable.html
- 强制Python放弃原生sqlite3并使用(安装的)最新的sqlite3版本
 - python 3.2 UnicodeEncodeError:'charmap'编解码器不能在位置9629编码字符'\ u2013':字符映射到<undefined>
 - 创build后,将ON DELETE CASCADE行为添加到sqlite3表中
 - 由于索引,SQLite插入速度随着logging数量的增加而减慢
 - 使用Python将CSV文件导入到sqlite3数据库表中
 - 从sqlite数据库中删除重复的行
 - string比较时如何设置Sqlite3不区分大小写?
 - SQL在date之间select
 - Google Analytics(分析)SDK 3.0中的_sqlite3链接器错误