Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

How to alter table to modify a column to have a default value?

3 posts in General Discussion Last posting was on 2009-10-21 09:47:53.0Z
lmike Posted on 2009-10-20 16:15:37.0Z
From: lmike <lmike3000@gmail.com>
Newsgroups: sybase.public.ase.general
Subject: How to alter table to modify a column to have a default value?
Date: Tue, 20 Oct 2009 09:15:37 -0700 (PDT)
Organization: http://groups.google.com
Lines: 13
Message-ID: <1c0f98ec-cb8c-4420-81b1-2e2609f2f4ab@p15g2000vbl.googlegroups.com>
NNTP-Posting-Host: 64.22.160.1
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
X-Trace: posting.google.com 1256055337 1750 127.0.0.1 (20 Oct 2009 16:15:37 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Tue, 20 Oct 2009 16:15:37 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: p15g2000vbl.googlegroups.com; posting-host=64.22.160.1; posting-account=aUSKYQoAAADzh29G-Vsuu6ugCKQ6EqCS
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.7) Gecko/2009040909 CentOS/3.0.7-1.el5.centos Firefox/3.0.7,gzip(gfe),gzip(gfe)
Path: forums-1-dub!forums-master!newssvr.sybase.com!news-sj-1.sprintlink.net!news-peer1.sprintlink.net!newsfeed.yul.equant.net!news-raspail.gip.net!news.gsl.net!gip.net!aotearoa.belnet.be!news.belnet.be!newsfeed.kpn.net!pfeed09.wxs.nl!feeder3.cambriumusenet.nl!feed.tweaknews.nl!postnews.google.com!p15g2000vbl.googlegroups.com!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:28512
Article PK: 77754

I have a table named "MyTableA", and it has this column "last_updated"
of type datetime
last_updated datetime 8 NULL NULL 0 NULL ... ...

How do I modify it to have a default?
I tried this but got an error;

>alter table Preferences_blob modify last_updated datetime default getdate() null;
Msg 156, Level 15, State 2
Server 'DBAOPS4', Line 1
Incorrect syntax near the keyword 'default'.

Thanks,


"Mark A. Parsons" <iron_horse Posted on 2009-10-20 16:49:47.0Z
From: "Mark A. Parsons" <iron_horse@no_spamola.compuserve.com>
User-Agent: Thunderbird 1.5.0.10 (Windows/20070221)
MIME-Version: 1.0
Newsgroups: sybase.public.ase.general
Subject: Re: How to alter table to modify a column to have a default value?
References: <1c0f98ec-cb8c-4420-81b1-2e2609f2f4ab@p15g2000vbl.googlegroups.com>
In-Reply-To: <1c0f98ec-cb8c-4420-81b1-2e2609f2f4ab@p15g2000vbl.googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Antivirus: avast! (VPS 091014-0, 10/14/2009), Outbound message
X-Antivirus-Status: Clean
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4addea2b$1@forums-1-dub>
Date: 20 Oct 2009 09:49:47 -0700
X-Trace: forums-1-dub 1256057387 10.22.241.152 (20 Oct 2009 09:49:47 -0700)
X-Original-Trace: 20 Oct 2009 09:49:47 -0700, vip152.sybase.com
Lines: 26
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:28513
Article PK: 77755

Looks like you're trying to perform 2 operations:

1 - change nullability from NOT NULL to NULL

alter table Preferences_blob modify last_updated datetime null

2 - change the column's default to getdate()

alter table Preferences_blob replace last_updated default getdate()

lmike wrote:
> I have a table named "MyTableA", and it has this column "last_updated"
> of type datetime
> last_updated datetime 8 NULL NULL 0 NULL ... ...
>
> How do I modify it to have a default?
> I tried this but got an error;
>
>> alter table Preferences_blob modify last_updated datetime default getdate() null;
> Msg 156, Level 15, State 2
> Server 'DBAOPS4', Line 1
> Incorrect syntax near the keyword 'default'.
>
> Thanks,


Carl Kayser Posted on 2009-10-21 09:47:53.0Z
From: "Carl Kayser" <kayser_c@bls.gov>
Newsgroups: sybase.public.ase.general
References: <1c0f98ec-cb8c-4420-81b1-2e2609f2f4ab@p15g2000vbl.googlegroups.com>
Subject: Re: How to alter table to modify a column to have a default value?
Lines: 27
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3598
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3350
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4aded8c9@forums-1-dub>
Date: 21 Oct 2009 02:47:53 -0700
X-Trace: forums-1-dub 1256118473 10.22.241.152 (21 Oct 2009 02:47:53 -0700)
X-Original-Trace: 21 Oct 2009 02:47:53 -0700, vip152.sybase.com
X-Authenticated-User: ase1251
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:28515
Article PK: 77757


"lmike" <lmike3000@gmail.com> wrote in message
news:1c0f98ec-cb8c-4420-81b1-2e2609f2f4ab@p15g2000vbl.googlegroups.com...
>I have a table named "MyTableA", and it has this column "last_updated"
> of type datetime
> last_updated datetime 8 NULL NULL 0 NULL ... ...
>
> How do I modify it to have a default?
> I tried this but got an error;
>
>>alter table Preferences_blob modify last_updated datetime default
>>getdate() null;
> Msg 156, Level 15, State 2
> Server 'DBAOPS4', Line 1
> Incorrect syntax near the keyword 'default'.
>
> Thanks,

The following may do it although my 12.5 doc doesn't allow for a builtin
default like getdate (). (I believe that I've done this with getdate () on
12.5.3.) Whether it works may depend upon your (unspecified) server
version.

alter table Preferences_blob replace last_updated_datetime default getdate
()