-- creating a table create table Person1(ID int Not Null Unique, LastName varchar(255) NOT NULL, FirstName varchar(255),Age int); insert into Person1(ID, LastName, FirstName, Age)values(101,"Singh","Dheerendra",20); insert into Person1(ID, LastName, FirstName, Age)values(102,"Singh","Dheerendra",20); insert into Person1(ID, LastName, FirstName, Age)values(103,"Singh","Dheerendra",20); insert into Person1(ID, LastName, FirstName, Age)values(104,"Singh","Dheerendra",20); select * from Person1; -- NULL VALUES : By default, a column can hold NULL values. -- The NOT NULL constraint enforces a column to NOT accept NULL values. -- This enforces a field to always contain a value, which means that you cannot -- insert a new record, or update a record without adding a value to this field. ------------------------------------------------ -- deault value using alter table create table employee2(empid int primary key, name varchar(255) unique, address varchar(255), age int default 18 , salary int); insert into employee2(empid, name, address, salary)values(1,"Harsh","Delhi",2000000); insert into employee2(empid, name, address, salary)values(2,"Pratik","Mumbai",2000000); insert into employee2(empid, name, address, salary)values(3,"Akash","Delhi",2000000); insert into employee2(empid, name, address, salary)values(4,"varun","Delhi",2000000); insert into employee2(empid, name, address, salary)values(5,"Harsh2","Delhi",2000000); insert into employee2(empid, name, address, salary)values(6,"Harsh3","Delhi",2000000); select * from employee2; ------ alter table employee2 add column Department varchar(255) default "CSE"; select * from employee2;
To embed this project on your website, copy the following code and paste it into your website's HTML: