On 15 Aug 2019, at 3:01pm, Jose Isaias Cabrera <jic...@outlook.com> wrote:

> sqlite> SELECT * FROM sqlite_master WHERE type='table' AND name='PMOTitles';
> type|name|tbl_name|rootpage|sql
> table|PMOTitles|PMOTitles|11|CREATE TABLE PMOTitles
>    (
>      TitleKey PRIMARY KEY,
>      Titles
>    )
> 
> What is the difference in the name and tbl_name headers, above?

The table called "sqlite_master" has lots of things in it, not only tables but 
also, for example, indexes.  Your SELECT picks out only tables, so all the rows 
returned by that SELECT will have the same thing in "name" and "tbl_name".  But 
for rows which are indexes, "name" and "tbl_name" are different.

> Can I rename any of those two without damaging the DB? Thanks.

I'm not sure I understand that question.  If you're asking whether you can 
rename a column in sqlite_master, then no.  Leave it alone.  Having 
sqlite_master working correctly is extremely important !

If you're asking whether you can make changes to the data in sqlite_master, 
then the answer is "Not unless you know what you're doing.".  A VIEW, or an 
INDEX, can refer to another TABLE by name.  If you rename a table, things can 
stop working.

If you're careful to restore integrity and get everything right, you can make 
changes to "sqlite_master", and then tell SQLite to rescan it so that it sees 
your changes.  To do this, use

<https://sqlite.org/pragma.html#pragma_writable_schema>

I seem to remember that after you've made changes to "sqlite_master" there's a 
command you are meant to use to make SQLite reread it, but I don't remember 
what command that is right now, so perhaps you'd better just close and reopen 
the connection.
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to