Proving that $\operatorname{codim}(X,Y)=\dim(\mathcal{O}_{X,\eta})$ I have a problem with the following exercise: Let $X$ be a noetherian scheme and $Y \subset X$ an irreducible closed subset. I have to prove that $$ \operatorname{codim}(X,Y)=\dim(\mathcal{O}_{X,\eta}), $$
where $\eta$ is the generic point of $Y$. We can replace $X$ with an open affine $U_\eta$, neighbourhood containing the generic point $\eta$. So we have that
$$\operatorname{codim}(X,Y)=\operatorname{codim}(U_\eta, U_\eta \cap Y) ,$$
but I don't know how to conclude the proof. In particular if $Z$ is an irreducible component of $X$, can I conclude that $\operatorname{codim}(Z,X)=0$? Thanks in advance!
 A: First some reductions. The problem is local so we may reduce to the case that $X$ is affine and we have a closed immersion $Y \to X$ in which case $Y$ is affine too. Furthermore, we can give $Y$ the reduced induced subscheme structure so that the closed immersion $Y \to X$ is the one induced by a ring map $A \to A/\mathfrak{p}$ for $\mathfrak{p}$ a prime ideal of $A$. Here we use the fact that an irreducible, reduced scheme is integral.
We recall that $\operatorname{codim}(Y,X)$ is equal to the supremum of the lengths of chains of irreducible closed subsets containing $Y$ (see Qing Liu, Definition 2.5.7):
$$Y \subseteq Z_0 \subsetneq Z_1 \ldots \subsetneq Z_n.$$
Since we have $Y =V(\mathfrak{p})$ you are now asking to prove:
$$\operatorname{codim}(V(\mathfrak{p}),\operatorname{Spec} A) = \operatorname{ht}(\mathfrak{p}) = \dim ( \operatorname{Spec} A_{\mathfrak{p}}).$$
In some sense this is now easy from the Nullstellensatz for $\operatorname{Spec} A$: Given a chain of prime ideals $\mathfrak{p}_0 \subsetneq \ldots \subsetneq \mathfrak{p}_n \subseteq \mathfrak{p}$ we apply $V(-)$ to get a chain of irreducible closed subsets $V(\mathfrak{p}) \subset V(\mathfrak{p}_n) \subsetneq V(\mathfrak{p}_{n-1}) \ldots \subsetneq V(\mathfrak{p}_0)$. The inclusions $V(\mathfrak{p}_i) \subset V(\mathfrak{p}_{i-1})$ are strict for $i \leq n$ (otherwise just take radicals to get that the original primes you had were equal, contradiction).
Conversely for any chain $V(\mathfrak{p}) \subseteq V(J_0) \subsetneq \ldots \subsetneq V(J_n)$ with each $V(J_k)$ irreducible, we must have that the radical of $J_k$ be prime (exercise). Since $V(\sqrt{J}) = V(J)$ it follows we may assume that each $J_k$ is prime. Now apply $I(-)$  to each of these to get
$$J_n \subsetneq J_{n-1} \subsetneq \ldots \subsetneq J_0 \subseteq \mathfrak{p}.$$
This establishes the fact we wanted to prove! Now  did we need  the Noetherian hypothesis? Not at all!


Exercise : In my answer above, I used the fact that $V(I)$ is irreducible iff $\sqrt{I}$ is prime. Prove this.


A: The main observation here is that there is a topological embedding  $$j: \operatorname{Spec}\: \mathcal O_{X,\eta}\hookrightarrow X$$  inducing an order preserving bijection between the points $z=[\mathfrak p]\in  \operatorname{Spec}\: \mathcal O_{X,\eta}$ and the set $\operatorname {Irr}(Y,X)$ of irrreducible closed subsets $Z\subset X$ satisfying  $Y\subset Z\subset X$ .
The bijection associates to $z\in \operatorname{Spec}\: \mathcal O_{X,\eta}$ the irreducible closed subset $Z=\overline {\{j(z)\}}$
This is proved in EGA I, Proposition (2.4.2) page 102 .
See also this answer on MathOverflow. 
The order relation on $\operatorname{Spec}\: \mathcal O_{X,\eta}$ being $$z=[\mathfrak p] \leq   z'=[\mathfrak p'] \iff z\in \overline { \{z'\}}\iff   \mathfrak p\supset \mathfrak p' $$ and the order relation on $\operatorname {Irr}(Y,X)$ being $Z\subset Z'$, we immediately obtain $$\operatorname {dim} (\operatorname{Spec}\: \mathcal O_{X,\eta})=\operatorname{codim} (Y,X)$$
