Обсуждение: ALTER TABLE ALTER COLUMN in view

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

ALTER TABLE ALTER COLUMN in view

От
"luiz"
Дата:
Hi all,

I have a scenario like follow (script generated with pg_dump) :

CREATE TABLE teste (   id integer NOT NULL,   ds character varying(20),   n2 character varying(10)
);

CREATE SEQUENCE teste_id_seq   INCREMENT BY 1   NO MAXVALUE   NO MINVALUE   CACHE 1;

ALTER TABLE teste ALTER COLUMN id SET DEFAULT nextval('teste_id_seq'::regclass);

ALTER TABLE ONLY teste   ADD CONSTRAINT pk_teste PRIMARY KEY (id);


ALTER SEQUENCE teste_id_seq OWNED BY teste.id;

CREATE VIEW vteste AS   SELECT teste.id, teste.ds, teste.n2 FROM teste;


ALTER TABLE vteste ALTER COLUMN id SET DEFAULT nextval('teste_id_seq'::regclass);


Well this last line make a change on a view column and it works.
I do it because when inserting a row in the view vteste, I got a message error
like "teste.id does not accept NULL values"

Searching in the internet, I found a message where Tom Lane suggest to do this.
Well, I don´t found anything in Postgresql manual saying that we can do it in
views, but I don´t found anything saying that we don´t must do it too.
Since pg_dump generates the script with this definition, I think that they
must be supported by PostgreSQL

The only thing that I have a objection is because this don´t appear in pgadmin
views definition. And we don´t mind that this "ALTER COLUMN" exists in the
Database structure.

I want to request/suggest that views script generates a complete script in the
sqlpane like when select a table (with index,triggers creation sql scripts) or
with at least this DDL, since we can´t see it anywhere. 

May we have a icon for this alter columns in the view definition tree too ?

I´m using pgAdmin 1.6.3 in a winXP pro SP2 with Postgresql 8.2.4

Thanks in Advance

Luiz



Re: ALTER TABLE ALTER COLUMN in view

От
Dave Page
Дата:
luiz wrote:
> Hi all,
> 
> I have a scenario like follow (script generated with pg_dump) :
> 
> CREATE TABLE teste (
>     id integer NOT NULL,
>     ds character varying(20),
>     n2 character varying(10)
> );
> 
> CREATE SEQUENCE teste_id_seq
>     INCREMENT BY 1
>     NO MAXVALUE
>     NO MINVALUE
>     CACHE 1;
> 
> ALTER TABLE teste ALTER COLUMN id SET DEFAULT nextval('teste_id_seq'::regclass);
> 
> ALTER TABLE ONLY teste
>     ADD CONSTRAINT pk_teste PRIMARY KEY (id);
> 
> 
> ALTER SEQUENCE teste_id_seq OWNED BY teste.id;
> 
> CREATE VIEW vteste AS
>     SELECT teste.id, teste.ds, teste.n2 FROM teste;
> 
> 
> ALTER TABLE vteste ALTER COLUMN id SET DEFAULT nextval('teste_id_seq'::regclass);
> 
> 
> Well this last line make a change on a view column and it works.
> I do it because when inserting a row in the view vteste, I got a message error
> like "teste.id does not accept NULL values"
> 
> Searching in the internet, I found a message where Tom Lane suggest to do this.
> Well, I don´t found anything in Postgresql manual saying that we can do it in
> views, but I don´t found anything saying that we don´t must do it too.
> Since pg_dump generates the script with this definition, I think that they
> must be supported by PostgreSQL
> 
> The only thing that I have a objection is because this don´t appear in pgadmin
> views definition. And we don´t mind that this "ALTER COLUMN" exists in the
> Database structure.
> 
> I want to request/suggest that views script generates a complete script in the
> sqlpane like when select a table (with index,triggers creation sql scripts) or
> with at least this DDL, since we can´t see it anywhere. 
> 
> May we have a icon for this alter columns in the view definition tree too ?

Done. Will be in 1.8.0.

Thanks for the suggestions.

Regards, Dave.