Let $X$ be a regular affine $\mathbb{C}$scheme, $A$ a (finitelygenerated) $\mathbb{C}$algebra. Let $Y \subset X \times \mathrm{Spec}(A)$ be a closed subscheme of codimension $1$ such that for each $t \in \mbox{Spec}(A)$, the fiber $Y_t$ is an effective Cartier divisor of $X \times \{t\}$. Is $Y$ flat over $\mbox{Spec}(A)$? In other words, does fiberwise Cartier imply globally Cartier?

1$\begingroup$ Laurent MoretBailly already answered your question. I am just repeating his second counterexample, since you seem not to have understood his point. Let $X$ be $\mathbb{A}^1_k$ with coordinate $s$, let $A$ be $k[t]$, and let $Y$ be the closed subscheme with defining ideal $\langle s^2,st \rangle$. The fiber $Y_t$ is an effective Cartier divisor in $X\times\{t\}$ for every $t$ in $\text{Spec}\ A$. However, $Y$ is not flat over $\text{Spec}\ A$. $\endgroup$– Jason StarrJan 17, 2019 at 19:40

$\begingroup$ @JasonStarr Thank you. I understand now. $\endgroup$– user45397Jan 17, 2019 at 20:01
1 Answer
I assume that "scheme" means $\mathbb{C}$scheme, and that the product is over $\mathbb{C}$. I also assume that $Y$ is a closed subscheme.
First (trivial) counterexample: take for $Y$ an effective Cartier divisor in $X\times t$ ($t\in \mathrm{Spec}(A)(\mathbb{C})$), viewed as a subscheme of $X\times \mathrm{Spec}(A)$.
Second counterexample: if $X$ is a regular curve, every proper closed subscheme of $X$ is a Cartier divisor in $X$. So, take for $Y$ any closed subscheme not containing any fiber component, and not flat over $\mathrm{Spec}(A)$.