Really new to SQL. I’m having some issues figuring out a constraint’
Here's what I want to do. I have a table with 2 columns CampusID
and Location
. I want a constraint that each element of the CampusID
must be 'UMS' followed by two digits. Not sure how to code this. This is what I have done. I am using SQL Fiddle to do this.
CREATE TABLE IF NOT EXISTS Campuses(
CampusID varchar(16) Primary Key,
Location varchar(16) NOT NULL,
CONSTRAINT CampusID Check CampusID LIKE (UMS[0-9]0-9]),
);
INSERT INTO Campuses VALUES
(“UMS01”,“Augusta”),
(“UMS02”,“Farmington”),
(“UMS03”,“Fort Kent”),
(“UMS04”,“Machais”),
(“UMS05”,“Orono”),
(“UMS06”,“Presque Isle”),
(“UMS07”,“Southern Maine”);