I'm not sure whether this is non-trivial or not, but do there exist simple examples of an affine scheme $X$ having an open affine subscheme $U$ which is not principal in $X$? By a principal open of $X = \mathrm{Spec} \ A$, I mean anything of the form $D(f) = \{\mathfrak p \in \mathrm{Spec} \ A : f \notin \mathfrak p\}$, where $f$ is an element of $A$.
Open Affine Subscheme – Non-Principal Examples in Algebraic Geometry
ag.algebraic-geometry
Related Solutions
Theorem 1: Let $R$ be an integral domain with field of fractions $K$, and $R \to A$ a homomorphism. Then $Spec(A) \to Spec(R)$ is an open immersion if and only if $A=0$ or $R \to K$ factors through $R \to A$ (i.e. $A$ is birational over $R$) and $A$ is flat and of finite type over $R$.
Proof: Assume $Spec(A) \to Spec(R)$ is an open immersion and $A \neq 0$. It is known that open immersions are flat and of finite type. Thus the same is true vor $R \to A$. Now $R \to K$ is injective, thus also $A \to A \otimes_R K$. In particular, $A \otimes_R K \neq 0$. Open immersions are stable under base change, so that $Spec(A \otimes_R K) \to Spec(K)$ is an open immersion. But since $Spec(K)$ has only one element and $Spec(A \otimes_R K)$ is non-empty, it has to be an isomorphism, i.e. $K \to A \otimes_R K$ is an isomorphism. Now $R \to A \to A \otimes_R K \cong K$ is the desired factorization.
Of course, the converse is not as trivial. It is proven in the paper
Susumu Oda, On finitely generated birational flat extensions of integral domains Annales mathématiques Blaise Pascal, 11 no. 1 (2004), p. 35-40
It is available online. In the section "Added in Proof." you can find some theorems concerning the general case without integral domains. In particular, it is remarked that in E.G.A. it is shown that
Theorem 2: $Spec(A) \to Spec(R)$ is an open immersion if and only if $R \to A$ is flat, of finite presentation and an epimorphism in the category of rings.
More generally, in EGA IV, 17.9.1 it is proven that a morphism of schemes is an open immersion if and only if it is flat, a (categorical) monomorphism and locally of finite presentation.
There are several descriptions of epimorphisms of rings (they don't have to be surjective), see this MO-question.
You can, if you use a slightly more general notion of gluing. (The notion of gluing you present is "wrong", or at least simplistic, in roughly the same way that it is "wrong" to require that a basis for a topology be closed under intersections. E.g., if you do this, then the set of open balls in $\mathbb{R}^n$ for $n > 1$ does not form a "basis.")
Let $X$ be a scheme. Consider the diagram whose objects are open affine subschemes of $X$, and whose morphisms are inclusions $U \hookrightarrow V$ such that $U$ is a distinguished open subset of $V$. Whenever $U$ and $V$ are two objects and $x \in U \cap V$, there exists an object $W \subset U \cap V$ such that $x \in W$ and $W \hookrightarrow U$, $W \hookrightarrow V$ are both morphisms: Since the distinguished open subsets of $U$ form a basis for the topology, there is a distinguished open $W'$ in $U$ such that $x \in W' \subset U \cap V$. Similarly, there is a section $f$ over $V$ such that $x \in V_f \subset W'$. But then $V_f = W'_f$ is a distinguished open subset of both $U$ and $V$, so we let $W = W'_f$.
It is also not too hard to show that whenever we have a category as above, we can glue things together to form a scheme (i.e., the diagram has a unique colimit in the category of schemes). If someone asks for a precise statement of this, I'll try to cook one up, but it's not particularly nice. (Not quite horrendous, but not very nice either.)
In particular, the fiber product is obtained by gluing together schemes of the form $\mathrm{Spec} A \otimes_C B$, where $\mathrm{Spec} C$ contains the images of both $\mathrm{Spec} A$ and $\mathrm{Spec} B$, with "overlap inclusions" specified by morphisms $A \otimes_C B \to A_f \otimes_C B_g$. An important note here: if $C \to D$ is a ring epimorphism (e.g., corresponds to an open immersion), and $A, B$ are $D$-algebras, then $A \otimes_C B$ is naturally isomorphic to $A \otimes_D B$.
Best Answer
Let X be an elliptic curve with the identity element O removed. Let U=X-P where P is a point of infinite order. Then U is affine by a Riemann-Roch argument. Now suppose that U=D(f). Then on the entire elliptic curve, the divisor of f must be supported at P and O only. This implies that P is a torsion point, a contradiction.