Page 3 :
for more updates visit: www.python4csip.com, , Types of constraints, , , , PRIMARY KEY : ensures unique value in any column, also forces data entry mandatory. Only one primary key, can be applied in one table, , UNIQUE : also allows unique value in any column but it, allows NULL values and can be applied to n times, , NOT NULL : it will make data entry mandatory for, applied column i.e. NULL will not be allowed, , DEFAULT : it allows to specify any value which will be, automatically inserted in applied column if we not, specify applied column at the time of data entry using, INSERT, , VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &, SACHIN BHARDWAJ, PGT(CS), KV NO.a TEZPUR
Page 4 :
for more updates visit: www.python4csip.com, , Types of constraints, , , , CHECK : allows to specify range of values that can be, entered in applied column like salary must be greater, than 2000, marks must be greater than o or dept must, be in given list of values etc., , Note: in mysql the database engine will ignore the, check constraints., , FOREIGN KEY: allows to establish relationship between, 2 tables. Foreign key column will be dependent on, PRIMARY KEY column of another table and allows to, enter only those values in foreign key whose, corresponding value exists in PRIMARY KEY, , VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &, SACHIN BHARDWAJ, PGT(CS), KV NO.1 TEZPUR
Page 5 :
for more updates visit: www.python4csip.com, , mysql> create table ABCLtd(empno int primary key, name varchar(2@) not null,, -> dept varchar(2@) default 'marketing', salary int);, Query OK, @ rows affected (@.23 sec), , mysql> insert into ABCLtd values(1, 'Freddy', 'Sales' ,6000@) ;, Query OK, 1 row affected (0.08 sec), , Now lets check PRIMARY KEY is working or not by inserting, , mysql> insert into ABCLtd values(1, 'Albert', 'IT' ,500@@) ;, ERROR 1062 (23000): Duplicate entry '1' for key 'PRIMARY', Now lets check NOT NULL is working or not by inserting, , NULL value in name column, mysql> insert into ABCLtd values(2,NULL, 'IT' ,500@@);, , ERROR 1048 (23000): Column 'name' cannot be null, , VINOD KUMAR VERMA, PGT(CS), KV OEF KANPUR &, SACHIN BHARDWAJ, PGT(CS), KV NO.a TEZPUR