B
B
Black back2019-12-16 11:22:14
PostgreSQL
Black back, 2019-12-16 11:22:14

How to check when inserting into a table for example if psql?

How can I check when inserting into a table, for example, if
I want to insert only words into the work column - 'registrar' , 'coordinator', 'user'
how can I do (

create table person (
id serial,
name varhcar(30) not null check( name='registrator' and 'coordinator' or 'user' )

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrew, 2019-12-16
@bekss

CREATE TABLE qna
(
  name VARCHAR(30) NOT NULL CHECK (name IN ('registrator', 'coordinator', 'user'))
);

sqlfiddle.com/#!15/90730

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question