Customer table Not null constraint and Unique constraint and Primary key constraint and Supplier and products table Foreign key constraint Person Table Check constraint

 Customer table**

Not null constraint*

create table customers(cid int not null,fname varchar2(10),lname varchar2(10));

insert into customers values('','ram','sony');



Customers table**

Unique constraint*

create table customers(cid int,fname varchar2(10)unique,lname varchar2(10));

insert into customers values('2','rahul','sony');

insert into customers values('1','ram','sony');

insert into customers values('2','ram','raghav');


if you face some problem or error then logout the orcal and after did this code run the this code will work properly

Customer table**

Primary key constraint*

create table customers(cid int primary key,fname varchar2(10),lname varchar2(10));

insert into customers values('2','shyam','jham');

insert into customers values('','shyam','jham');


Supplier and products table**

Foreign key constraint*

CREATE TABLE supplier

( supplier_id numeric(10) not null,

  supplier_name varchar2(50) not null,

  contact_name varchar2(50),

  PRIMARY KEY (supplier_id)

);


CREATE TABLE products

( product_id numeric(10) not null,

  supplier_id numeric(10) not null,

 

    FOREIGN KEY (supplier_id)

    REFERENCES supplier(supplier_id)

);

insert into supplier values(1,'rohan','jony',):

insert into products values(101,1);

insert into supplier values(2,'shyam','jony');

insert into products values(102,2);

insert into supplier values(3,'shy','jha');

insert into products values(103,3);

insert into products values(104,4);

Person Table**
Check constraint*
create table person(pid int not null,fname varchar2(10),lname varchar2(10), age int check(age>=18));
insert into person values(1,'rohan','singh',17);




Comments

Popular Posts