Constraints Tutorial

List of Constraints in MySql :

1) NOT NULL

2) UNIQUE

3) DEFAULT

4) CHECK

5) FOREIGN KEY

6) PRIMARY KEY


CREATE TABLE table_name(

id INT NOT NULL UNIQUE,

name VARCHAR(50) NOT NULL,

age INT NOT NULL CHECK(age >= 18),

gender VARCHAR(10) NOT NULL,

phone VARCHAR(10) NOT NULL UNIQUE,

city VARCHAR(10) NOT NULL DEFAULT "Agra");

Comments

Popular posts from this blog

Ajax Insert Records in Database Tutorial in PHP

SubQuery with EXISTS and NOT EXISTS in PHP

Submitting HTML Form data in JSON File (without MySql Database) in PHP