Friday , April 19 2024

Create Table Inherits PostgreSQL

In this article, I will talk about using the INHERIT feature while creating a table and the details about it.

INHERIT allows us to inherit a different table.

INHERIT table operations are generally used to design tables without connecting the primary key and the foreign key.

Let’s explain with an example.

Let’s create our field table INHERITS from our personnel_name table.

We created both tables. As a result of this process, there are number and homeaddress columns in our personnel_communication table, but we can see our personnel_name columns in the personnel_communication table because we are doing INHERIT.

We can enter data into both tables by performing operations such as select, insert, update and delete in the INHERIT table.

Let’s insert our staff communication table and check if our first table is also affected by this insertion process.

In the insert sentence above, we added the first and last name columns in the personnel_name table, because we want to add records to both of them. You can make different inserts in both tables.

Let’s check if data has been added to our personnel_name table:

Loading

About Faruk Erdem

Leave a Reply

Your email address will not be published. Required fields are marked *

Categories