You could use a check constraint, or a foreign key.
Check constraint:
alter table brands add country_name varchar(64) not null; alter table brands add constraint ck_country_list check (country_name in ('Japan', 'New Zealand', 'US', 'France'));
With a check constraint, the values that are allowed never change (unless you change the constraint code). With a foreign key, the allowed values are stored in another table. As long as the value exists in the other table, they are allowed in this table.
create table countries(country_name varchar(64) not null primary key); insert countries (country_name) values ('France'), ('New Zealand') -- etc alter table brands add country_name varchar(64) not null; alter table brands add constraint fk_brands_countries foreign key (country_name) references countries (country_name);
But we can actually do even better that! Countries already have a well defined "thing" which uniquely identifies them: ISO3166 country codes. You can use the 2 char, 3 char, or int versions. Using well defined standards where you can is always a good idea for primary keys.
This is the next level up beyond what you are currently trying to learn. But here's what it might look like:
create table countries ( country_code char(2) not null primary key clustered, country_name varchar(64) not null ); insert countries (country_code, country_name) values ('FR', 'France'), ('NZ', 'New Zealand') -- etc etc; alter table brands add country_code char(2) not null; alter table brands add constraint fk_brands_countries foreign key (country_code) references countries (country_code);
When you want to get the country name, you join the brands table to the countries table using the country_code column.
check constraintwith anINstatement with the allowed values. See: learn.microsoft.com/en-us/sql/relational-databases/tables/…