-
Using the following script, I want to populate table TEST with 4 columns
insert into test
values (select name, sysdate from v$database),
(SELECT A.TABLESPACE_NAME,
ROUND(((NVL(B.BYTES,0) * 100) / A.BYTES), 1)
FROM (select tablespace_name, sum(bytes) bytes
from dba_data_files
group by tablespace_name) A,
(select tablespace_name,
sum(bytes) bytes
from dba_extents
group by tablespace_name) B
WHERE A.TABLESPACE_NAME = B.TABLESPACE_NAME (+)
order BY 1))
which does not work: help please!
Fiona
-
You can't use multiple, isolated SELECTS as you are trying to do. You can only use a single SELECT. If you need columns from multiple tables, then you need to join those tables into a singular SELECT.
- Chris
-
insert into test
select c.name, sysdate, a.tablespace_name, a.bytes, b.bytes
from
(select tablespace_name, sum(bytes) bytes from dba_data_files group by tablespace_name ) a,
(select tablespace_name, sum(bytes) bytes from dba_extents group by tablespace_name ) b,
v$database c
where a.tablespace_name = b.tablespace_name
----
I have simplified the query, but you should get the idea.
You have a couple of issues with your select:
1. you are using the "values" clause when you are not using any values.
2. you are trying to use "order by" with an insert query ( a no-no)
Jeff Hunter
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|