473,406 Members | 2,220 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

ORACLE Describe Table

Is it possible to execute the DESC tablename command using PHP to a Oracle
DB or is that a *SQLPlus command?
Jun 29 '07 #1
8 11640
cbtguy_2000 (cb*********@yahoo.com) wrote:
: Is it possible to execute the DESC tablename command using PHP to a Oracle
: DB or is that a *SQLPlus command?

Not exactly, DESCRIBE is actually a command of sqlplus.

In oracle, look up the columns in a table by SELECTing from the
USER_TAB_COLUMNS table.

Oracle has a number of tables such as that one that have data about
tables/colums/etc.

Jun 29 '07 #2
On Thu, 28 Jun 2007 23:02:02 -0700, cbtguy_2000 wrote:
Is it possible to execute the DESC tablename command using PHP to a
Oracle DB or is that a *SQLPlus command?
What SQL*Plus does is to describe a cursor. Describing USER_TAB_COLUMNS
is equivalent to describing a cursor "select * from USER_TAB_COLUMNS".
OCI8 has plenty of functions to do just that:
oci_num_fields
oci_field_name
oci_field_is_null
oci_field_precision
oci_field_scale
oci_field_size
oci_field_type
--
http://www.mladen-gogala.com
Jun 30 '07 #3
Thanks for your help.
That info was very helpful.

The following SELECT gives the basic same info as DESCRIBE
SQLDESCRIBE BB_TAX
Name
Null? Type
----------------------------------------------------------------- --------
---------------
IDSTATE
NOT NULL NUMBER(2)
STATE
CHAR(2)
TAXRATE
NUMBER(4,3)

SQLcol column_name format a15
SQLcol data_type format a15
SQLcol nullable format a4
SQLSELECT column_name, data_type,
2 data_length, data_precision,
3 data_scale, nullable
4 FROM user_tab_columns
5 WHERE table_name = 'BB_TAX';

COLUMN_NAME DATA_TYPE DATA_LENGTH DATA_PRECISION
DATA_SCALE NULL
--------------- --------------- -----------
--------------- ---------
----
IDSTATE NUMBER 22
2 0
N
STATE CHAR 2
Y
TAXRATE NUMBER 22
4 3
Y

"Mladen Gogala" <mg*****************@verizon.netwrote in message
news:pa*********************@verizon.net...
On Thu, 28 Jun 2007 23:02:02 -0700, cbtguy_2000 wrote:
>Is it possible to execute the DESC tablename command using PHP to a
Oracle DB or is that a *SQLPlus command?

What SQL*Plus does is to describe a cursor. Describing USER_TAB_COLUMNS
is equivalent to describing a cursor "select * from USER_TAB_COLUMNS".
OCI8 has plenty of functions to do just that:
oci_num_fields
oci_field_name
oci_field_is_null
oci_field_precision
oci_field_scale
oci_field_size
oci_field_type
--
http://www.mladen-gogala.com

Jun 30 '07 #4
On Sat, 30 Jun 2007 05:45:00 +0000, cbtguy_2000 wrote:
The following SELECT gives the basic same info as DESCRIBE
It does, but it will not work for views or V$ tables.

--
http://www.mladen-gogala.com
Jul 2 '07 #5
On Mon, 02 Jul 2007 12:33:08 GMT, Mladen Gogala
<mg*****************@verizon.netwrote:
>On Sat, 30 Jun 2007 05:45:00 +0000, cbtguy_2000 wrote:
>The following SELECT gives the basic same info as DESCRIBE

It does, but it will not work for views or V$ tables.
Um, yes it will. Views' columns appear in USER_TAB_COLUMNS.

--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Jul 2 '07 #6
On Mon, 02 Jul 2007 19:31:52 +0100, Andy Hassall wrote:
On Mon, 02 Jul 2007 12:33:08 GMT, Mladen Gogala
<mg*****************@verizon.netwrote:
>>On Sat, 30 Jun 2007 05:45:00 +0000, cbtguy_2000 wrote:
>>The following SELECT gives the basic same info as DESCRIBE

It does, but it will not work for views or V$ tables.

Um, yes it will. Views' columns appear in USER_TAB_COLUMNS.
You are right, my mistake.
Jul 5 '07 #7
On Mon, 02 Jul 2007 19:31:52 +0100, Andy Hassall wrote:
>>It does, but it will not work for views or V$ tables.

Um, yes it will. Views' columns appear in USER_TAB_COLUMNS.
It does work for views, but not for V$ tables:
SQLselect column_name from dba_tab_columns
2 where table_name='V$PROCESS';

no rows selected

SQLselect column_name from dba_tab_columns
2 where table_name='V$SESSION';

no rows selected

SQLselect column_name from dba_tab_columns
2 where table_name='DBA_USERS';

COLUMN_NAME
-----------------------------------
USERNAME
USER_ID
PASSWORD
ACCOUNT_STATUS
LOCK_DATE
EXPIRY_DATE
DEFAULT_TABLESPACE
TEMPORARY_TABLESPACE
CREATED
PROFILE
INITIAL_RSRC_CONSUMER_GROUP
EXTERNAL_NAME

12 rows selected.

--
http://www.mladen-gogala.com
Jul 5 '07 #8
On Thu, 05 Jul 2007 23:45:10 GMT, Mladen Gogala
<mg*****************@verizon.netwrote:
>On Mon, 02 Jul 2007 19:31:52 +0100, Andy Hassall wrote:
>>>It does, but it will not work for views or V$ tables.

Um, yes it will. Views' columns appear in USER_TAB_COLUMNS.

It does work for views, but not for V$ tables:
SQLselect column_name from dba_tab_columns
2 where table_name='V$PROCESS';

no rows selected
That's because V$PROCESS is a synonym, not a table or view. Dereference it
first.

SQLselect table_owner, table_name
2 from dba_synonyms
3 where synonym_name = 'V$PROCESS'
4 and owner = 'PUBLIC';

TABLE_OWNER TABLE_NAME
------------------------------ ------------------------------
SYS V_$PROCESS

SQLselect column_name from dba_tab_columns
2 where owner = 'SYS'
3 and table_name = 'V_$PROCESS';

COLUMN_NAME
------------------------------
PGA_USED_MEM
PGA_ALLOC_MEM
PGA_FREEABLE_MEM
PGA_MAX_MEM
ADDR
PID
SPID
USERNAME
SERIAL#
TERMINAL
PROGRAM
TRACEID
BACKGROUND
LATCHWAIT
LATCHSPIN

15 rows selected
--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Jul 6 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Thierry B. | last post by:
Hi, from SQL*Plus, i use: DESCRIBE MyTable and I get this result (example): Nom NULL ? Type ----------------------------------------- --------...
2
by: Dmitry Bond. | last post by:
Hello All. Currently we are porting some software from NSK (HP Hon-Stop) SQL to Oracle and I faced with the following problem... The SQL statement: select * from BOM where ordnr = :1 where...
133
by: jonathan | last post by:
hey all, I realize that this question might pop up from time to time, but I haven't seen it a while and things might of changed, so - Right now (July 2004) how does mysql stand up in...
0
by: Prabhakar Chola | last post by:
I got this error on production and I rebooted the server and the problem went away. It happens at random. Please help. Environment W2K with Oracle 9.2 client connected to oracle using...
0
by: Max | last post by:
Hi wise people, Has anyone encountered the Crystal Reports problem I describe below? If so, how did you solve it? It seems that every article posted on google regarding CR and logon problems is...
11
by: Rosco | last post by:
Does anyone have a good URL or info whre Oracle and Access are compared to one another in performance, security, cost etc. Before you jump on me I know Oracle is a Cadillac compared to Access the...
9
by: AnandaSim | last post by:
Hi All, I've had Access 97, 2000 connections to the corporate Oracle database for a few years now - but seldom use it. When I did use it years ago, performance was not fast but the features were...
3
by: egarobar | last post by:
I am using Access 2003 (on WinXP) to read from an Oracle db, where there is a table with a CLOB which is a variable-size text field. In the 'linked table' which is created in the Tables panel of...
3
by: =?Utf-8?B?S3VsZGVlcCBWaWpheWt1bWFy?= | last post by:
Language: C#.NET 2.0 Technology: ASP.NET 2.0 Database: Oracle 10g Hi All, Could any one of you please suggest the BEST method to: 1. Fetch data from a very large .csv file (around 8 MB) and...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.