avatar

目录
sqlite-browser-index-display

SQLite Browser Index and Primary Key Display

主界面

在SQLite Browser的主界面中,你会看到几个选项卡:

  1. Database Structure(数据库结构)
  2. Browse Data(浏览数据)
  3. Edit Pragmas(编辑语用)
  4. Execute SQL(执行SQL)

查看索引和主键

  1. 在”Database Structure”选项卡中:

    • 你会看到一个树状结构,显示所有的表格。
    • 展开一个表格,你会看到”Indices”子节点。
    • 主键会显示为一个特殊的索引,通常名为”sqliteautoindex表名_1”。
  2. 在表格详情中:

    • 点击一个表格,右侧会显示表格的详细信息。
    • 你会看到”Table”和”Indices”两个部分。
    • 在”Table”部分,主键列会被标记为”PK”。
    • 在”Indices”部分,你会看到所有的索引,包括主键索引。

示例

假设我们有一个名为”students”的表:

Code
1
2
3
4
5
6
7
+--------------------+
| students |
+--------------------+
| id (INTEGER, PK) |
| name (TEXT) |
| age (INTEGER) |
+--------------------+

在SQLite Browser中,它可能会这样显示:

Code
1
2
3
4
5
6
7
8
students
|-- Columns
| |-- id (INTEGER, PK)
| |-- name (TEXT)
| |-- age (INTEGER)
|-- Indices
|-- sqlite_autoindex_students_1 (id)
|-- idx_name (name)

其中:

  • sqlite_autoindex_students_1 是自动为主键”id”创建的索引。
  • idx_name 是我们可能手动创建的索引。

创建新索引

  1. 在”Execute SQL”选项卡中,你可以运行创建索引的SQL命令:

    sql
    1
    CREATE INDEX idx_age ON students(age);
  2. 创建后,刷新”Database Structure”视图,你会在”Indices”下看到新的索引。


评论