Re: simple ALTER TABLE question

From: Aaron [SQL Server MVP] (ten.xoc_at_dnartreb.noraa)
Date: 01/24/05


Date: Mon, 24 Jan 2005 16:55:39 -0500

Right, and the NOT NULL constraint added at column creation time makes sure
that existing insert statements that do *not* include this column will
continue to work (assuming there is a column list, of course) and will not
leave this column with NULL...

-- 
http://www.aspfaq.com/
(Reverse address to reply.)
"Michael C" <me@mine.com> wrote in message
news:OnB5j8lAFHA.1300@TK2MSFTNGP14.phx.gbl...
> Scratch that - the NOT NULL clause he specified takes care of that for
you.
>
> Thanks,
> Michael C#, MCDBA
>
> "Aaron [SQL Server MVP]" <ten.xoc@dnartreb.noraa> wrote in message
> news:exfdA2lAFHA.1452@TK2MSFTNGP11.phx.gbl...
> > > ALTER TABLE ADD COLUMN MyNewField BIT SET DEFAULT 0
> > >
> > > but that doesn't work.
> >
> > Where did you get the SET keyword?  Also, for some reason, COLUMN is not
> > allowed here (but only when ADDing).  Finally, you should specify
whether
> > the column allows NULLs or not.  If you want existing rows to have 0,
and
> or
> > existing insert statements to populate the default value, Try:
> >
> > ALTER TABLE tablename ADD MyNewField BIT NOT NULL DEFAULT 0
> >
> > A
> >
> >
>
>


Relevant Pages

  • Re: Difference between semivowel and consonant
    ... would seem to specify only how the tongue is oriented relative to the ... than there is such a constraint on its fricative counterpart SAMPA ... So there is an implicit contraint to the position of the lips? ... there are many examples both of vowels and of consonants undergoing ...
    (sci.lang)
  • Re: Default value: ISNULL()
    ... You can create a default constraint to specify a default value for a column. ... Col1 int NOT NULL, ... > ISNULL() as a default value to avoid NULL entries when importing data ...
    (comp.databases.ms-sqlserver)
  • Re: OReilly interview with Date
    ... >>OK but if you have to specify the foreign key, ... constraint for every join you might want to do, ... (How many other salespersons have total ...
    (comp.databases.theory)
  • Re: what are keys and surrogates?
    ... never mind manipulation of ASTs. ... avoid the need to introduce lots of meaningless identifiers. ... specify a constraint on a variable, ...
    (comp.databases.theory)
  • Re: Pythonic use of CSV module to skip headers?
    ... Michael> cumbersome idiom every single time. ... In my example I flubbed and failed to specify the delimiter to the ... You can create a subclass of DictReader that plucks the first line out as a ...
    (comp.lang.python)

Quantcast