You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by Bryan Pendleton <bp...@amberpoint.com> on 2005/09/08 23:27:39 UTC

Does Derby support ALTER TABLE DROP COLUMN?

I tried

   alter table my_table drop column my_column;

and I got:

   ERROR 42X01: Syntax error: Encountered "drop" at line 4, column 27.

Do I have a syntax error? Or does Derby simply not support
dropping columns from an existing table?

thanks,

bryan


Re: Does Derby support ALTER TABLE DROP COLUMN?

Posted by Rick Hillegas <Ri...@Sun.COM>.
Hi Bryan,

Derby supports adding but not dropping columns. An enhancement request 
(396) has been filed on this issue.

Regards,
-Rick

Bryan Pendleton wrote:

> I tried
>
>   alter table my_table drop column my_column;
>
> and I got:
>
>   ERROR 42X01: Syntax error: Encountered "drop" at line 4, column 27.
>
> Do I have a syntax error? Or does Derby simply not support
> dropping columns from an existing table?
>
> thanks,
>
> bryan
>


Questions about Derby (was Re: Does Derby support ALTER TABLE DROP COLUMN?)

Posted by "Jean T. Anderson" <jt...@bristowhill.com>.
Dheeraj wrote:
> ...
> I want to information about alter a table !!

The ALTER TABLE command is documented at
http://db.apache.org/derby/docs/10.1/ref/rrefsqlj81859.html .

> Like change column name or increase/ decrease the size of a column  !!

As the link above explains, you can increase the size of column, but not
decrease it. But there are some restrictions that are being addressed by
 DERBY-396 (http://issues.apache.org/jira/browse/DERBY-396) .

> I want to information about how can I see the structure of a table through a
> query or etc.
> 
> i.e how many columns currently present in a table  what their size & data type !!

Derby's 'dblook' utility outputs the DDL for objects in a database:

http://db.apache.org/derby/docs/10.1/tools/ctoolsgenddldb.html

DERBY-1164 (http://issues.apache.org/jira/browse/DERBY-1164) is a
feature request to add functionality to ij to output information.

Also, some of the GUI tools listed on the Wiki page below provide nice
viewing of database objects:

http://wiki.apache.org/db-derby/UsesOfDerby#ProductsByType

> Please give me list of what data type are convert to other data type !!

A table that shows which types can be explicitly converted ("cast") to
another is in the SQL Reference Guide:

http://db.apache.org/derby/docs/10.1/ref/rrefsqlj33562.html

And this page summarizes the data types that can be used for comparison,
sorting and ordering expressions:

http://db.apache.org/derby/docs/10.1/ref/rrefsqlj58560.html


>  ...
> Pls give me these information about Apache Derby !!

Much of the information you are looking for is available in the Derby
manuals, which you can access from the Derby web site:

http://db.apache.org/derby/manuals

I hope this helps.

regards,

 -jean


Re: Does Derby support ALTER TABLE DROP COLUMN?

Posted by Dheeraj <dh...@daffodildb.com>.

Hi !!

 

I m Dheeraj  !!

May u help me about problem which is occur at time of using Apache Derby  !!

I m using Apache Derby Data Base for my project .

I want to information about alter a table !!

Like change column name or increase/ decrease the size of a column  !!

I want to information about how can I see the structure of a table through a
query or etc.

i.e how many columns currently present in a table  what their size & data type !!

 

Please give me list of what data type are convert to other data type !!

e.g 

varchar to bigint are convertible or not !!

bigint to varchar are convertible or not !!

These kind of list !!

 

Pls reply quickly as early as possible !!

 

Pls give me these information about Apache Derby !!

 

Bye !!



Re: Does Derby support ALTER TABLE DROP COLUMN?

Posted by "Michael J. Segel" <ms...@segel.com>.
On Friday 09 September 2005 09:22, Rick Hillegas wrote:
> Derby does have a RENAME TABLE command.
>
> Cheers,
> -Rick
>
Perfect.

If you were to enhance the Alter Table to allow for a DROP COLUMN foo, then 
you'd rename the existing table to a temp name, rebuild the table with all of 
the columns except the one that you're dropping, add all the constraints and 
indexes... then reload the new table and drop the temp.

Of course I'm probably missing something....

-- 
Michael Segel
Principal
MSCC
(312) 952-8175

Re: Does Derby support ALTER TABLE DROP COLUMN?

Posted by Rick Hillegas <Ri...@Sun.COM>.
Derby does have a RENAME TABLE command.

Cheers,
-Rick

Michael J. Segel wrote:

>On Thursday 08 September 2005 20:09, wolfgang127us@yahoo.co.jp wrote:
>  
>
>>Hi Susan,
>>
>>Is there any other way we can drop columns
>>which are not objects you mentioned ?
>>or impossible ?
>>
>>thanks,
>>
>>Wolfgang
>>    
>>
>You could always do a simple work around.
>
>I don't know if you can rename the table, you can always copythe data you want 
>of the table to a temp table. Drop the table, then recreate with the missing 
>column and reload.
>
>Its sort of what the Alter Table would do...
>  
>


Re: Does Derby support ALTER TABLE DROP COLUMN?

Posted by "Michael J. Segel" <ms...@segel.com>.
On Thursday 08 September 2005 20:09, wolfgang127us@yahoo.co.jp wrote:
> Hi Susan,
>
> Is there any other way we can drop columns
> which are not objects you mentioned ?
> or impossible ?
>
> thanks,
>
> Wolfgang
You could always do a simple work around.

I don't know if you can rename the table, you can always copythe data you want 
of the table to a temp table. Drop the table, then recreate with the missing 
column and reload.

Its sort of what the Alter Table would do...
-- 
Michael Segel
Principal
MSCC
(312) 952-8175

Re: Does Derby support ALTER TABLE DROP COLUMN?

Posted by wo...@yahoo.co.jp.
Hi Susan,

Is there any other way we can drop columns 
which are not objects you mentioned ?
or impossible ?

thanks,

Wolfgang



Re: Does Derby support ALTER TABLE DROP COLUMN?

Posted by Susan Cline <ho...@pacbell.net>.
Hi Bryan,
 
You are correct, Derby does not support dropping columns
in the ALTER TABLE statement.
 
The Derby Reference Manual for the ALTER TABLE statement lists PRIMARY KEYS, FOREIGN KEYS and CONSTRAINTS as the only supported objects to drop.
 
Susan

Bryan Pendleton <bp...@amberpoint.com> wrote:
I tried

alter table my_table drop column my_column;

and I got:

ERROR 42X01: Syntax error: Encountered "drop" at line 4, column 27.

Do I have a syntax error? Or does Derby simply not support
dropping columns from an existing table?

thanks,

bryan