open but not affine subscheme?example? In the book algebraice geometry by R.Harshorne we always say :an open affine subset U=SpecA of a sheme X.
I was always wondering that whether there existed an open but not affine subset.
I want to have a good example.
Thank you all very much!
 A: The standard example is to let $X$ be the affine plane over a field,
and $U=X-\{(0,0)\}$.
A: 1) Obviously if $X$ is not affine, then $U=X$ is an open subset which is not affine (see Kevin's comment above) but this might feel cheating.
2) A more general example along the lines of Robin's example is the following:
Let $X$ be an arbitrary $S_2$ affine scheme of dimension at least $2$. (If you don't know what $S_2$ is, take normal, or smooth). Let $Z\subset X$ be a non-empty closed subscheme of codimension at least $2$. Then $U=X\setminus Z\subset X$ is a proper open subset which is not affine.
Here is why it's not affine: Assume that $X={\rm Spec} A$ is affine and let $\iota:U\hookrightarrow X$ be the natural embedding. By the $S_2$ property it follows that $\iota_*\mathcal O_U\simeq \mathcal O_X$, and consequently the induced morphism on global sections $\Gamma(U, \mathcal O_U)\to A$ is an isomorphism, but then if $U$ were affine, then this would imply that the embedding $\iota$ is an isomorphism, which is not true by construction.
A: The weirdest example of affineness / non-affineness I know is the following.  There is a smooth projective scheme $X$ over $\mathbb{Z}[1/7]$ and a closed subscheme $Z$ (in fact, $Z$ is a smooth irreducible divisor) such that $U = X \setminus Z$ is not affine.  However, after tensoring with $\mathbb{Z}/p$ , $$U_p := U \otimes_{\mathbb{Z}} \mathbb{Z}/p$$
is affine for infinitely many $p > 0$ and also non-affine for infinitely many $p > 0$.  
For details, see Remark 4.8 in MR2220102, Brenner and Katzman, J. Amer. Math. Soc. 19 (2006), no. 3.
EDIT:  As far as I know, it is unknown whether similar examples exist in the equal characteristic setting.
