# Properties of codimension under pull back

If I pull back a cycle of codimension $c$ along a morphism of schemes I can easily see that the codimension can stay the same or the codimension can drop to all the way to $0$. But intuitively it seems the codimension can never increase. Is there a precise statement of this form?

To state it more carefully suppose $X,Y$ are irreducible schemes and $f:X \to Y$ is a morphism and $Z\subset Y$ is an irreducible subscheme of codimension $c$. Is it always true that if $T\subset f^{-1}(Z)$ is an irreducible component then $codim(T) \leq codim(Z)$?

If this is not true then are there reasonable hypothesis under which it is true, $X,Y$ Noetherian, finite type, smooth?

If $f$ is flat the codimension should be preserved but the inequality above seems to be true more generally.

This is false as stated: taking for $f$ the embedding of a closed subscheme $X\subset Y$, it would mean that $\operatorname{codim}(X\cap Z,X)\leq \operatorname{codim}(Z,Y)$. There are well-known counter-examples: let $Y_0$ be a projective variety with two divisors $D_1,D_2$ which do not intersect, let $Y$ be the cone over $Y_0$, and let $Z,X$ be the subcones over $D_1$ and $D_2$.
To correct the statement you need to assume that $f$ is surjective. Then it is true if moreover $X$ and $Y$ are locally noetherian: this is Corollary 6.1.4 in EGA IV (Part 2).