TITLE: Is it always possible to write a scheme as a colimit of affine schemes?
QUESTION [18 upvotes]: My question is: Is it possible to write any scheme as a (1-categorical) colimit of a diagram of affines? If no, what are some examples?
I ask this question because I have read that one can write any derived scheme as a colimit (in the $\infty$-categorical sense) over a diagram of affine derived schemes. So I am curious what is the analogous statement is in the classical setting.

REPLY [23 votes]: Yes, this is just a basic fact in category theory, if interpreted correctly. For $C$ any category, and $F$ any preheaf on $C,$ $F$ is the colimit in presheaves of the diagram $C/F \to C \stackrel{y}{\hookrightarrow} Psh(C),$ which sends a morphism $f:y(C) \to F,$ to $y(C),$ where $y$ is the Yoneda embedding. This follows immediately from the Yoneda lemma. Now, if $F$ is a sheaf for some Grothendiek topology, then since the sheafification functor $a$ is a left adjoint, it preserves all colimits, so we also have that $F$ is the colimit of the diagram $C/F \to C \stackrel{y}{\hookrightarrow} Sh(C).$ Note that this diagram consists entirely of representables (provided the Grothendieck topology is subcanonical, i.e. each representable is a sheaf). Now, take $C$ to the the category of affine schemes, and let the Grothendieck topology be the Zariski topology. The functor of points of any scheme, in particular, is a sheaf. The result now follows.

REPLY [10 votes]: Actually, every scheme is the canonical colimit of all affine schemes mapping into it:
$$X = \underset{\substack{U \to X\\U \text{ affine}}}{\mathrm{colim}} U$$
In order to avoid size issues, we can in fact restrict ourselves to open affine subschemes $U \hookrightarrow X$ here. (So the diagram scheme doesn't really depend on the choice of an open affine cover of $X$. But the proof, that $X$ is the colimit, clearly requires such a choice.)
The statement above is equivalent to the statement that the functor of points $\mathsf{Sch} \to [\mathsf{CRing},\mathsf{Set}]$ is fully faithful. In functorial algebraic geometry, one defines $\mathsf{Sch}$ as a certain full subcategory of $[\mathsf{CRing},\mathsf{Set}]$, so in that setting there would be nothing to prove.