简体   繁体   中英

How to add column to nested table in Oracle SQL

I have table with nested table, and I want to add another column to the nested table . Is it possible? If it is, what is the syntax? couldn't find it anywhere..

Consider this example:

CREATE TYPE address_t AS OBJECT (
   street  VARCHAR2(30),
   city    VARCHAR2(20),
   zip     NUMBER );
 
CREATE TYPE addresses_nested IS TABLE OF address_t;

CREATE TABLE customers (
   id NUMBER,
   address addresses_nested )
   NESTED TABLE address STORE AS customer_addresses;

It Creates the the table "customers" with nested table "addresses_nested": 在此处输入图像描述

Can u give an example how to add column to "addresses_nested" if possible? Thank you

I if followed correctly, you want to add an attribute to the underlying type. If so, you can use the alter type statement:

alter type address_t add attribute phone varchar2(12) cascade;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM