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.

Help needed to drop column

2 posts in ,  Windows NT Unix Last posting was on 2000-03-02 23:33:38.0Z
rahul bakare Posted on 2000-03-02 22:15:41.0Z
Message-ID: <38BEE80A.857D781F@intervoice.com>
Date: Thu, 02 Mar 2000 16:15:41 -0600
From: rahul bakare <rbakare@intervoice.com>
X-Mailer: Mozilla 4.06 [en] (WinNT; I)
MIME-Version: 1.0
Subject: Help needed to drop column
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Newsgroups: sybase.public.sqlserver.nt,sybase.public.sqlserver.unix
Lines: 8
NNTP-Posting-Host: freeside.intervoice.com 208.200.21.194
Path: forums-1-dub!forums-master.sybase.com!forums.sybase.com
Xref: forums-1-dub sybase.public.sqlserver.nt:2464 sybase.public.sqlserver.unix:268
Article PK: 1089917

Hi,

Can any one help me in this regard...
1.I have a table and would like to drop a column without affecting the
data.
How can I do that ?
2. I have a table and would like to chnage a column from NULL to NOT
NULL
How can I do that ??

Thanks in advance

Rahul


Bret Halford Posted on 2000-03-02 23:33:38.0Z
Message-ID: <38BEFA52.6150FB3E@sybase.com>
Date: Thu, 02 Mar 2000 16:33:38 -0700
From: Bret Halford <bret@sybase.com>
Organization: Sybase, Inc.
X-Mailer: Mozilla 4.5 [en]C-CCK-MCD (WinNT; I)
X-Accept-Language: en,ja
MIME-Version: 1.0
Subject: Re: Help needed to drop column
References: <38BEE80A.857D781F@intervoice.com>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Newsgroups: sybase.public.sqlserver.nt,sybase.public.sqlserver.unix
Lines: 31
NNTP-Posting-Host: bret-pc.sybase.com 157.133.80.211
Path: forums-1-dub!forums-master.sybase.com!forums.sybase.com
Xref: forums-1-dub sybase.public.sqlserver.nt:2463 sybase.public.sqlserver.unix:267
Article PK: 1089916


rahul bakare wrote:

> Hi,
>
> Can any one help me in this regard...
> 1.I have a table and would like to drop a column without affecting the
> data.
> How can I do that ?

Well, you can upgrade to ASE 12.0 and use the new ALTER TABLE DROP
<column> command.
(Don't try it on earlier versions, it is not supported though the syntax
is allowed by the parser - there are bugs in the command that can damage
the data in the table).

Otherwise you have to do something like select all the columns but the one
you are dropping into a new table, drop the original table, rename the new
table to the old table's name, recreate indexes, triggers, procedures
(particularly those that used "select *") related to the original table.



>
> 2. I have a table and would like to chnage a column from NULL to NOT
> NULL
> How can I do that ??

Roughly the same way:

In 12.0, add a new, NOT NULL column (you will have to provide a default
value). Update that column with the contents of the NULLable column, then
drop the NULLable column.

Prior to 12.0: create a new table with the column defined as NOT NULL and
copy all the rows over, then drop the original table, etc.