2
I would like to know how to set an Insert pattern in a column in SQL.
Example:
CREATE TABLE XPTO(
ID INT IDENTITY(1,1),
NOME VARCHAR(100) NOT NULL,
ATIVO CHAR(1) NOT NULL)
In this case, I want to limit the ACTIVE field to receive only values of’S' or 'N'.
Thank you
It would not be the same that was informed by Ricardo Punctual?
– Luiz Martinez
@Luizmartinez: Yes, Ricardo also suggested the use of the CHECK restriction. The difference is only the form: he suggested it through the ALTER TABLE command and I suggested it directly in the table definition. The final result is the same. // When the table already exists, the method of making changes to the tables is via the ALTER TABLE command.
– José Diz
I understood, it was what I suspected, as here the fields already exist, I will have to use the Alter Table, but thank you for the suggestion, I will keep it in the sleeve for another need.
– Luiz Martinez