Home » SQL & PL/SQL » SQL & PL/SQL » SDO_GTYPE count and group by based on tables in all_tab_cols?
SDO_GTYPE count and group by based on tables in all_tab_cols? [message #609233] Tue, 04 March 2014 04:51 Go to next message
psnepvangers
Messages: 2
Registered: March 2014
Location: Nederland
Junior Member
Hello all,

I've got the following query:
SELECT GEO.GEOMETRY.SDO_GTYPE "TYPE GEOMETRY", COUNT(*) FROM SCHEMA.TREES GEO GROUP BY GEO.GEOMETRY.SDO_GTYPE;

Now, I want to do this to every table where the column GEOMETRY exists:
SELECT TABLE_NAME FROM ALL_TAB_COLS WHERE COLUMN_NAME = 'GEOMETRY' AND OWNER = '&SCHEMA';

This will result in the following:
TABLE_NAME
TREES
GREENPATCHES

Now, I can't seem to find out how I can run the first query depending on what I get in the second query. Can anyone help me with this?

Thanks in advance,

Peter
Re: SDO_GTYPE count and group by based on tables in all_tab_cols? [message #609234 is a reply to message #609233] Tue, 04 March 2014 05:04 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

select table_name,
       to_number(extractvalue(
                   dbms_xmlgen.getXMLtype ('select count(*) cnt from '||table_name),
                   '/ROWSET/ROW/CNT')) rows_in_table
from user_tab_columns
where column_name = 'GEOMETRY'
order by 1
/

Re: SDO_GTYPE count and group by based on tables in all_tab_cols? [message #609295 is a reply to message #609234] Wed, 05 March 2014 03:51 Go to previous messageGo to next message
psnepvangers
Messages: 2
Registered: March 2014
Location: Nederland
Junior Member
This seems to be a select count on each table where the GEOMETRY column exists. My plan is however to use the query to find out which tables have what SDO object types, and how many of each (see the first query).

Is that possible to do, or not with Oracle?
Re: SDO_GTYPE count and group by based on tables in all_tab_cols? [message #609296 is a reply to message #609295] Wed, 05 March 2014 04:01 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
So add the column to the dynamic select.
Re: SDO_GTYPE count and group by based on tables in all_tab_cols? [message #609298 is a reply to message #609295] Wed, 05 March 2014 04:06 Go to previous message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
This seems to be a select count on each table where the GEOMETRY column exists.


Yes it is as you said:

Quote:
I want to do this to every table where the column GEOMETRY exists:


Quote:
(see the first query).


Your query which does not give you what you want does not help us to understand what you actually want.


Quote:
My plan is however to use the query to find out which tables have what SDO object types,


Something like:
select owner, table_name, data_type, count(*)
from dba_tab_columns
where data_type_owner = 'MDSYS'
group by owner, table_name, data_type
order by owner, table_name, data_type
/


SQL> select owner, table_name, data_type, count(*)
  2  from dba_tab_columns
  3  where data_type_owner = 'MDSYS'
  4  group by owner, table_name, data_type
  5  order by owner, table_name, data_type
  6  /
OWNER                          TABLE_NAME                     DATA_TYPE                        COUNT(*)
------------------------------ ------------------------------ ------------------------------ ----------
MDSYS                          ALL_SDO_GEOM_METADATA          SDO_DIM_ARRAY                           1
MDSYS                          ALL_SDO_INDEX_METADATA         SDO_GEOMETRY                            1
MDSYS                          ALL_SDO_STYLES                 SDO_GEOMETRY                            1
MDSYS                          CS_SRS                         SDO_GEOMETRY                            1
MDSYS                          DBA_SDO_STYLES                 SDO_GEOMETRY                            1
MDSYS                          MY_SDO_INDEX_METADATA          SDO_GEOMETRY                            1
MDSYS                          SDO_COORD_OP_PARAM_VALS        XMLTYPE                                 1
MDSYS                          SDO_COORD_REF_SYS              SDO_GEOMETRY                            1
MDSYS                          SDO_COORD_REF_SYSTEM           SDO_GEOMETRY                            1
MDSYS                          SDO_CS_SRS                     SDO_GEOMETRY                            1
MDSYS                          SDO_GEOM_METADATA_TABLE        SDO_DIM_ARRAY                           1
MDSYS                          SDO_INDEX_METADATA_TABLE       SDO_GEOMETRY                            1
MDSYS                          SDO_STYLES_TABLE               SDO_GEOMETRY                            1
MDSYS                          SDO_TOPO_METADATA_TABLE        SDO_TOPO_GEOMETRY_LAYER_ARRAY           1
MDSYS                          USER_SDO_GEOM_METADATA         SDO_DIM_ARRAY                           1
MDSYS                          USER_SDO_INDEX_METADATA        SDO_GEOMETRY                            1
MDSYS                          USER_SDO_STYLES                SDO_GEOMETRY                            1
OE                             CUSTOMERS                      SDO_GEOMETRY                            1
OE                             WAREHOUSES                     SDO_GEOMETRY                            1

[Updated on: Wed, 05 March 2014 04:06]

Report message to a moderator

Previous Topic: Wrong result in trying to find offset change time
Next Topic: PlSql open read cell in excel file!!
Goto Forum:
  


Current Time: Thu Apr 25 06:18:24 CDT 2024