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!
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! 

closed as too localized by Martin Brandenburg, Andres Caicedo, Harry Gindi, S. Carnahan♦ Nov 27 '10 at 14:44This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. If this question can be reworded to fit the rules in the help center, please edit the question. 


The weirdest example of affineness / nonaffineness 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 nonaffine 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. 


The standard example is to let $X$ be the affine plane over a field, and $U=X\{(0,0)\}$. 


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 nonempty 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. 

