The next thing we need to cover around views is what we can and can't do with views.
Views may act like a table.
They might look like a table in some situations, but of course they're not true tables behind the scenes.
And that means we can't always perform all table operations with a given view.
So if we go back to our full select start from full reviews view, this view here has all sorts of information
synthesized from different tables.
Of course, we joined three tables together in the previous video, so with a regular table, if this
is a true table, I could do something like delete.
Let's just delete everything that was released in the year 2010.
I don't know why, but let's say that's what I want to do.
Well, in a regular table I would do a delete from the table name Full reviews where released year equals
2010, but it doesn't work.
It says cannot delete from join view called full review.
So you can't delete from that view.
So what it's telling me is it's not a real table and there's rules to what we can and can't do.
And because this is a join view, you can't delete.
So it's a little complicated, the different rules, but there's a whole page in the docs about this.
Basically only a very small portion of views are updatable and insert double meaning we can insert into
them and update them and treat them as if they were a table.
Same thing with delete.
And if you have any of these bullet points in your view, then you're going to have a bad time if you
use an aggregate function.
Some in Macs that view is no longer updatable or delete able or inscrutable.
If you use group by, if you have some queries, if you have joints, at least certain joints.
And this is a nuance thing, there's a lot of detail about joints.
Sometimes you can write a joint view that is updatable, but we're not going to go into all of that.
It can get quite complicated, but the point is that our view is not updatable.
It's not going to work for us.
But that doesn't mean all views are limited to only selecting.
We could write a simple view, just as an example here that I don't know.
Let's do like a query.
We might run somewhat frequently.
Let's do select star from series and we'll do an order by released here.
Let's say this is something we do a lot.
Probably not, but let's say it is.
I could make this a view.
I'll call it something like, I don't know, create view.
What should we call it?
Ordered series.
Again, it's silly.
It's trivial because we could just this is a short enough query to run, but I want to show just a simple
example to prove my point that some queries or that some views are updatable and in searchable OC.
So if I create this view ordered series now I select star from ordered series ordered series.
There we are.
We see all of our series ordered by release here.
Simple enough.
So let's say I treat this as a table ordered series and I want to delete or actually I don't want to
delete our data, but let's say I want to insert something into it.
I really like the show The Great, which came out I think in 2020 for the first season.
So I would do an insert into never mind the fact that I could just insert into series with this.
Just let's ignore that, let's just insert into ordered series and I'll do a title released year and
genre.
And then have my values.
The Great 2020 is the first release year and genre is comedy, and that needs to be in quotes.
So this is not a real table ordered series.
Of course, behind the scenes there is a table called series, but this is a view that we set up.
It looks like a table that it's not a true table, but it will let us insert because this is considered
an instable, updatable, delectable view, and that's because it doesn't break any of the rules laid
out here.
We didn't use Group BI.
We don't have aggregate functions.
There's no sub queries, we don't have joints.
So it is an updatable view I can insert into it.
And now if I do a select star from ordered series, we see the great edit in there and that means it's
also been added into select star from series.
Into our series so I can also delete delete from ordered series where.
Let's do well let's just do title equals the great to delete that.
And one more time.
This is our virtual table.
This is not a true table.
This is all based upon the query that we stored under the View name ordered series.
But I can treat it as a table and I can delete from it.
And if we now look at ordered series, the Great is gone.
Well, it should be gone.
And it is gone.
Okay, so that's all I'm going to show in this video.
Just know that by making something a view that does not mean that you can truly treat it as a table
with all the standard operations.
Deleting, updating, inserting only a subset of views allow those operations and it all depends on
if they include any of these features or not.