SQLite Schema Information Metadata

后端 未结 7 1062
终归单人心
终归单人心 2020-11-27 03:46

I need to get column names and their tables in a SQLite database. What I need is a resultset with 2 columns: table_name | column_name.

In MySQL, I\'m a

7条回答
  •  面向向阳花
    2020-11-27 03:59

    There are ".tables" and ".schema [table_name]" commands which give kind of a separated version to the result you get from "select * from sqlite_master;"

    There is also "pragma table_info([table_name]);" command to get a better result for parsing instead of a construction query:

    
    sqlite> .tables
    students
    sqlite> .schema students
    create table students(id INTEGER, name TEXT);
    sqlite> pragma table_info(students);
    0|id|INTEGER|0||0
    1|name|TEXT|0||0
    

    Hope, it helps to some extent...

提交回复
热议问题