An example of a Ring with many zero divisors

Is there an example of a commutative ring $R$ with identity such that all its elements distinct from $1$ are zero-divisors?

I know that in a finite ring all the elements are units or zero-divisors. Is there a finite ring with the property I've required?

Obviosuly I'm requiring that $|R|\geq 3$.


What about all functions from $\mathbb Z$ to $\mathbb Z/2\mathbb Z$? It's a ring using addition and multiplication of $\mathbb Z/2\mathbb Z$. The identity is the function $f(x)=\overline 1$ $\forall$ $x$. Every other function is obviously a zero divisor.


Hint $\ $ If $\,1\,$ is the only unit then $\,-1 = 1\,$ so the ring is an algebra over $\,\Bbb F_2.\,$ With that in mind, it is now easy to construct many examples.

Such commutative rings - where every element $\ne 1$ is a zero-divisor - were called $0$-rings by Paul M. Cohn. Clearly they include Booolean rings, i.e. rings where every element is idempotent $\,x^2-x,\,$ since then $\,x(x-1) = 0.\,$ Kaplansky asked about the existence of non-Boolean $0$-rings. Paul M. Cohn answered the question in Rings of Zero-divisors. There he gave a simple proof that every commutative ring R can be embedded in a commutative ring S such that every element is either a unit of R or a zero-divisor (and if R is an algebra over a field F then so is S). The proof shows further that every proper ideal of R survives (remains proper) in S, with nontrivial annihilator. Cohn then proceeded to prove

${\bf Theorem\ 3\,\ }$ Let $R\,$ be an algebra over $F$ in which every element not in $F$ is a zero-divisor. Then $R$ is a subdirect product of extension fields of $F,\,$ and every $\,x\in R\,$ which is not in $\,F\,$ is transcendental over $F$, except if $\,F = \Bbb F_2$ and $\,x\,$ is idempotent. Moreover, if $R$ has finite dimension over $F$ then either $R=F$ or $R\,$ is a Boolean algebra.


In any boolean ring (with identity), the only unit is the identity.

So in particular, $\prod_{i\in I} F_2$ for any nonempty index set $I$, and the field of two elements $F_2$. In fact, any subring (with identity) of such a ring will work.


Yet another ring isomorphic to Gregory's answer which I find worth mentioning: $$(\mathcal{P}(\mathbb{Z}), \Delta, \cap),$$ where $\Delta$ is symmetric difference. Not surprisingly, $\mathbb{Z}$ can be replaced with any set.