I write a program which scans all tablenames of a database and displays all
My Db has the Tables : User, Order,History
It should look like this:" Existing Tables: User Order History"
how should the command look like?
string SqlOrder="Select ??? from TestDB"
Try this
SELECT 'Existing Tables: ' || wm_concat(table_name) tablenames
FROM user_tables;
For the sample Oracle HR database it returns
TABLENAMES
------------------------------------------------------------------------------------
Existing Tables: REGIONS,LOCATIONS,DEPARTMENTS,JOBS,EMPLOYEES,JOB_HISTORY,COUNTRIES
UPDATE: Example with LISTAGG()
SELECT 'Existing Tables: ' || LISTAGG(table_name, ',')
WITHIN GROUP (ORDER BY table_name) tablenames
FROM user_tables;
select table_name
from all_tables
More details in the manual: http://docs.oracle.com/cd/E11882_01/server.112/e25513/statviews_2117.htm#i1592091
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With