My Problem is to make the Column email NOT NULL AND UNIQUE
ALTER TABLE benutzer ADD email VARCHAR(75) UNIQUE;
works fine but
ALTER TABLE benutzer ADD email VARCHAR(75) UNIQUE NOT NULL;
or
ALTER TABLE benutzer ADD email VARCHAR(75) UNIQUE ,NOT NULL;
work not fine :-(
the error is:
FEHLER: Syntaxerror by „NULL“
I don't understand the Problem from Postgresql >.<
EDIT:
I have solve the Problem. The Solution for my Problem is to delete the records in my Table.
It is not possible to add a new column that is both UNIQUE and NOT NULL at the same time, when it contains existing records.
The reason for this is due to the fact that adding a column gives it null values to start with, and simultaneously saying there are not allowed to nulls is a contradiction.
OR
OR
for reference another answer with more info: Create unique constraint with null columns
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With