I want to access all the particular views of any particular table in Sqlite . I know I can get the list of all the available tables in the database using sqlite_master
SELECT name from sqlite_master WHERE type='table';
And the list of all the available views using
SELECT name from sqlite_master WHERE type ='view';
But I want to find all the available views for a particular table . How do I do that ?
If you are running the sqlite3 command-line access program you can type ". tables" to get a list of all tables. Or you can type ". schema" to see the complete database schema including all tables and indices.
To find all of the SQL Server database views where a table is used, just apply a filter criteria on table_name column of the information schema view INFORMATION_SCHEMA. VIEW_TABLE_USAGE as seen below.
Views are read-only in SQLite. However, in many cases you can use an INSTEAD OF trigger on the view to accomplish the same thing. Views are removed with the DROP VIEW command. If a column-name list follows the view-name, then that list determines the names of the columns for the view.
No need to use extension-functions.c; just use the "LIKE" operator:
SELECT name FROM sqlite_master WHERE type = 'view' and sql LIKE "%_tablename_%";
You will get false matches, of course, if you have table names that contain other table names as substrings, or that are substrings of common SQL reserved words (like "here" or "rom"). You can eliminate the latter by the following:
SELECT name FROM sqlite_master WHERE type = 'view' AND sql LIKE "% FROM %tablename% WHERE %";
providing the views you're trying to find conform to the typical model.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With