OR Database/Type in Oracle Express/SQL Developer

拈花ヽ惹草 提交于 2020-01-06 04:25:08

问题


I try to do some stuff wie object relational Databases. I have Oracle Express and the SQL Developer. Everything works fine.

I can create my own, custom types and insert some rows. The problem is that it would not be display right. I think it is normally because they should be display object/types in a column...

Is there a solution to display the objects in the columns?

This is my code. p.s. i am from germany. ANSCHRIFT_T is a type for an address with name of the tress (Strasse) and house number (Hausnr).

CREATE OR REPLACE TYPE ANSCHRIFT_T AS OBJECT (STRASSE CHAR(12), HAUSNR CHAR(3));

CREATE TABLE VERTRETER(V_NR NUMBER(4) PRIMARY KEY, ANSCHRIFT ANSCHRIFT_T);

INSERT INTO VERTRETER VALUES (1, ANSCHRIFT_T('TESTWEG','14'));
INSERT INTO VERTRETER VALUES (2, ANSCHRIFT_T('BLA BLA WEG', '25'));

SELECT V_NR, ANSCHRIFT FROM VERTRETER;

But the output its just this:


回答1:


Double click on the value. You'll see your data.

Or, you can tell SQL Developer to show those values by default.

Preferences > Advanced, display structures

And then run your query again.

[




回答2:


You need to add an alias for the table name and then you can select the values from the object column using table_alias.object_column.object_attribute. Like this:

Query:

SELECT V_NR,
       v.ANSCHRIFT.STRASSE,
       v.ANSCHRIFT.HAUSNR
FROM   VERTRETER v;

Output:

      V_NR ANSCHRIFT.STRASSE ANSCHRIFT.HAUSNR
---------- ----------------- ----------------
         1 TESTWEG           14               
         2 BLA BLA WEG       25               


来源:https://stackoverflow.com/questions/37098969/or-database-type-in-oracle-express-sql-developer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!