Constraints
CONSTRAINTS
Rules for data in the table
NOT NULL - defines that the column cannot have null value
UNIQUE - all values in that particular column are unique
DEFAULT - sets the value of a column as a default value
CHECK - can limit the values allowed in a column
create database classss;
use classss;
CREATE TABLE users3(name VARCHAR(30) NOT NULL,mails VARCHAR(100) unique, followers INT DEFAULT 100 ,age INT, constraint age_check check(age>=13));
insert into users3 (name,mails,age) VALUES
("abhi","1253@mail",21),
("ash","2153@mail",23),
("bharath","1455@mail",31),
("vinay","495@mail",14);
SELECT * from users3;

Comments
Post a Comment