5

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"
1
  • You need to fire the statement, get the results then format these in c# Commented Mar 6, 2013 at 9:28

2 Answers 2

3

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;
Sign up to request clarification or add additional context in comments.

3 Comments

LISTAGG() could be relevant too : oracle-base.com/articles/misc/…
Agree. Added to the answer.
This answere do exactly what i want to do thx !
1
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

4 Comments

manual link is missing, besides i guess the OP didnt mean this
I understood it like he would like to have the string before the tablenames and the tablenames as coma separated which would explain tagging the question with the C# tag.
@TwoMore: but he still neeeds to select all table names somehow.
absolutly right, i have no problem with your answer but wonders if it answers the question, guess we will have to wait for the OP

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.