我的表格
question_id | title | user_id |
+---------------+---------------------------------+----------------+
它的类型有:
Column | Type | Modifiers
---------------------------------------+-----------------------------+-----------------------------------------------------------------
question_id | integer | not null default nextval('questions_question_id_seq'::regclass)
title | character varying(256) |
user_id | integer |
我运行
INSERT INTO questions VALUES (SERIAL, 'question title', 123);
我收到了一个关于使用SERIAL的错误。
如何通过PostgreSQL自动将问题添加到表中并取一个唯一的问题ID?
was_sent_at_time
,我想知道您如何自动将时间添加到新列中。我的尝试不成功,使用了now()
方法和括号中的显式列名:INSERT INTO questions(title, user_id, wast_sent_at_time) VALUES ('Lorem Ipsun.', 123, now())
。您如何将时间也添加到表中? - Léo Léopold Hertz 준영