Advertisement
shawonrog

Untitled

Apr 7th, 2019
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. drop TABLE orderp;
  2. drop TABLE orderItem;
  3. drop TABLE customer;
  4. drop TABLE item;
  5.  
  6. CREATE TABLE customer(
  7. custid INT PRIMARY KEY,
  8. cNAME varchar(20),
  9. city varchar(20)
  10. );
  11.  
  12. CREATE TABLE orderp(
  13. orderid INT PRIMARY KEY,
  14. oDate DATE,
  15. custid INT,
  16. oAmount INT,
  17. FOREIGN KEY (custid) REFERENCES customer(custid)
  18. );
  19.  
  20. CREATE TABLE item(
  21. itemid INT PRIMARY KEY,
  22. unitPrice INT
  23. );
  24.  
  25. CREATE TABLE orderItem(
  26. orderid INT,
  27. itemid INT,
  28. quant INT,
  29. FOREIGN KEY (itemid) REFERENCES item(itemid)
  30. );
  31.  
  32. Insert into customer(custid,cNAME,city) values(11,'shobha','Dhaka');
  33. Insert into customer(custid,cNAME,city) values(12,'shilpa','Jessore');
  34. Insert into customer(custid,cNAME,city) values(13,'sameera','Khulna');
  35. Insert into customer(custid,cNAME,city) values(14,'Shuvo','Bagerhat');
  36. Insert into customer(custid,cNAME,city) values(15,'salam','Valuka');
  37.  
  38. Insert into item(itemid,unitPrice) values(33,100);
  39. Insert into item(itemid,unitPrice) values(10,150);
  40. Insert into item(itemid,unitPrice) values(3,140);
  41. Insert into item(itemid,unitPrice) values(11,100);
  42. Insert into item(itemid,unitPrice) values(22,101);
  43.  
  44. Insert into orderp(orderid,oDate,custid,oAmount) values(21,'12-JAN-02',11,1000);
  45. Insert into orderp(orderid,oDate,custid,oAmount) values(22,'12-JAN-02',12,2000);
  46. Insert into orderp(orderid,oDate,custid,oAmount) values(23,'02-JAN-02',11,3000);
  47. Insert into orderp(orderid,oDate,custid,oAmount) values(24,'12-FEB-02',13,4000);
  48. Insert into orderp(orderid,oDate,custid,oAmount) values(25,'12-JAN-02',13,5000);
  49.  
  50. select * from orderp;
  51.  
  52. Insert into orderItem(orderid,itemid,quant) values(21,33,3);
  53. Insert into orderItem(orderid,itemid,quant) values(22,10,2);
  54. Insert into orderItem(orderid,itemid,quant) values(23,3,5);
  55. Insert into orderItem(orderid,itemid,quant) values(24,11,4);
  56. Insert into orderItem(orderid,itemid,quant) values(25,22,7);
  57.  
  58. select * from orderItem;
  59.  
  60. alter table item add color varchar(20);
  61.  
  62. describe item;
  63.  
  64. alter table item modify unitPrice int default 1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement