Answer the question
In order to leave comments, you need to log in
Assign unique value to two columns?
In short, I want to create a database with columns id, name, tel, mail, txt
At the same time, so that id is filled in automatically when a new row is added, and most importantly, a duplicate value cannot be added to the name column , that is, if the name table already has a row named vasy1 , then a row with the same value in that column could not be added.
I tried to do this, but it gives an error:
CREATE TABLE `book` (
`id` INTEGER AUTOINCREMENT NOT NULL,
`name` TEXT NOT NULL,
`site` TEXT NULL,
`tel` TEXT NULL,
`mail` INTEGER NULL,
`txt` TEXT NULL,
PRIMARY KEY(id,name)
);
Answer the question
In order to leave comments, you need to log in
https://www.techonthenet.com/sqlite/unique.php
CREATE TABLE employees
( employee_id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR NOT NULL,
first_name VARCHAR,
hire_date DATE,
CONSTRAINT name_unique UNIQUE (last_name, first_name)
);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question