Reputation: 23
Created a type vehicle as-
create type vehicle as ( tag text, name text);
Create table using type as-
create table bike of vehicle;
Trying to add column as-
alter table bike add column attributes text;
ERROR: cannot add column to typed table
Is it possible to add column in typed column by any method?
Upvotes: 2
Views: 240
Reputation: 18290
From the documentation for ALTER TYPE
CASCADE
Automatically propagate the operation to typed tables of the type being altered, and their descendants.
So, using your example:
CREATE TYPE vehicle AS ( tag text, name text);
CREATE TABLE bike OF vehicle;
INSERT INTO bike(tag, name) values ('t','n')
ALTER TYPE vehicle ADD ATTRIBUTE test text CASCADE;
SELECT * FROM bike
results in:
|tag|name|test|
|---|----|----|
|t |n | |
Upvotes: 2