On 03/16/2012 07:06 AM, salah jubeh wrote:
Hello,
When creating a serial, a sequence is created automatically.
CREATE TABLEtablename (
colname SERIAL
);
CREATE SEQUENCE tablename_colname_seq;
CREATE TABLE tablename (
colname integer NOT NULL DEFAULT nextval('tablename_colname_seq')
);
ALTER SEQUENCE tablename_colname_seq OWNED BY tablename.colname;
The OWNED BY is for dependency tracking not privileges:
http://www.postgresql.org/docs/9.1/interactive/sql-altersequence.html
OWNED BY table.column
OWNED BY NONE
The OWNED BY option causes the sequence to be associated with a specific
table column, such that if that column (or its whole table) is dropped,
the sequence will be automatically dropped as well. If specified, this
association replaces any previously specified association for the
sequence. The specified table must have the same owner and be in the
same schema as the sequence. Specifying OWNED BY NONE removes any
existing association, making the sequence "free-standing".
Should not a proper permissions based on the table privileges added to
the sequence ?. For example, when a table has INSERT, UPDATE permissions
on the table to a certain user, this should be taken into account.
Regards
--
Adrian Klaver
adrian.klaver@xxxxxxxxx
--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general