Re: default timestamp and default autoinc
От | Edward Q. Bridges |
---|---|
Тема | Re: default timestamp and default autoinc |
Дата | |
Msg-id | 200011081507.eA8F7ps99857@mail.postgresql.org обсуждение исходный текст |
Ответ на | default timestamp and default autoinc ("Jarmo Paavilainen" <jarmo@comder.com>) |
Список | pgsql-general |
On Mon, 6 Nov 2000 15:00:19 +0100, Jarmo Paavilainen wrote: > Hi, > > Does pg have "default timestamp" and "default autoinc" as default values > (used in CREATE TABLE). > here's an example that shows how to default a timestamp and how to use a sequence to auto-increment a primary key column: CREATE SEQUENCE personid_seq; CREATE TABLE person ( person_id INT4 NOT NULL DEFAULT nextval('personid_seq'), create_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, modify_date TIMESTAMP NOT NULL, firstname VARCHAR (128) NOT NULL, lastname VARCHAR (128), PRIMARY KEY (person_id)); CREATE UNIQUE INDEX personid_key ON person(person_id); CREATE TRIGGER trg_modtime BEFORE INSERT OR UPDATE ON person FOR EACH ROW EXECUTE PROCEDURE setmodtime(); the trigger updates the modify_date column, and you could use that as an alternate way of adding a timestamp. > And where is the PostgreSQL reference guide. Or actually/maybe how do I make > html files of the sgml files that are included with the CVS tree (what do I > need, jade? and where do I get it?)? > bash# cd $POSTGRES_SOURCE_TREE/doc bash# gmake install should create man pages and html files for all docs HTH ed
В списке pgsql-general по дате отправления: