Using regular expression in check : Check « Table Index « SQL / MySQL






Using regular expression in check

       
mysql>
mysql>
mysql> CREATE   TABLE EmployeeS
    ->         (EmployeeNO     INTEGER NOT NULL,
    ->          NAME         CHAR(15) NOT NULL,
    ->          INITIALS     CHAR(3) NOT NULL,
    ->          BIRTH_DATE   DATE,
    ->          SEX          CHAR(1) NOT NULL,
    ->          JOINED       SMALLINT NOT NULL,
    ->          STREET       VARCHAR(30)  NOT NULL,
    ->          HOUSENO      CHAR(4),
    ->          POSTCODE     CHAR(6),
    ->          TOWN         VARCHAR(30) NOT NULL,
    ->          PHONE        CHAR(13),
    ->          LEAGUENO     CHAR(4),
    ->          CONSTRAINT PRIMARY_KEY_EmployeeS
    ->             PRIMARY KEY(EmployeeNO),
    ->          CONSTRAINT JOINED
    ->             CHECK(JOINED > 1969),
    ->          CONSTRAINT POSTCODE_SIX_CHARACTERS_LONG
    ->             CHECK(POSTCODE LIKE '______'),
    ->          CONSTRAINT ALLOWED_VALUES_SEX
    ->             CHECK(SEX IN ('M', 'F')));
mysql>
mysql>

   
    
    
    
    
    
    
  








Related examples in the same category

1.Check date range
2.Value must be from another table