Hello friends and welcome to the channel today we are going to show you how we can see the tables that belong to a database using code. The easiest way is to open the database then you open the directory called "Tables" and here it shows you all the tables

However, we are going to see how it is done using the code. This is a more advanced way which allows us to make filters and now we are going to see how it is done. Here it shows you the name of all the tables that belong to the "AdventureWorks database "Here you will also see in the column called" table_type "what type of table it is and it means if the table is a physical table or it is a" View "For this reason we can also do a filter and we will see how it is done

We simply use the same code and put a condition at the end.For example, in this case we want to see all the tables that belong to the production schema.In this case, the tables that we list with our query are limited to only that schema. also do a filter based on the table type we can do the same For example we can filter by the schema again and we can also filter by the table type

In this case, if you see below, the number of records is 28 when we execute it, you no longer see the view here and you also see that there are 3 less There are only 25 The reason is because here we filter the "views" if we want to see the "views" belong only to this scheme we can do the following View and as you can see there are only three at the moment There is another way to see the type of tables and the tables that we have inside the database using code and it is like this In this case another Once we are going to filter by the "Production" schema And here we have all the tables that are in this schema.

In the number of records that we have, this does not give us the "views" it only gives us the "tables" the tables If we want to see the 'views' which will be 3 in this case We go to "sysviews" and see that there are 3 only because we are seeing the "views" in that schema if we run the query without the filter in the schema, you will see that there are more. For example, the schema called "Sales" we have 7 "views"

I hope you have enjoyed until next video Thanks

Exit mobile version