Oracle Articles

Submit Article
Home » Articles » Oracle » Data Definition LangRSS Feeds

Example of Create Table

Posted By: Charlie Evans     Category: Oracle     Views: 8726

This article provides an example of how to create table with primary key , foreign key, check, unique and not null constrains.

Code for Example of Create Table in Oracle

Example 1 :

createtable cust
(custno varchar2(5) primarykey,    
 cname varchar2(20) unique,
 state varchar2(10),
 phone number(10),
constraint  st check(statein ('Gujarat','Rajasthan','MP','UP','Maharastra')));

Example 2 :

createtable item
(itemno varchar2(5) primarykey,
 itemname varchar2(20) notnull,
 itemprice number(8,2),
 Qty_hand number(3),
constraint itp check(itemprice>0));

Example 3 :

createtable invoice
(invno number(4) primarykey,
 invdate date,
 custno varchar2(5) references cust);

Example 4 :

createtable invitem
(invno varchar2(5) references invoice,
 Itemno varchar2(5) references item,
 qty number(3),);

Didn't find what you were looking for? Find more on Example of Create Table Or get search suggestion and latest updates.

Charlie Evans
Charlie Evans author of Example of Create Table is from London, United Kingdom.
View All Articles

Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

No Comment Found, Be the First to post comment!