Answer the question
In order to leave comments, you need to log in
Why does postgre sql require to enter key field values during INSERT?
valid request
INSERT INTO abonents
VALUES ('Petrov', 'Pobeda 9, 1', '8909999231')
Answer the question
In order to leave comments, you need to log in
It does not require a key field, but just a field. With INSERT without specifying the names of the fields, it is necessary to transfer values for all columns to VALUES.
and so that without instructions it would be possible to add like this - is it possible to do it?
INSERT INTO abonents
VALUES (DEFAULT, 'Petrov', 'Pobeda 9, 1', '8909999231')
It is possible without DEFAULT, you should only list the names of the columns that you insert:
CREATE TABLE abonents (
id serial,
name varchar(64),
address varchar(64),
phone varchar(64)
);
INSERT INTO abonents (name, address, phone) VALUES ('Petrov', 'Pobeda 9, 1', '8909999231');
SELECT * FROM abonents;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question