Search code examples
oracle-databaseoracle11gnested-table

Add a column to a nested table


I've this table

parlamentari
---------------
id|nome|cognome

Can i add in this table a nested column called telefoni? I tried with

create table or replace type telefoni_nt as table of varchar2(10) after dnn;

alter table parlamentari add telefoni telefoni_nt  nested table telefoni store telefoni_tab;

without success. Thanks


Solution

  • I think you want :

    create table parlamentari( id integer, nome varchar2(20), cognome varchar2(20));
    
    create or replace type telefoni_nt as table of varchar2(10);
    
    alter table parlamentari 
            add (telefoni telefoni_nt)
    nested table telefoni store as telefoni_tab;
    

    and had a typo table at "create table or replace type telefoni_nt".

    SQL Fiddle Demo