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: Alex Vinokur <alexander.vinokur_at_telrad.co.il>
Date: Thu, 28 Oct 1999 11:08:42 GMT
Message-ID: <7v9arp$kcg$1@nnrp1.deja.com>


In article <AdmL3.68$wp.186463232_at_newsa.telia.net>,   "Lars Sjöström" <lasse.sjostrom_at_telia.com> wrote:
> 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.
>
> --------- 1. tables in database ---------------
> >1.1. How can we know
> > if a table (for instance, table "AAA")
> > exists in database?
>
> 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
>



Now I would like to remove this 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
>
>

A lot of thanks.
It is very helpful.

        Alex

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Thu Oct 28 1999 - 06:08:42 CDT

Original text of this message

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