Advertisement
netx_iit

DDL (Account_master and Account_transaction)

Mar 29th, 2023
1,351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 2.05 KB | Source Code | 0 0
  1. ===== CREATE query Account master TABLE
  2. CREATE TABLE account_master
  3. (
  4. act_no INTEGER PRIMARY KEY,
  5. custname VARCHAR(20),
  6. address VARCHAR(20),
  7. act_type VARCHAR(10),
  8. open_date DATE,
  9. balance INTEGER,
  10. CONSTRAINT chk_type CHECK (act_type IN ('saving','current'))
  11. );
  12.  
  13. CREATE TABLE accont_transaction
  14. (
  15. trans_id INTEGER PRIMARY KEY,
  16. trans_type  VARCHAR(15),
  17. trans_date DATE,
  18. act_no INTEGER,
  19. trans_amt INTEGER,
  20. CONSTRAINT check_ttype CHECK (trans_type IN ('deposite','withdrawal')), CONSTRAINT
  21. fk_act_no FOREIGN KEY (act_no) REFERENCES account_master (act_no) ON UPDATE cascade ON DELETE cascade
  22. );
  23.  
  24. INSERT QUERY.
  25. INSERT INTO account_master VALUES(100,'jay','bhatar','saving','2017-05-04','20000');
  26. INSERT INTO account_master VALUES(101,'gutam','pipload','current','2013-01-02','34000');
  27. INSERT INTO account_master VALUES(102,'devyesh','udhna','current','2014-12-04','27000');
  28. INSERT INTO account_master VALUES(103,'jenish','adajan','saving','2016-05-04','40000');
  29. INSERT INTO account_master VALUES(104,'krushang','vesu','current','2015-01-04','8000');
  30. INSERT INTO account_master VALUES(105,'carry','farukhabad','current','1905-01-04','23000');
  31. INSERT INTO account_master VALUES(106,'bhuvan','delhi','current','2015-01-04','2000');
  32.  
  33.  
  34. INSERT INTO accont_transaction VALUES(1003,'withdrawal','2020-02-01','100','2000');
  35. INSERT INTO accont_transaction VALUES(1004,'withdrawal','2020-02-15','101','4000');
  36. INSERT INTO accont_transaction VALUES(1005,'deposite','2020-02-23','102','2500');
  37. INSERT INTO accont_transaction VALUES(1006,'withdrawal','2020-03-01','103','1800');
  38. INSERT INTO accont_transaction VALUES(1007,'deposite','2020-03-05','104','6000');
  39. INSERT INTO accont_transaction VALUES(1008,'deposite','2019-12-05','105','2000');
  40. INSERT INTO accont_transaction VALUES(1009,'withdrawal','2020-03-05','101','2000');
  41. INSERT INTO accont_transaction VALUES(1010,'deposite','2020-03-02','103','1800');
  42. INSERT INTO accont_transaction VALUES(1011,'withdrawal','2014-12-02','105','1800');
  43. INSERT INTO accont_transaction VALUES(1012,'deposite','2018-10-23','100','8000');
  44.  
  45.  
Tags: Sql Query
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement