Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Alter Table NOT NULL question
Wed, Aug 4 2010 7:05 AMPermanent Link

Uli Becker

EDB 2.03 Build18 non-unicode
Delphi2010
WIN7

I try to alter a column to "NOT NULL" from NULLABLE:

ALTER TABLE "Scheine"
ALTER COLUMN "SaetzeID" AS INTEGER DEFAULT 1 NOT NULL

and get error

ElevateDB Error #1004 The column SaetzeID in the table Scheine cannot be
NULL

If I remember well I did that before quite some times and the default
value was entered automatically where it was NULL before. Am I wrong?

Uli
Wed, Aug 4 2010 8:03 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Uli


I think DEFAULT only works on new rows so you'll need to populate the column first then alter it.

Roy Lambert [Team Elevate]

Thu, Aug 5 2010 3:30 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Uli,

<< If I remember well I did that before quite some times and the default
value was entered automatically where it was NULL before. Am I wrong? >>

A new DEFAULT clause only works on ADDed columns, not on ALTERed columns.
The reason is that there is no guarantee that someone wants their existing
NULL columns defaulted, simply because they're adding a DEFAULT clause for
new rows.

At some point there will probably be a clause to specify this behavior,
though.

--
Tim Young
Elevate Software
www.elevatesoft.com
Image