How do I find the base table of a view in SQL?

How do I find the base table of a view in SQL?

Using the Information Schema

  1. SELECT TABLE_NAME FROM INFORMATION_SCHEMA. TABLES.
  2. SELECT TABLE_NAME, COLUMN_NAME FROM INFORMATION_SCHEMA. COLUMNS.
  3. SELECT COLUMN_NAME FROM INFORMATION_SCHEMA. COLUMNS WHERE TABLE_NAME = ‘Album’
  4. IF EXISTS( SELECT * FROM INFORMATION_SCHEMA.
  5. IF EXISTS( SELECT * FROM INFORMATION_SCHEMA.

Are views base tables?

Unlike ordinary base tables in a relational database, a view does not form part of the physical schema: as a result set, it is a virtual table computed or collated dynamically from data in the database when access to that view is requested. Views can represent a subset of the data contained in a table.

How do I find a database table?

SQL command to list all tables in Oracle

  1. Show all tables owned by the current user: SELECT table_name FROM user_tables;
  2. Show all tables in the current database: SELECT table_name FROM dba_tables;
  3. Show all tables that are accessible by the current user:

How do I find the references to a table in SQL Server?

Using SQL Server Management Studio

  1. In Object Explorer, expand Databases, expand a database, and then expand Tables.
  2. Right-click a table, and then click View Dependencies.
  3. In the Object Dependencies dialog box, select either Objects that depend on , or Objects on whichdepends.

What is the difference between base table and view?

A table is structured with columns and rows, while a view is a virtual table extracted from a database. The table is an independent data object while views are usually depending on the table. If we want to make any changes in a view, we need to update the data in the source tables.

How to get the base table of views?

Viewed 10K+ times! This question is Thanks a lot for your hard work. My question is writing a query to get the base table name of view. Are there any dictionary views including these information? Thanks. and we said…

Is it possible to determine the base table?

It depends on what you mean by, “looking at them”. If you mean looking at a script that creates the table then yes. Also, if you mean by browsing through something like SQL Server Management Studio then again yes, because they break tables and views into different folders.

How to find all tables related to a view?

I have a view-A that is comprised of other views (View-B View-C) and I would like to list all the tables that used by View-A (which would include the tables used in View-B and View-C). When I use this code… …I only get the tables that are immediately used by View-A plus the name of the other views (View-B, View-C).

How to determine table referenced in view in SQL Server?

SELECT * FROM INFORMATION_SCHEMA.VIEW_COLUMN_USAGE AS cu JOIN INFORMATION_SCHEMA.COLUMNS AS c ON c.TABLE_SCHEMA = cu.TABLE_SCHEMA AND c.TABLE_CATALOG = cu.TABLE_CATALOG AND c.TABLE_NAME = cu.TABLE_NAME AND c.COLUMN_NAME = cu.COLUMN_NAME WHERE cu.VIEW_NAME = ‘viewtablename’; You can use DISTINCT to get only the tables.