Constraints and DDL
Constraints and DDL
create table stud(admno int primary key, rollno varchar(20) not null,name
varchar(30) default 'ananthy',phno int unique,m1 int check (m1>50));
Query OK, 0 rows affected (0.27 sec)
Now let us check how DEFAULT constraint to use. (Remember to use
DEFAULT CONSTRAINT, The applied column name will not be used with
INSERT
Default value
‘Marketing’
is
automaticall
y inserted
Create another table to store training details
of employee as-
mysql> create table training(empno int,
trainingname varchar(20),startdate
date, enddate date, constraint myfkey
foreign key(empno) references
ABCLtd(empno));