Is lim R_i = O(colim Spec R_i) true for finite (co)limits? $\DeclareMathOperator{\colim}{colim}
\DeclareMathOperator{\Spec}{Spec}$
[Edit1] I should point out that the colimits below are in the category of schemes, since the statements are trivially false for colimits in the category of affine schemes. [/Edit1]
In this answer Martin points out that $\coprod_i \Spec R_i \ne \Spec \prod_i R_i$ in general. This also proves for
$$ \colim_{i \in I} \Spec R_i \ne \Spec \lim_{i \in I} R_i. $$
(Though taking a non-affine scheme, and writing it as colimit of affines might even be a more 'natural' proof.) Now I wondered if what happens if we take global sections on both sides, i.e.,
$$ \mathcal{O}(\colim_{i \in I} \Spec R_i) \stackrel{?}{=} \lim_{i \in I} R_i. $$
For several (co)limits, I verified this is true. And actually there is a natural map from right to left. 
But is this map
$$ \lim_{i \in I} R_i \to \mathcal{O}(\colim_{i \in I} \Spec R_i) $$
an isomorphism:


*

*when $I$ is finite?

*if so, when $I$ is small?

 A: We have an equivalence of categories $Aff\simeq Ring^{op}$ and a pair of adjoint functors $$\mathcal{O}:Sch\rightleftharpoons Ring^{op} : Spec$$ $$\mathcal{O} \dashv Spec$$
The category of affine schemes is clearly a full subcategory of $Sch$. This leads us to reformulation of the previous statement: the inclusion of full subcategory $J:Aff\hookrightarrow Sch$ has a left adjoint $L=Spec\circ \mathcal{O}$. So $Aff$ is a reflective subcategory of $Sch$. Your question is then about the isomorphism $$\mathrm{colim}_i A_i \simeq L(\mathrm{colim}_i J(A_i))$$
This is true, because for a reflective subcategory $L\circ J \simeq 1$ (see, for example, Maclane's book) and left adjoints ($L$) commute with colimits.
$$\mathrm{colim}_i A_i \simeq \mathrm{colim}_i LJ(A_i) \simeq L(\mathrm{colim}_i J(A_i))$$
It is an isomorphism whenever any mentioned colimit exists, it also defines then all other mentioned colimits.
A: Some additions:
It is rather rare that a diagram of schemes has a colimit in the category of schemes - even if all schemes in the diagram are affine. For a nice counterexample, see here. Positive examples include: Coproducts, as well as pushouts along open immersions (this is the usual gluing procedure), but also along closed immersions (see Karl Schwede's paper, and for more results in this direction see this MO discussion). In general, it is quite hard to prove that some diagram of schemes has no colimit (because it is not enough to show that the colimit in the larger categry of locally ringed spaces (or algebraic spaces or alike) is no scheme); but in any event, the functor $\mathcal{O} : \mathrm{Sch} \to \mathrm{Ring}^{op}$ is left adjoint to $\mathrm{Spec}$ and therefore preserves all colimits which exist in $\mathrm{Sch}$, no matter how they look like.
For exmaple, if the colimit $X$ of the sequence of closed immersions $\mathbb{A}^0 \hookrightarrow \mathbb{A}^1 \hookrightarrow \mathbb{A}^2 \hookrightarrow \dotsc$ exists, then we have $\mathcal{O}(X) = \mathrm{lim}_n ~ k[x_1,\dotsc,x_n]$. It is still an open question whether $X$ exists (but not really relevant for algebraic geometers because as soon as no colimit is available in first sight, they use ind-schemes instead).
Other MO-questions about colimits of schemes which illustrate the problems:


*

*GIT quotients vs. LRS coequalizers

*Are coequalizers local?

*Are coequalizers surjective?
