0

I'm working on a JavaEE project, with DB2 Database and JPA. Can we make Inheritance between tables ? In the IBM DB2 Website, i found nothing on the DB2 documentation to do this via SQL code.

This is what i want to do Exemple :

CREATE TABLE TRANSACTION (
TranNo int);

CREATE TABLE MOBILETRANSACTION (
Number1 varchar(255),
Number2 varchar(255) );

What is the word to add to the MOBILETRANSACTION Table to inherit the TRANSACTION table ?

Thank you !

ilias
  • 182
  • 1
  • 3
  • 13
  • Alternatively, just add an FK from `MOBILETRANSACTION` to `TRANSACTION` and do a `JOIN` in your query when retrieving data, or use a `VIEW` to do the same thing. – Dai Sep 10 '21 at 22:15

1 Answers1

1

What you need is called typed-tables in DB2. For global information about inheritance: http://pic.dhe.ibm.com/infocenter/db2luw/v10r5/topic/com.ibm.db2.luw.admin.structypes.doc/doc/c0006588.html

You first need to create a structure (type), and then you can use that structure in a table.

Please, check this first (http://pic.dhe.ibm.com/infocenter/db2luw/v10r5/topic/com.ibm.db2.luw.admin.structypes.doc/doc/c0006441.html) read all sections and them proceed with your own implementation.

AngocA
  • 7,655
  • 6
  • 39
  • 55