Why are locally closed subschemes not open subschemes of closed subschemes?
Ravi Vakil gives the following argument for why open subschemes of closed subschemes are locally closed: "Clearly an open subscheme U of a closed subscheme V of X can be interpreted as a closed subscheme of an open subscheme: as the topology of V is induced from the topology of X, the underlying set of U is the intersection of some open subset U' on X with V. We can take V' = $V \bigcap U'$, and then $V' \rightarrow U'$ is a closed embedding, and $U' \rightarrow X$ is an open embedding.
What I don't understand is why this argument doesn't also give the converse. It seems to me that if the words "closed" and "open" are switched in the above argument, we will "prove" that locally closed subschemes are open subschemes of closed subschemes. But this is false; what is wrong with the "proof"?
Topologically this is correct: let $Z$ be a closed subscheme of an open subscheme $U$ of $X$. Then there exists a closed subset $F$ of $X$ such that $F\cap U=Z$ set-theoretically (take $F$ be the Zariski closure of $Z$ in $X$). But the scheme structure of $Z$ might not extend to $F$.
The natural attempt is to define the scheme-theoretical closure of $Z$ in $X$, and this actually exists when $X$ is locally noetherian or, more generally, when $Z\to X$ is quasi-compact. So under this assumption, $Z$ is an open subscheme of a closed subscheme of $Z$. See [EGA], I.4.1.3.
QiL has already gave a nice explanation. I just want to add one comment. Follows the notation of QiL, if $Z$ is reduced, the converse is also true. But in general the converse is not true. For a counter-example please see Example 24.3.4 in the Stacks Project by de Jong. All the above can be found in the chapter 24 of the Stacks Project.