Re: how to create secondary key!! - Mailing list pgsql-novice

From Josh Berkus
Subject Re: how to create secondary key!!
Date
Msg-id web-1801250@davinci.ethosmedia.com
Whole thread Raw
In response to how to create secondary key!!  ("Nelson Yong" <nelsonyong@ipmuda.com.my>)
List pgsql-novice
Nelson,

> I appriciate u reply, thank u.
>
> I try the sql statement which u commented then how to solve not null
> problem.
>
> ALTER TABLE king ADD CONSTRAINT king_PK
> PRIMARY KEY (vb1, vb2);
>
> Error hit during execute this command
> Number: -2147467259
>
> Description: Error while executing the query;
> ERROR:  Existing attribute "vb1" cannot be a PRIMARY KEY because it
> is
> not marked NOT NULL
> ---------------------------
> OK
> ---------------------------
>
> i try to use command below but no function, kindly command.
>
> ALTER TABLE table_name
>    ALTER COLUMN column_name INT NOT NULL

Regrettably, this function of the ALTER TABLE command is currently not
supported in PostgreSQL.   In order to mark a column as NOT NULL, you
must:
1) make sure to remove all NULLs from the column, and
2) modify the system tables to set the column NOT NULL.

Hopefully someone will post more detailed instructions on step 2), as I
cannot remember them right now.

-Josh




pgsql-novice by date:

Previous
From: "Chad Thompson"
Date:
Subject: Re: Select case
Next
From: Sigurdur Helgason
Date:
Subject: How to dynamically call a column in plpgsql