How to get the oracle table structure? [message #205558] |
Sun, 26 November 2006 01:28 |
sathyguy
Messages: 31 Registered: January 2006
|
Member |
|
|
Friends,
I have to take the table structure of a user.
i tried like this....
select dbms_metadata.get_ddl('TABLE',table_name,'SCOTT')
from user_tables;
but...the output is not so good. Is there any other way to get a table structure apart from sql tool like sql navigator etc...
thanks
|
|
|
|
Re: How to get the oracle table structure? [message #205579 is a reply to message #205577] |
Sun, 26 November 2006 07:12 |
sathyguy
Messages: 31 Registered: January 2006
|
Member |
|
|
Thanks for your reply....but....
DBMS_METADATA.GET_DDL('TABLE',TABLE_NAME,'SCOTT')
--------------------------------------------------------------------------------
CREATE TABLE "SCOTT"."BONUS"
( "ENAME" VARCHAR2(10),
"JOB" VARCHAR2(9),
"SAL" NUMBER,
"COMM" NUMBER
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "SYSTEM"
====================
see the extra entries....PCTFREE, STORAGE ETC....
if i need only the create table structure and its related constraints what should i do?
also, i am having one more doubt.
if i just copy the above statement will it work when i try to create a table......
[Updated on: Sun, 26 November 2006 07:12] Report message to a moderator
|
|
|
|
Re: How to get the oracle table structure? [message #217042 is a reply to message #205581] |
Wed, 31 January 2007 08:12 |
agostino_neto
Messages: 180 Registered: July 2005
|
Senior Member |
|
|
Hi,
Does somebody know how to extract table structure without the name of the owner ?
I would like to have CREATE TABLE "BONUS" and not CREATE TABLE "SCOTT"."BONUS".
Does somebody know how to avoid having description splitting into many lines
For example, instead of having "NOT NULL ENABLE", I am having
line1: NOT NULL EN
line2: ABLE
Thanks.
|
|
|
|
|
Re: How to get the oracle table structure? [message #217080 is a reply to message #217072] |
Wed, 31 January 2007 10:46 |
|
Mahesh Rajendran
Messages: 10708 Registered: March 2002 Location: oracleDocoVille
|
Senior Member Account Moderator |
|
|
Still, you need to feed the value of SCHEMA_OWNER programatically. Right?
Replace there~!. I believe, there is no other option in 9i (not sure about 10g).
scott@9i > var sname varchar2(30);
scott@9i > exec :sname :='SCOTT';
PL/SQL procedure successfully completed.
scott@9i > SELECT replace(DBMS_METADATA.GET_DDL('INDEX',D.INDEX_NAME)||';','"'||:sname||'".') FROM DBA_INDEXES d
2 where owner=:sname;
REPLACE(DBMS_METADATA.GET_DDL('INDEX',D.INDEX_NAME)||';','"'||:SNAME||'".')
--------------------------------------------------------------------------------
CREATE UNIQUE INDEX "SYS_C001612" ON "DEPT" ("DEPTNO")
PCTFREE 10 INITRANS 2 MAXTRANS 255
TABLESPACE "USERS"
|
|
|