我刚刚开始学习SQLite。如果能够看到表的详细信息就太好了,比如MySQL的DESCRIBE [table]。PRAGMA table_info [table]不够好,因为它只有基本信息(例如,它没有显示一个列是否是某种类型的字段)。SQLite有办法做到这一点吗?
当前回答
如果你使用图形工具。它在表名旁边显示模式。对于DB Browser For Sqlite,单击打开数据库(右上角),导航并打开您的数据库,您将看到填充在表中的信息如下所示。
右键单击record/table_name,单击copy create statement,你就有了它。
希望它能帮助到一些无法使用命令行的初学者。
其他回答
PRAGMA table_info([tablename]);
如果你使用图形工具。它在表名旁边显示模式。对于DB Browser For Sqlite,单击打开数据库(右上角),导航并打开您的数据库,您将看到填充在表中的信息如下所示。
右键单击record/table_name,单击copy create statement,你就有了它。
希望它能帮助到一些无法使用命令行的初学者。
SQLite命令行实用工具有一个.schema TABLENAME命令,它向您显示创建语句。
为了防止人们被一些评论误导到其他答案:
如果.schema或sqlite_master的查询没有给出任何输出,则表示表名不存在,例如,这也可能是由;.schema, .tables,…或者只是因为这个表根本不存在。 schema不能正常工作是不太可能的,然后应该在sqlite项目中提交错误报告。
... .模式只能在命令行中使用;上面的命令>可以通过库(Python, c#等)作为查询运行。——Mark Rushakoff 7月25日21:09
'can only be used from a command line' may mislead people. Almost any (likely every?) programming language can call other programs/commands. Therefore the quoted comment is unlucky as calling another program, in this case sqlite, is more likely to be supported than that the language provides a wrapper/library for every program (which not only is prone to incompleteness by the very nature of the masses of programs out there, but also is counter acting single-source principle, complicating maintenance, furthering the chaos of data in the world).
查看所有表格:
.tables
要查看一个特定的表:
.schema [tablename]
推荐文章
- 模式、表和数据库之间的区别是什么?
- 如何停止mysqld
- 检查MySQL表是否存在而不使用“select from”语法?
- 从NOW() -1天选择记录
- 我看到VARCHAR(255)如此频繁地使用(而不是其他长度),有什么好的原因吗?
- 使用pgadmin连接到heroku数据库
- 从表中选择1是什么意思?
- Delete_all vs destroy_all
- 我如何移动一个redis数据库从一个服务器到另一个?
- 如何首次配置postgresql ?
- 数据库性能调优有哪些资源?
- 如何更改表的默认排序规则?
- 如何在PostgreSQL中自动更新时间戳
- MySQL foreign_key_checks是否影响整个数据库?
- 设置NOW()为datetime数据类型的默认值?