I created a table
CREATE TABLE street (
id SERIAL PRIMARY KEY NOT NULL,
street_name CHAR (30) NOT NULL,
city_id INTEGER REFERENCES city,
building_number CHAR(10));
after that I insert some data:
INSERT INTO street (street_name, city_id) VALUES ('Sumskaya', 1);
The data was added with id=1. Then I insert next data
INSERT INTO street (street_name, city_id) VALUES ('Sumskaya', 10);
and get the error
Key (city_id)=(10) is not present in table "city".
I changed my insert data
INSERT INTO street (street_name, city_id) VALUES ('Sumskaya', 2);
and get a row in the table with id = 3. Id = 2 is missing. Why serial assigned the value 3, not 2 and how to change it?