  The supersymmetric extension of the standard model suffers from a problem of
baryon-number violation. Discrete (and global) symmetries introduced to protect
the proton are unstable under gravitational effects. We add a gauged $U(1)_X$
to the standard model gauge group $G_{SM}$ and require it to be anomaly-free.
As new (chiral) superfields we only allow $G_{SM}$-singlets in order to
maintain the good unification predictions. We find the most general set of
solutions for the rational singlet charges. We embed our models in {\it local}
supersymmetry and study the breaking of supersymmetry and $U(1)_X$ to determine
$M_X$. We determine the full non-renormalizable and gauge invariant Lagrangian
for the different solutions. We expect any effective theory to contain baryon-
and lepton-number violating terms of dimension four suppressed by powers of
$M_X/M_{Pl}$. The power is predicted by the $U(1)_X$ charges. We find
consistency with the experimental bounds on the proton lifetime and on the
neutrino masses. We also expect all supersymmetric models to have an unstable
but longlived lightest supersymmetric particle. Consistency with underground
experiments on upward going muons leads to stricter constraints than the proton
decay experiments. These are barely satisfied.
