I am creating the table in MySQL and want to CHECK the syntax of the date. It should be 'YYYY-MM-DD'. When I insert data into this table it should give me error when I type something else when inserting the date, e.g. Insert into Member(DoB) values('2013-120qw'). It should be only for instance '2013-12-04'.
Here is my table:
CREATE TABLE Member(
email VARCHAR(100) NOT NULL,
name VARCHAR(100) NOT NULL,
DoB TEXT(10) NOT NULL CHECK (length(DoB) IN (10) AND date(DoB) BETWEEN date('1900-01-01') AND date(CURRENT_DATE)),
telephone VARCHAR(11) NOT NULL CHECK (length(telephone) IN (11)),
PRIMARY KEY (email)
);
Aucun commentaire:
Enregistrer un commentaire