Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: [Pro*C/C++] : List of tables in database and other things

Re: [Pro*C/C++] : List of tables in database and other things

From: Lars Sjöström <lasse.sjostrom_at_telia.com>
Date: Fri, 08 Oct 1999 13:21:36 GMT
Message-ID: <AdmL3.68$wp.186463232@newsa.telia.net>


Every one of these SQL-statements you have to issue to the database and take care of the result. I dont recall if there should be : before the variable-names. Be sure to look in the Pro*Cmanual for that.

Use USER_TABLES. Do a search and if NO_DATA_FOUND then handle that. i.e. SELECT TABLE_NAME into your-var FROM USER_TABLES WHERE TABLE_NAME=your-table-name

>1.2. How can we get number of tables
> containing in database?

Same view, but SELECT COUNT(*) INTO your-var in stead.

>1.3. How can we get list of names of all tables
> containing in database?
>

Same view again, but SELECT TABLE_NAME into som array-or-whatever FROM USER_TABLES. If you are intrested in views also the view (!) for that is USER_VIEWS.
>
>---------- 2. columns in table -----------------
>2.1. How can we know
> if a column (for instance, column "BBB")
> exists in table?

Another view, USER_TAB_COLUMNS, SELECT COLUMN_NAME into your-var FROM USER_TAB_COLUMNS
WHERE TABLE_NAME=table-in-question.

>2.2. How can we get number of columns
> containing in table?

SELECT COUNT(*) into noc from the view above. noc being your variable.
>2.3. How can we get list of names of all columns
> containing in table?
>

SELECT COLUMN_NAME FROM USER_TAB_COLUMNS WHERE TABLE_NAME=your table.

>
>---------- 3. rows in table --------------------
>3.1. How can we know
> if a row (for instance, row with specific key)
> exists in table?

SELECT 'x' from table where your_index_col_name=key

>3.2. How can we get number of rows
> containing in table?

SELECT COUNT(*) FROM table-in-question

>3.3. How can we get list of names of all rows
> containing in table?

Names? Dont get this question. What do you want? Maybe you are looking for the ROWID. THen it is SELECT ROWID from table-in-question.

Lars Olof Sjöström
RKS Data AB
Linköping
Sweden Received on Fri Oct 08 1999 - 08:21:36 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US