Обсуждение: Bug or Feature?

Поиск
Список
Период
Сортировка

Bug or Feature?

От
"Herbert R. Ambos"
Дата:

Hey guys,

 

I found this interesting…

 

 

test=# create table t ( c char);

CREATE TABLE

 

test =# \d t

         Table "public.t"

 Column |     Type     | Modifiers

--------+--------------+-----------

 c      | character(1) |

 

test =# alter table t drop column c;

ALTER TABLE

 

test =# \d t

     Table "public.t"

 Column | Type | Modifiers

--------+------+-----------

 

test =# select * from t;

 

--

(0 rows)

 

test =# create table t2 ();

CREATE TABLE

 

test =# select * from t2;

 

--

(0 rows)

 

 

I mean, we have a table with nothing on it.  Of course this maybe useful if like to check if an object exists in pg_class for some reasons.  But nah… we can have other workarounds for that.  Is this allowed in SQL?

 

 

Thanks,

 

 

herbert


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.542 / Virus Database: 336 - Release Date: 11/18/2003

Re: Bug or Feature?

От
Tom Lane
Дата:
"Herbert R. Ambos" <hrambos@transco.ph> writes:
> [ drops only column of a table ]

> Is this allowed in SQL?

The SQL spec forbids that.  We deliberately decided to ignore the spec
restriction, because it creates too many unpleasant boundary cases for
tools that want to manipulate table definitions.  "DROP COLUMN foo"
shouldn't depend on whether there are other columns besides foo.

In short, yes, it's a feature.
        regards, tom lane