pawelsalawa / sqlitestudio

A free, open source, multi-platform SQLite database manager.
https://sqlitestudio.pl
Other
4.4k stars 551 forks source link

Database Management -- Fields in Tables #3554

Open JrgMyr opened 4 years ago

JrgMyr commented 4 years ago

Where are the fields (row) information stored inside of a database? The table "sqlite_master" has tables and views but not the field info.

Is there any other way to get to the field names in a given table than parsing the CREATE TABLE code? I imagine a second management table that links rows to table names. Does this exist?

Best, Jörg

JrgMyr commented 4 years ago

Ok, I found something myself. Apologies for not finding it during previous researches. There is a PRAGMA table_info which doubles as a table-valued function and can be used like this in a regular query:

select * from pragma_table_info('tablename');

Out of curiosity: where is this info stored inside the database?

pawelsalawa commented 4 years ago

It's all in sqlite_master. Everything you need to know about any table or view is stored there.

The only exception is when you create temporary objects (CREATE TEMP ...) - in that case they are in sqlite_temp_master.