Insert expression asked me to insert for auto-increment column

I am using PostgreSQL, I created the following table:

CREATE TABLE "Task"
(
  "taskID" serial NOT NULL,
  "taskType" text NOT NULL,
  "taskComment" text NOT NULL,
  "taskDate" date NOT NULL,
  CONSTRAINT "Task_pkey" PRIMARY KEY ("taskID")
)

I set taskID as seriala data type that will automatically increase. Now I am confused how to use the operator INSERT, since the first column in the table should grow automatically, but the operator INSERTasked me to insert the value myself! Any idea?

Here is my insert statement:

INSERT INTO "Task" VALUES ('HomeWork', 'No Comment', '3/3/2013');
+5
source share
2 answers

@mvp answer . , () id - . DEFAULT . , "" , .:)

INSERT INTO "Task"("taskID", "taskType", "taskComment", "taskDate")
VALUES (DEFAULT, 'HomeWork', 'No Comment', '2013-03-03');

ISO 8601 (YYYY-MM-DD), . .


, , , PostgreSQL :

CREATE TABLE task (
  task_id serial NOT NULL PRIMARY KEY,
  task_type text NOT NULL,
  task_comment text NOT NULL,
  task_date date NOT NULL
);

INSERT INTO task
VALUES (DEFAULT, 'HomeWork', 'No Comment', '2013-03-03');

:

INSERT INTO task (task_type, task_comment, task_date)
VALUES ('HomeWork', 'No Comment', '2013-03-03');
+10

INSERT, , :

INSERT INTO "Task" (
    "taskType", "taskComment", "taskDate"
) VALUES (
    'abc', 'my comment', '2013-03-17'
)

INSERT, , - , , nextval('some_sequence').

+3

All Articles