TIPS(18) : CREATING SCRIPTS TO RECREATE A TABLE STRUCTURE

제품 : SQL*PLUS
작성날짜 : 1996-11-12
TIPS(18) : Creating Scripts to Recreate a Table Structure
=========================================================
The script creates scripts that can be used to recreate a table structure.
For example, this script can be used when a table has become fragmented or to
get a defintion that can be run on another database.
CREATES SCRIPT TO RECREATE A TABLE-STRUCTURE
INCL. STORAGE, CONSTRAINTS, TRIGGERS ETC.
This script creates scripts to recreate a table structure.
Use the script to reorganise a table that has become fragmented,
to get a definition that can be run on another database/schema or
as a basis for altering the table structure (eg. drop a column!).
IMPORTANT: Running the script is safe as it only creates two new scripts and
does not do anything to your database! To get anything done you have to run the
scripts created.
The created scripts does the following:
1. save the content of the table
2. drop any foreign key constraints referencing the table
3. drop the table
4. creates the table with an Initial storage parameter that
will accomodate the entire content of the table. The Next
parameter is 25% of the initial.
The storage parameters are picked from the following list:
64K, 128K, 256K, 512K, multiples of 1M.
5. create table and column comments
6. fill the table with the original content
7. create all the indexes incl storage parameters as above.
8. add primary, unique key and check constraints.
9. add foreign key constraints for the table and for referencing
tables.
10.Create the table's triggers.
11.Compile any depending objects (cascading).
12.Grant table and column privileges.
13.Create synonyms.
This script must be run as the owner of the table.
If your table contains a LONG-column, use the COPY
command in SQL*Plus to store/restore the data.
USAGE
from SQL*Plus:
start reorgtb
This will create the scripts REORGS1.SQL and REORGS2.SQL
REORGS1.SQL contains code to save the current content of the table.
REORGS2.SQL contains code to rebuild the table structure.
undef tab;
set echo off
column a1 new_val stor
column b1 new_val nxt
select
decode(sign(1024-sum(bytes)/1024),-1,to_char((round(sum(bytes)/(1024*1
024))+1))||'M', /* > 1M new rounded up to nearest Megabyte */
decode(sign(512-sum(bytes)/1024), -1,'1M',
decode(sign(256-sum(bytes)/1024), -1,'512K',
decode(sign(128-sum(bytes)/1024), -1,'256K',
decode(sign(64-sum(bytes)/1024) , -1,'128K',
'64K'
a1,
decode(sign(1024-sum(bytes)/4096),-1,to_char((round(sum(bytes)/(4096*1
024))+1))||'M', /* > 1M new rounded up to nearest Megabyte */
decode(sign(512-sum(bytes)/4096), -1,'1M',
decode(sign(256-sum(bytes)/4096), -1,'512K',
decode(sign(128-sum(bytes)/4096), -1,'256K',
decode(sign(64-sum(bytes)/4096) , -1,'128K',
'64K'
b1
from user_extents
where segment_name=upper('&1');
set pages 0 feed off verify off lines 150
col c1 format a80
spool reorgs1.sql
PROMPT drop table bk_&1
prompt /
PROMPT create table bk_&1 storage (initial &stor) as select * from &1
prompt /
spool off
spool reorgs2.sql
PROMPT spool reorgs2
select 'alter table '||table_name||' drop constraint
'||constraint_name||';'
from user_constraints where r_constraint_name
in (select constraint_name from user_constraints where
table_name=upper('&1')
and constraint_type in ('P','U'));
PROMPT drop table &1
prompt /
prompt create table &1
select decode(column_id,1,'(',',')
||rpad(column_name,40)
||decode(data_type,'DATE' ,'DATE '
,'LONG' ,'LONG '
,'LONG RAW','LONG RAW '
,'RAW' ,'RAW '
,'CHAR' ,'CHAR '
,'VARCHAR' ,'VARCHAR '
,'VARCHAR2','VARCHAR2 '
,'NUMBER' ,'NUMBER '
,'unknown')
||rpad(
decode(data_type,'DATE' ,null
,'LONG' ,null
,'LONG RAW',null
,'RAW' ,decode(data_length,null,null
,'('||data_length||')')
,'CHAR' ,decode(data_length,null,null
,'('||data_length||')')
,'VARCHAR' ,decode(data_length,null,null
,'('||data_length||')')
,'VARCHAR2',decode(data_length,null,null
,'('||data_length||')')
,'NUMBER' ,decode(data_precision,null,' '
,'('||data_precision||
decode(data_scale,null,null
,','||data_scale)||')')
,'unknown'),8,' ')
||decode(nullable,'Y','NULL','NOT NULL') c1
from user_tab_columns
where table_name = upper('&1')
order by column_id
prompt )
select 'pctfree '||t.pct_free c1
,'pctused '||t.pct_used c1
,'initrans '||t.ini_trans c1
,'maxtrans '||t.max_trans c1
,'tablespace '||s.tablespace_name c1
,'storage (initial '||'&stor' c1
,' next '||'&stor' c1
,' minextents '||t.min_extents c1
,' maxextents '||t.max_extents c1
,' pctincrease '||t.pct_increase||')' c1
from user_Segments s, user_tables t
where s.segment_name = upper('&1') and
t.table_name = upper('&1')
and s.segment_type = 'TABLE'
prompt /
select 'comment on table &1 is '''||comments||''';' c1 from
user_tab_comments
where table_name=upper('&1');
select 'comment on column &1..'||column_name||
' is '''||comments||''';' c1 from user_col_comments
where table_name=upper('&1');
prompt insert into &1 select * from bk_&1
prompt /
set serveroutput on
declare
cursor c1 is select index_name,decode(uniqueness,'UNIQUE','UNIQUE')
unq
from user_indexes where
table_name = upper('&1');
indname varchar2(50);
cursor c2 is select
decode(column_position,1,'(',',')||rpad(column_name,40) cl
from user_ind_columns where table_name = upper('&1') and
index_name = indname
order by column_position;
l1 varchar2(100);
l2 varchar2(100);
l3 varchar2(100);
l4 varchar2(100);
l5 varchar2(100);
l6 varchar2(100);
l7 varchar2(100);
l8 varchar2(100);
l9 varchar2(100);
begin
dbms_output.enable(100000);
for c in c1 loop
dbms_output.put_line('create '||c.unq||' index '||c.index_name||' on
&1');
indname := c.index_name;
for q in c2 loop
dbms_output.put_line(q.cl);
end loop;
dbms_output.put_line(')');
select 'pctfree '||i.pct_free ,
'initrans '||i.ini_trans ,
'maxtrans '||i.max_trans ,
'tablespace '||i.tablespace_name ,
'storage (initial '||
decode(sign(1024-sum(e.bytes)/1024),-1,
to_char((round(sum(e.bytes)/(1024*1024))+1))||'M',
decode(sign(512-sum(e.bytes)/1024), -1,'1M',
decode(sign(256-sum(e.bytes)/1024), -1,'512K',
decode(sign(128-sum(e.bytes)/1024), -1,'256K',
decode(sign(64-sum(e.bytes)/1024) , -1,'128K',
'64K'))))) ,
' next '||
decode(sign(1024-sum(e.bytes)/4096),-1,
to_char((round(sum(e.bytes)/(4096*1024))+1))||'M',
decode(sign(512-sum(e.bytes)/4096), -1,'1M',
decode(sign(256-sum(e.bytes)/4096), -1,'512K',
decode(sign(128-sum(e.bytes)/4096), -1,'256K',
decode(sign(64-sum(e.bytes)/4096) , -1,'128K',
'64K'))))) ,
' minextents '||s.min_extents ,
' maxextents '||s.max_extents ,
' pctincrease '||s.pct_increase||')'
into l1,l2,l3,l4,l5,l6,l7,l8,l9
from user_extents e,user_segments s, user_indexes i
where s.segment_name = c.index_name
and s.segment_type = 'INDEX'
and i.index_name = c.index_name
and e.segment_name=s.segment_name
group by s.min_extents,s.max_extents,s.pct_increase,
i.pct_free,i.ini_trans,i.max_trans,i.tablespace_name ;
dbms_output.put_line(l1);
dbms_output.put_line(l2);
dbms_output.put_line(l3);
dbms_output.put_line(l4);
dbms_output.put_line(l5);
dbms_output.put_line(l6);
dbms_output.put_line(l7);
dbms_output.put_line(l8);
dbms_output.put_line(l9);
dbms_output.put_line('/');
end loop;
end;
declare
cursor c1 is
select constraint_name, decode(constraint_type,'U',' UNIQUE',' PRIMARY
KEY') typ,
decode(status,'DISABLED','DISABLE',' ') status from user_constraints
where table_name = upper('&1')
and constraint_type in ('U','P');
cname varchar2(100);
cursor c2 is
select decode(position,1,'(',',')||rpad(column_name,40) coln
from user_cons_columns
where table_name = upper('&1')
and constraint_name = cname
order by position;
begin
for q1 in c1 loop
cname := q1.constraint_name;
dbms_output.put_line('alter table &1');
dbms_output.put_line('add constraint '||cname||q1.typ);
for q2 in c2 loop
dbms_output.put_line(q2.coln);
end loop;
dbms_output.put_line(')' ||q1.status);
dbms_output.put_line('/');
end loop;
end;
declare
cursor c1 is
select c.constraint_name,c.r_constraint_name cname2,
c.table_name table1, r.table_name table2,
decode(c.status,'DISABLED','DISABLE',' ') status,
decode(c.delete_rule,'CASCADE',' on delete cascade ',' ')
delete_rule
from user_constraints c,
user_constraints r
where c.constraint_type='R' and
c.r_constraint_name = r.constraint_name and
c.table_name = upper('&1')
union
select c.constraint_name,c.r_constraint_name cname2,
c.table_name table1, r.table_name table2,
decode(c.status,'DISABLED','DISABLE',' ') status,
decode(c.delete_rule,'CASCADE',' on delete cascade ',' ')
delete_rule
from user_constraints c,
user_constraints r
where c.constraint_type='R' and
c.r_constraint_name = r.constraint_name and
r.table_name = upper('&1');
cname varchar2(50);
cname2 varchar2(50);
cursor c2 is
select decode(position,1,'(',',')||rpad(column_name,40) colname
from user_cons_columns
where constraint_name = cname
order by position;
cursor c3 is
select decode(position,1,'(',',')||rpad(column_name,40) refcol
from user_cons_columns
where constraint_name = cname2
order by position;
begin
dbms_output.enable(100000);
for q1 in c1 loop
cname := q1.constraint_name;
cname2 := q1.cname2;
dbms_output.put_line('alter table '||q1.table1||' add constraint ');
dbms_output.put_line(cname||' foreign key');
for q2 in c2 loop
dbms_output.put_line(q2.colname);
end loop;
dbms_output.put_line(') references '||q1.table2);
for q3 in c3 loop
dbms_output.put_line(q3.refcol);
end loop;
dbms_output.put_line(') '||q1.delete_rule||q1.status);
dbms_output.put_line('/');
end loop;
end;
col c1 format a79 word_wrap
set long 32000
set arraysize 1
select 'create or replace trigger ' c1,
description c1,
'WHEN ('||when_clause||')' c1,
trigger_body ,
'/' c1
from user_triggers
where table_name = upper('&1') and when_clause is not null
select 'create or replace trigger ' c1,
description c1,
trigger_body ,
'/' c1
from user_triggers
where table_name = upper('&1') and when_clause is null
select 'alter trigger '||trigger_name||decode(status,'DISABLED','
DISABLE',' ENABLE')
from user_Triggers where table_name='&1';
set serveroutput on
declare
cursor c1 is
select 'alter table
'||'&1'||decode(substr(constraint_name,1,4),'SYS_',' ',
' add constraint ') a1,
decode(substr(constraint_name,1,4),'SYS_','
',constraint_name)||' check (' a2,
search_condition a3,
') '||decode(status,'DISABLED','DISABLE','') a4,
'/' a5
from user_constraints
where table_name = upper('&1') and
constraint_type='C';
b1 varchar2(100);
b2 varchar2(100);
b3 varchar2(32000);
b4 varchar2(100);
b5 varchar2(100);
fl number;
begin
open c1;
loop
fetch c1 into b1,b2,b3,b4,b5;
exit when c1%NOTFOUND;
select count(*) into fl from user_tab_columns where table_name =
upper('&1') and
upper(column_name)||' IS NOT NULL' = upper(b3);
if fl = 0 then
dbms_output.put_line(b1);
dbms_output.put_line(b2);
dbms_output.put_line(b3);
dbms_output.put_line(b4);
dbms_output.put_line(b5);
end if;
end loop;
end;
create or replace procedure dumzxcvreorg_dep(nam varchar2,typ
varchar2) as
cursor cur is
select type,decode(type,'PACKAGE BODY','PACKAGE',type) type1,
name from user_dependencies
where referenced_name=upper(nam) and referenced_type=upper(typ);
begin
dbms_output.enable(500000);
for c in cur loop
dbms_output.put_line('alter '||c.type1||' '||c.name||' compile;');
dumzxcvreorg_dep(c.name,c.type);
end loop;
end;
exec dumzxcvreorg_dep('&1','TABLE');
drop procedure dumzxcvreorg_Dep;
select 'grant '||privilege||' on '||table_name||' to '||grantee||
decode(grantable,'YES',' with grant option;',';') from
user_tab_privs where table_name = upper('&1');
select 'grant '||privilege||' ('||column_name||') on &1 to
'||grantee||
decode(grantable,'YES',' with grant option;',';')
from user_col_privs where grantor=user and
table_name=upper('&1')
order by grantee, privilege;
select 'create synonym '||synonym_name||' for
'||table_owner||'.'||table_name||';'
from user_synonyms where table_name=upper('&1');
PROMPT REM
PROMPT REM YOU MAY HAVE TO LOG ON AS SYSTEM TO BE
PROMPT REM ABLE TO CREATE ANY OF THE PUBLIC SYNONYMS!
PROMPT REM
select 'create public synonym '||synonym_name||' for
'||table_owner||'.'||table_name||';'
from all_synonyms where owner='PUBLIC' and table_name=upper('&1') and
table_owner=user;
prompt spool off
spool off
set echo on feed on verify on
The scripts REORGS1.SQL and REORGS2.SQL have been
created. Alter these script as necesarry.
To recreate the table-structure, first run REORGS1.SQL.
This script saves the content of your table in a table
called bk_.
If this script runs successfully run REORGS2.SQL.
The result is spooled to REORGTB.LST.
Check this file before dropping the bk_ table.
*/

Please do NOT cross-postings: create a deep structure for dynamic internal table
Regards
  Uwe

Similar Messages

  • Creating a simple 3 column table structure

    Good afternoon.
    I have been trying to create a simple 3 column table structure. A task which should typically take no longer than 15 minutes to design and populate has taken over two hours! (The final structure is acceptable but not ideal).
    Creating the design whilst applying the style Default Table Style - Light,  the content of each column and row are all equally aligned.
    However, when applying either of these styles; Table Style 1 - Clear or
    Table Style 2 - Light Banded,  (light banded is my preference) the alignment of each column and row 'fall apart'. I.e. the content within the left column displays half way down the page, the content within the middle column  at the top
    and the content within the right column at the bottom of the page???
    Adding and removing carriage returns help to a degree but is not ultimately agreeable to achieving an equally structured table design.
    I am rather new to SharePoint design and after exhausting all efforts and considerable time, I need to request assistance please.
    Thank you.
    David
    Senninha010

    Thank you so much!
    Such a simple yet effective solution. :)
    The table structure created in Word retains it's integrity when pasted into a SharePoint page.
    Is there anyway I can also retain the background colour of individual table columns? Specifying such colours in Word; this feature is lost when the table is pasted into a SharePoint page.
    Senninha010

  • Create script for installing underlying tables

    Please let me know what steps to follow to create scripts to include (exproting of tables_data ) while exporting a packaged application

    utility exp rows=N/imp show=y or package dbms_metadata
    SQL> select dbms_metadata.get_ddl('TABLE','EMP') from dual;
    DBMS_METADATA.GET_DDL('TABLE',
      CREATE TABLE "SCOTT"."EMP"
       (    "EMPNO" NUMBER(4,0),
            "ENAME" VARCHAR2(10),
            "JOB" VARCHAR2(9),
            "MGR" NUMBER(4,0),
            "HIREDATE" DATE,
            "SAL" NUMBER(7,2),
            "COMM" NUMBER(7,2),
            "DEPTNO" NUMBER(2,0),
             CONSTRAINT "PK_EMP" PRIMARY KEY ("EMPNO")
      USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "TOOLS"  ENABLE,
             CONSTRAINT "FK_DEPTNO" FOREIGN KEY ("DEPTNO")
              REFERENCES "SCOTT"."DEPT" ("DEPTNO") ENABLE
       ) 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 "TOOLS"HTH
    Laurent Schneider
    OCM DBA

  • Create PHP form from MySQL table structure

    Hi folks
    Not directly DW related, but ....
    Anybody got any recommendations for a utility which would
    create a quick head
    start by creating the php/html code for a basic form using
    the field structure
    of a MySQL table ?
    Thanks for any suggestions.
    Ronnie MacGregor
    Scotland
    Ronnie at
    dBASEdeveloper
    dot co dot uk
    www.dBASEdeveloper.co.uk

    On Sun, 21 Dec 2008 15:08:30 +0000 (UTC)
    Joe Makowiec said :
    > On 21 Dec 2008 in macromedia.dreamweaver, Ronnie
    MacGregor wrote:
    >
    > > Anybody got any recommendations for a utility which
    would create a
    > > quick head start by creating the php/html code for
    a basic form
    > > using the field structure of a MySQL table ?
    > I haven't used it, but it looks like phpmyedit may do
    what you want:
    >
    >
    http://www.phpmyedit.org/
    Hi Joe
    Thanks for this ...
    phpMyEdit looks very good and very useful, and I'm playing
    with it to see just
    how configurable it proves to be.
    It looks good for general admin tasks etc. bet whether it
    proves suitable for
    end user (public) use remains to be seen.
    It is basically a class which generates the page code server
    side at runtime
    using the parameters you set in a calling script, but of
    course you can grab
    the source code for the generated page which may prove to
    satisfy my initial
    request.
    Anyway ... from what I've seen so far I could recommend that
    it is well worth
    some time exploring the possibilities.
    Cheers,
    Ronnie
    Ronnie MacGregor
    Scotland
    Ronnie at
    dBASEdeveloper
    dot co dot uk
    www.dBASEdeveloper.co.uk

  • Generate Create Script creates scripts that won't run: ORA-00922: missing..

    I'm having trouble running a script that I created by using the Generate Create Script tool in Oracle Explorer. I created the following script by running the Generate Create Script on a table called, "ASPNET_APPLICATIONS":
    CREATE TABLE "DEV"."ASPNET_APPLICATIONS" ("APPLICATIONID" NUMBER,"APPLICATIONNAME" VARCHAR2(256 BYTE),"DESCRIPTION" VARCHAR2(256 BYTE)) TABLESPACE "USERS" PCTFREE 10 INITRANS 1 MAXTRANS 255 STORAGE ( INITIAL 65536 MAXEXTENTS 2147483645 MINEXTENTS 1 )
    CREATE UNIQUE INDEX "DEV"."PK_APPS" ON "DEV"."ASPNET_APPLICATIONS" ("APPLICATIONID" ) TABLESPACE "USERS"
    CREATE UNIQUE INDEX "DEV"."IDX_APPS_APPNAME" ON "DEV"."ASPNET_APPLICATIONS" (LOWER(TRIM("APPLICATIONNAME")) ) TABLESPACE "USERS"
    ALTER TABLE "DEV"."ASPNET_APPLICATIONS" ADD ( CONSTRAINT "SYS_C004598" CHECK ("APPLICATIONNAME" IS NOT NULL) ENABLE VALIDATE )
    ALTER TABLE "DEV"."ASPNET_APPLICATIONS" ADD ( CONSTRAINT "SYS_C004597" CHECK ("APPLICATIONID" IS NOT NULL) ENABLE VALIDATE )
    I then deleted the table in my Oracle 10g database and ran the above script to recreate the table. The result is that I get an error the following error, ORA-00922: missing or invalid option. Does anyone know how to resolve this?
    Is anyone aware of any bugs in the Generate Create Script option of Oracle Explorer?

    Okay, I think I found my problem.
    I was trying to run the script created by Oracle Explorer directly from a Database project I added to my Solution in Visual Studio. Visual Studio is probably using some SQL Server specific tool when I select the Run or Run On option on the script.
    When running the same script directly in the Oracle 10g Home Page (Home > SQL > SQL Scripts), I had no problem. Everything executes correctly.
    Is anyone aware of another way to run Oracle scripts directly from Visual Studio? Do I have my project setup incorrectly? This is the first project I've used .NET and Oracle together, so if anyone has any suggestions, I'd really appreciate the help.
    Thanks,
    Mycole

  • Issue with Generate Create Script in new ODT 11.1.0.5.10 beta

    So I'm trying to determine if there's an issue with the Generate Create Script option in the new ODT 11.1.0.5.10 beta (when you right click on a table in Server Explorer).
    The SQL create script that it generates lacks the slash between lines. For example I generated the create script for my User table and this is what was generated:
    CREATE TABLE "DEV"."SYSTEM_USER_TB" ("RID" NUMBER(10,0),"USER_NAME" VARCHAR2(256 CHAR),"APPLICATION_RID" NUMBER(10,0),"FIRST_NAME" VARCHAR2(256 CHAR),"LAST_NAME" VARCHAR2(256 CHAR),"PW" VARCHAR2(128 CHAR),"PW_FORMAT" NUMBER,"PW_SALT" VARCHAR2(128 CHAR),"LAST_ACTIVITY_DT" DATE,"EXPIRATION_DT" DATE,"EMAIL" VARCHAR2(256 CHAR),"PW_QUESTION" VARCHAR2(256 CHAR),"PW_ANSWER" VARCHAR2(256 CHAR),"APPROVED_FLG" NUMBER(1,0),"LOCKED_OUT_FLG" NUMBER(1,0),"LAST_LOGIN_DT" DATE,"LAST_PW_CHANGED_DT" DATE,"LAST_LOCKOUT_DT" DATE,"FAILED_PW_ATTEMPT_CNT" NUMBER(6,0),"FAILED_PW_ATTEMPT_WINSTART" DATE,"FAILED_PW_ANSW_ATTEMPT_CNT" NUMBER(8,0),"FAILED_PW_ANSW_ATTEMPT_WINSTRT" DATE,"CREATED_BY_RID" NUMBER(10,0),"CREATED_DT" DATE,"MODIFIED_BY_RID" NUMBER(10,0),"MODIFIED_DT" DATE) TABLESPACE "USERS" PCTFREE 10 INITRANS 1 MAXTRANS 255 STORAGE ( INITIAL 131072 MAXEXTENTS 2147483645 MINEXTENTS 1 )
    CREATE UNIQUE INDEX "DEV"."XPKSTAFF" ON "DEV"."SYSTEM_USER_TB" ("RID" ) TABLESPACE "USERS"
    ALTER TABLE "DEV"."SYSTEM_USER_TB" ADD ( CONSTRAINT "SYS_C0033033" PRIMARY KEY ("RID") USING INDEX "DEV"."XPKSTAFF" ENABLE VALIDATE )
    ALTER TABLE "DEV"."SYSTEM_USER_TB" ADD ( CONSTRAINT "SYS_C0033032" CHECK ("RID" IS NOT NULL) ENABLE VALIDATE )
    CREATE TRIGGER "DEV"."SYSTEM_USER_TRG1"
    BEFORE
    INSERT
    ON "DEV"."SYSTEM_USER_TB"
    FOR EACH ROW
    begin
         select SYSTEM_USER_SEQ.nextval into :new.RID from dual;
    end;
    In my new Oracle Database Project, if I right click on the script and select "Run" or "Run On", the script fails saying:
    Connected.
    CREATE UNIQUE INDEX "DEV"."XPKSTAFF" ON "DEV"."SYSTEM_USER_TB" ("RID" ) TABLESPACE "USERS"
    ERROR at line 2:
    ORA-00922: missing or invalid option
    If I then add, a slash between lines, the script runs successfully and creates the table/trigger and whatever else just fine. For example, I changed the above generated code to look as follows:
    CREATE TABLE "DEV"."SYSTEM_USER_TB" ("RID" NUMBER(10,0),"USER_NAME" VARCHAR2(256 CHAR),"APPLICATION_RID" NUMBER(10,0),"FIRST_NAME" VARCHAR2(256 CHAR),"LAST_NAME" VARCHAR2(256 CHAR),"PW" VARCHAR2(128 CHAR),"PW_FORMAT" NUMBER,"PW_SALT" VARCHAR2(128 CHAR),"LAST_ACTIVITY_DT" DATE,"EXPIRATION_DT" DATE,"EMAIL" VARCHAR2(256 CHAR),"PW_QUESTION" VARCHAR2(256 CHAR),"PW_ANSWER" VARCHAR2(256 CHAR),"APPROVED_FLG" NUMBER(1,0),"LOCKED_OUT_FLG" NUMBER(1,0),"LAST_LOGIN_DT" DATE,"LAST_PW_CHANGED_DT" DATE,"LAST_LOCKOUT_DT" DATE,"FAILED_PW_ATTEMPT_CNT" NUMBER(6,0),"FAILED_PW_ATTEMPT_WINSTART" DATE,"FAILED_PW_ANSW_ATTEMPT_CNT" NUMBER(8,0),"FAILED_PW_ANSW_ATTEMPT_WINSTRT" DATE,"CREATED_BY_RID" NUMBER(10,0),"CREATED_DT" DATE,"MODIFIED_BY_RID" NUMBER(10,0),"MODIFIED_DT" DATE) TABLESPACE "USERS" PCTFREE 10 INITRANS 1 MAXTRANS 255 STORAGE ( INITIAL 131072 MAXEXTENTS 2147483645 MINEXTENTS 1 )
    CREATE UNIQUE INDEX "DEV"."XPKSTAFF" ON "DEV"."SYSTEM_USER_TB" ("RID" ) TABLESPACE "USERS"
    ALTER TABLE "DEV"."SYSTEM_USER_TB" ADD ( CONSTRAINT "SYS_C0033033" PRIMARY KEY ("RID") USING INDEX "DEV"."XPKSTAFF" ENABLE VALIDATE )
    ALTER TABLE "DEV"."SYSTEM_USER_TB" ADD ( CONSTRAINT "SYS_C0033032" CHECK ("RID" IS NOT NULL) ENABLE VALIDATE )
    CREATE TRIGGER "DEV"."SYSTEM_USER_TRG1"
    BEFORE
    INSERT
    ON "DEV"."SYSTEM_USER_TB"
    FOR EACH ROW
    begin
         select SYSTEM_USER_SEQ.nextval into :new.RID from dual;
    end;
    So, does anyone know if this is a bug? Could I be missing an option to add in the slashes to the generated code? Is there an option to not require the slashes? Could there be another way to execute these scripts?
    Seriously, I think I'm having deja vu from the last release of the Dev Tools: Generate Create Script creates scripts that won't run: ORA-00922: missing..
    ...except this time the documentation says I should be able to use the "Run" and "Run On" commands in the Oracle Database Project (see page 8): http://www.oracle.com/technology/tech/dotnet/pdf/ODT11_whatsnew.pdf
    null

    There are 2 issues in the generated script :
    1. Missing semicolons at the end of the create stmts
    2. Missing slashes
    Both of these fixes will be available in the ODT 11.1 release.

  • How to generate sql script based on table structure

    I want to generate a sql script based on a table structure.
    For example:
    if the table is:
    cid id c_value
    1 1 zz
    2 1 yy
    3 2 zz
    4 2 xx
    5 3 ss
    6 3 tt
    The expected output is:
    WITH
    CHILD_tab as (
    SELECT 1 cid, 1 id,'zz' c_value from dual union all
    SELECT 2 cid, 1 id,'yy' c_value from dual union all
    SELECT 3 cid, 2 id,'zz' c_value from dual union all
    SELECT 4 cid, 2 id,'xx' c_value from dual union all
    SELECT 5 cid, 3 id,'ss' c_value from dual union all
    SELECT 6 cid, 3 id,'tt' c_value from dual )
    Release 11.1.0.7.0

    I'm doing a lot of XML these days (too much perhaps) so here's a solution involving XQuery.
    We pass a query string and it outputs a CLOB containing the WITH clause :
    SELECT DBMS_XMLGEN.Convert(
    XMLQuery(
    q'[concat(
    "WITH t AS (
    string-join(
    for $i in /ROWSET/ROW
    return concat( " SELECT ",
                    string-join($i/*/concat("'",ora:replace(text(),"'","''"),"' ",local-name()),", "),
                    " FROM dual" ),
    " UNION ALL
    passing dbms_xmlgen.getXMLType('SELECT * FROM scott.emp')
    returning content
    ).getClobVal(), 1) AS WITH_CLAUSE
    FROM dual;
    WITH_CLAUSE
    WITH t AS (
    SELECT '7369' EMPNO, 'SMITH' ENAME, 'CLERK' JOB, '7902' MGR, '17/12/80' HIREDATE, '800' SAL, '20' DEPTNO FROM dual UNION ALL
    SELECT '7499' EMPNO, 'ALLEN' ENAME, 'SALESMAN' JOB, '7698' MGR, '20/02/81' HIREDATE, '1600' SAL, '300' COMM, '30' DEPTNO FROM dual UNION ALL
    SELECT '7521' EMPNO, 'WARD' ENAME, 'SALESMAN' JOB, '7698' MGR, '22/02/81' HIREDATE, '1250' SAL, '500' COMM, '30' DEPTNO FROM dual UNION ALL
    SELECT '7566' EMPNO, 'JONES' ENAME, 'MANAGER' JOB, '7839' MGR, '02/04/81' HIREDATE, '2975' SAL, '20' DEPTNO FROM dual UNION ALL
    SELECT '7654' EMPNO, 'MARTIN' ENAME, 'SALESMAN' JOB, '7698' MGR, '28/09/81' HIREDATE, '1250' SAL, '1400' COMM, '30' DEPTNO FROM dual UNION ALL
    SELECT '7698' EMPNO, 'BLAKE' ENAME, 'MANAGER' JOB, '7839' MGR, '01/05/81' HIREDATE, '2850' SAL, '30' DEPTNO FROM dual UNION ALL
    SELECT '7782' EMPNO, 'CLARK' ENAME, 'MANAGER' JOB, '7839' MGR, '09/06/81' HIREDATE, '2450' SAL, '10' DEPTNO FROM dual UNION ALL
    SELECT '7788' EMPNO, 'SCOTT' ENAME, 'ANALYST' JOB, '7566' MGR, '19/04/87' HIREDATE, '3000' SAL, '20' DEPTNO FROM dual UNION ALL
    SELECT '7839' EMPNO, 'KING' ENAME, 'PRESIDENT' JOB, '17/11/81' HIREDATE, '5000' SAL, '10' DEPTNO FROM dual UNION ALL
    SELECT '7844' EMPNO, 'TURNER' ENAME, 'SALESMAN' JOB, '7698' MGR, '08/09/81' HIREDATE, '1500' SAL, '0' COMM, '30' DEPTNO FROM dual UNION ALL
    SELECT '7876' EMPNO, 'ADAMS' ENAME, 'CLERK' JOB, '7788' MGR, '23/05/87' HIREDATE, '1100' SAL, '20' DEPTNO FROM dual UNION ALL
    SELECT '7900' EMPNO, 'JAMES' ENAME, 'CLERK' JOB, '7698' MGR, '03/12/81' HIREDATE, '950' SAL, '30' DEPTNO FROM dual UNION ALL
    SELECT '7902' EMPNO, 'FORD' ENAME, 'ANALYST' JOB, '7566' MGR, '03/12/81' HIREDATE, '3000' SAL, '20' DEPTNO FROM dual UNION ALL
    SELECT '7934' EMPNO, 'MILLER' ENAME, 'CLERK' JOB, '7782' MGR, '23/01/82' HIREDATE, '1300' SAL, '10' DEPTNO FROM dual
    )It may be useful for small data sets only because we quickly hit ORA-01706.

  • How to automatically create the custom migration scripts after recreating SSMA project?

    How to automatically create the custom data migration scripts after recreating SSMA project?
    There is number of tables ( big tables with BLOBS)  which I want to set up automatically to be migrated with custom migration scripts (replacing e.g. attribute named "FILE" with "TO_BLOB('') AS FILE" ).
    So the question is how to open MB file (I think that it should be standard db of some destktop RDBMS) ? 

    Hi Roman.Pokrovskij,
    According
    to your description, we can use SSMA tool to migrate data from one database (including Access, Oracle and so on) to SQL Server via GUI or the scripts. There is an example about migrating Access database to SQL Server via the
    custom migration scripts, you can review refer to them.
    <?xml version="1.0" encoding="utf-8"?>
    <ssma-script-file xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="C:\Microsoft SQL Server Migration Assistant for Access\Schemas\A2SSConsoleScriptSchema.xsd">
    <config>
    <output-providers>
    <output-window suppress-messages="false"
    destination="stdout"/>
    <upgrade-project action="yes"/>
    <data-migration-connection source-use-last-used="true"
    target-server="target_1"/>
    <progress-reporting enable="false"
    report-messages="false"
    report-progress="off"/>
    <object-overwrite action="skip" />
    </output-providers>
    </config>
    <servers>
    <!-- Server definition for Sql server target server-->
    <sql-server name="target_1">
    <sql-server-authentication>
    <server value="$SQLServerName$"/>
    <database value="$SQLServerDb$"/>
    <user-id value="$SQLServerUsrID$"/>
    <password value="$SQLServerPassword$"/>
    <encrypt value="true"/>
    <trust-server-certificate value="true"/>
    </sql-server-authentication>
    </sql-server>
    </servers>
    <script-commands>
    <create-new-project project-folder="$project_folder$ "
    project-name="$project_name$"
    overwrite-if-exists="true"/>
    <connect-target-database server="target_1"/>
    <load-access-database database-file="$AccessDbFolder$\$AccessDatabaseFile$"/>---
    <!--Schema Mapping-->
    <map-schema source-schema="$AccessDatabase$" sql-server-schema="$SQLServerDb$.dbo" />
    <!-- Convert schema -->
    <!-- Example: Convert entire Schema (with all attributes)-->
    <convert-schema object-name="$AccessDatabase$"
    object-type="Databases"
    conversion-report-overwrite="true"
    verbose="true"
    report-errors="true" />
    <!-- Synchronize target -->
    <!-- Example: Synchronize target entire Database with all attributes-->
    <synchronize-target object-name="$SQLServerDb$.dbo"
    on-error="fail-script" />
    <!-- Data Migration-->
    <!--Example: Data Migration of all tables in the schema (with all attributes)-->
    <migrate-data object-name="$AccessDatabase$.Tables"
    object-type="category"
    report-errors="true"
    verbose="true"/>
    </script-commands>
    </ssma-script-file>
    There is a similar scripts about migrating Oracle database to SQL Server, you can use powershell script to automatically run the console for scripts/variable files, saved in the specified folder. For more information, review the following
    article.
    http://blogs.msdn.com/b/ssma/archive/2010/09/09/performing-database-migration-assessment-using-ssma-console-application.aspx
    Regards,
    Sofiya Li
    Sofiya Li
    TechNet Community Support

  • Hlw_events table create script requested

    To whom it may respond to,
    I couldn't find out the demo schema , I simply need hlw_events table create script,
    Thank you for your concern,
    Kayhan YÜKSEL

    Here it is:
    CREATE TABLE "HLW_EVENTS" ("EVENT_ID" NUMBER(10, 0) NOT NULL ENABLE, "EMPLOYEE_ID" NUMBER(6, 0), "DEPARTMENT_NO" NUMBER(6, 0), "EVENT_START_DATE" DATE NOT NULL ENABLE, "EVENT_END_DATE" DATE, "START_TIME" DATE, "END_TIME" DATE, "EVENT_TITLE" VARCHAR2(30) NOT NULL ENABLE, "EVENT_DESCRIPTION" VARCHAR2(1000), "EVENT_NOTE" VARCHAR2(1000), "EVENT_COMPLETED" VARCHAR2(1) NOT NULL ENABLE)
    But, I am curious as to why you want to setup a WebDB demo schema?
    Cheers,
    Mick

  • How can I create scripts from DBA studio??

    I just created about a bunch of tables, F&P keys, synonyms, etc using DBA studio. Now I'd like to extract that dictionary data to create scripts that I can run in the future to recreate the environment in production.
    How can I do this?
    THanks,
    Chris

    For some reason in my Oracle DBA Studio ( Oralce 8.1.6) table right click menu has no "Show object DDL" option. I run DBA Studio standalone, not from Oracle Enterpr Manager. Can this be the reason ?
    Also my database has 100+ tables.
    I also tried the import with indexfile option. It is gives me all a lot of ALTERs as they where applied to tables which looks UGLY. I need "clean" CREATE TABLE DDL.
    I's amaizing that Oracle has no simple way of doing this ???

  • BI 7 : Command to export a table structure of SAP R/3 into a script/text ?

    Hi All.
    Greetings.
    Am New to SAP R/3 system.  And request help.
    We are trying to pull data from SAP R/3 thro Bussiness Objects Data Services into Oracle.
    For now : we create a target oracle table looking at the table structure of SAP R/3 from SE 11.
    In BODS, We then do the query transformation, and use the oracle target table created by us manually.
    This works absolutely fine.
    We would like to know the command by which we could export the table structure of any existing table
    in SAP R/3 into a script / or to text file,
    which we could use to create the same table structure in oracle.
    Rather than manually typing some 200 field names for each tables.
    Can anyone advise on this.
    Thanks
    Indu

    Hello,
    The problem is caused due to the spaces in your directories
    C:\SAP Dumps\Core Release SR1 Export_CD1_51019634/DB/ADA/DBSIZE.XML
    Replace the spaces with underscores and restart the installation from from scratch.
    Cheers
    Bert

  • Get "Creation Script" of the existing table ( in SQL database) using C# and without using SMO dlls

    Hi All,
    I need to get the "Creation Script" of the existing table using c# and without using SMO dlls (is it possible? I don't know).
    I.e. In SQL Management Studio -> right click on any table -> Script table as -> Create To  - > open in the new query editor window. This will give you the schema of the table with the constraints of the table.
    For E.g. In Northwind database, for the table "Categories", I would like to get it as show below
    USE [Northwind]
    GO
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[Categories](
        [CategoryID] [int] IDENTITY(1,1) NOT NULL,
        [CategoryName] [nvarchar](15) NOT NULL,
        [Description] [ntext] NULL,
        [Picture] [image] NULL,
     CONSTRAINT [PK_Categories] PRIMARY KEY CLUSTERED
        [CategoryID] ASC
    )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
    ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
    GO
    I would like to get the same schema using c#. Please help.
    Thanks & Regards,
    Kalai.

    SMO is the easiest way to get this. This is what Management Studio uses. If you can't use SMO, get a Profiler trace of the queries that SMO executes when generating the script and execute the same using ADO.NET.
    Regards,
    Farooq Mahmud
    Support Escalation Engineer 
    •  Microsoft Health Solutions Group

  • Not able to create EM repository - ORA-00942: table or view does not exist

    -bash-3.00$ emca -config dbcontrol db -repos recreate
    STARTED EMCA at 2010-06-02 12:12:29
    EM Configuration Assistant, Version 10.2.0.1.0 Production
    Copyright (c) 2003, 2005, Oracle.  All rights reserved.
    Enter the following information:
    Database SID: eric1
    Listener port number: 1521
    Password for SYS user:
    Password for DBSNMP user:
    Password for SYSMAN user:
    Email address for notifications (optional):
    Outgoing Mail (SMTP) server for notifications (optional):
    You have specified the following settings
    Database ORACLE_HOME ................ /oracle/product/10.2.0/db_1
    Database hostname ................ solx
    Listener port number ................ 1521
    Database SID ................ eric1
    Email address for notifications ...............
    Outgoing Mail (SMTP) server for notifications ...............
    Do you wish to continue? [yes(Y)/no(N)]: Y
    2010-06-02 12:12:52 oracle.sysman.emcp.EMConfig perform
    INFO: This operation is being logged at /oracle/product/10.2.0/db_1/cfgtoollogs/emca/eric1/emca_2010-06-02_12-12-29-PM.log.
    2010-06-02 12:13:02 oracle.sysman.emcp.EMReposConfig dropRepository
    INFO: Dropping the EM repository (this may take a while) ...
    2010-06-02 12:13:05 oracle.sysman.emcp.util.PlatformInterface executeCommand
    WARNING: Error executing /oracle/product/10.2.0/db_1/sysman/admin/emdrep/bin/RepManager -connect (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=solx)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=eric1))) -repos_user SYSMAN -action drop -verbose -output_file /oracle/product/10.2.0/db_1/cfgtoollogs/emca/eric1/emca_repos_drop_2010-06-02_12-13-02-PM.log
    2010-06-02 12:13:05 oracle.sysman.emcp.EMReposConfig invoke
    SEVERE: Error dropping the repository
    2010-06-02 12:13:05 oracle.sysman.emcp.EMReposConfig invoke
    INFO: Refer to the log file at /oracle/product/10.2.0/db_1/cfgtoollogs/emca/eric1/emca_repos_drop_<date>.log for more details.
    2010-06-02 12:13:05 oracle.sysman.emcp.EMConfig perform
    SEVERE: Error dropping the repository
    Refer to the log file at /oracle/product/10.2.0/db_1/cfgtoollogs/emca/eric1/emca_2010-06-02_12-12-29-PM.log for more details.
    Could not complete the configuration. Refer to the log file at /oracle/product/10.2.0/db_1/cfgtoollogs/emca/eric1/emca_2010-06-02_12-12-29-PM.log for more details.So I looked into a log file: /oracle/product/10.2.0/db_1/cfgtoollogs/emca/eric1/emca_2010-06-02_12-12-29-PM.log
    Here is an end of it ( I can paste all log file if necessary but it is very long):
    CONFIG: Starting execution: /oracle/product/10.2.0/db_1/sysman/admin/emdrep/bin/RepManager -connect (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=solx)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=eric1))) -repos_user SYSMAN -action drop -verbose -output_file /oracle/product/10.2.0/db_1/cfgtoollogs/emca/eric1/emca_repos_drop_2010-06-02_12-13-02-PM.log
    2010-06-02 12:13:05 oracle.sysman.emcp.util.PlatformInterface executeCommand
    CONFIG: Exit value of 51
    2010-06-02 12:13:05 oracle.sysman.emcp.util.PlatformInterface executeCommand
    CONFIG: Enter SYS user's password :
    Enter repository user password :
    Getting temporary tablespace from database...
    prepare(SELECT tablespace_name FROM dba_tablespaces WHERE contents='TEMPORARY'  AND status='ONLINE'): ORA-00942: table or view does not exist (DBD ERROR: error possibly near <*> indicator at char 28 in 'SELECT tablespace_name FROM <*>dba_tablespaces WHERE contents='TEMPORARY'  AND status='ONLINE'')
    2010-06-02 12:13:05 oracle.sysman.emcp.util.PlatformInterface executeCommand
    CONFIG: stty: : No such device or address
    stty: : No such device or address
    stty: : No such device or address
    stty: : No such device or address
    2010-06-02 12:13:05 oracle.sysman.emcp.util.PlatformInterface executeCommand
    WARNING: Error executing /oracle/product/10.2.0/db_1/sysman/admin/emdrep/bin/RepManager -connect (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=solx)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=eric1))) -repos_user SYSMAN -action drop -verbose -output_file /oracle/product/10.2.0/db_1/cfgtoollogs/emca/eric1/emca_repos_drop_2010-06-02_12-13-02-PM.log
    2010-06-02 12:13:05 oracle.sysman.emcp.EMReposConfig invoke
    SEVERE: Error dropping the repository
    2010-06-02 12:13:05 oracle.sysman.emcp.EMReposConfig invoke
    INFO: Refer to the log file at /oracle/product/10.2.0/db_1/cfgtoollogs/emca/eric1/emca_repos_drop_<date>.log for more details.
    2010-06-02 12:13:05 oracle.sysman.emcp.EMConfig perform
    SEVERE: Error dropping the repository
    Refer to the log file at /oracle/product/10.2.0/db_1/cfgtoollogs/emca/eric1/emca_2010-06-02_12-12-29-PM.log for more details.
    2010-06-02 12:13:05 oracle.sysman.emcp.EMConfig perform
    CONFIG: Stack Trace:
    oracle.sysman.emcp.exception.EMConfigException: Error dropping the repository
            at oracle.sysman.emcp.EMReposConfig.invoke(EMReposConfig.java:176)
            at oracle.sysman.emcp.EMReposConfig.invoke(EMReposConfig.java:127)
            at oracle.sysman.emcp.EMConfig.perform(EMConfig.java:142)
            at oracle.sysman.emcp.EMConfigAssistant.invokeEMCA(EMConfigAssistant.java:479)
            at oracle.sysman.emcp.EMConfigAssistant.performConfiguration(EMConfigAssistant.java:1123)
            at oracle.sysman.emcp.EMConfigAssistant.statusMain(EMConfigAssistant.java:463)
            at oracle.sysman.emcp.EMConfigAssistant.main(EMConfigAssistant.java:412)...and here I can easly see that error: ORA-00942: table or view does not exist.
    But what does it mean to me ? I mean what should I ro to create/recreate missing table or view ?

    Hi, so here are my tries:
    1. admin:
    Below Dirs dont not exist:
    <ORACLE_HOME>/<hostname_sid>
    <ORACLE_HOME>/oc4j/j2ee/OC4J_DBConsole_<hostname>_<sid>
    ...also it was unable to drop user - does not exist
    -bash-3.00$ sqlplus "/as sysdba"
    SQL*Plus: Release 10.2.0.2.0 - Production on Wed Jun 2 12:55:44 2010
    Copyright (c) 1982, 2005, Oracle.  All Rights Reserved.
    Connected to:
    Oracle Database 10g Release 10.2.0.2.0 - Production
    SQL> sqlplus "/as sysdba"
    drop user sysman cascade;
    drop role MGMT_USER;
    drop user MGMT_VIEW cascade;
    drop public synonym MGMT_TARGET_BLACKOUTS;
    drop public synonym SETEMVIEWUSERCONTEXT;
    SP2-0734: unknown command beginning "sqlplus "/..." - rest of line ignored.
    SQL> drop user sysman cascade
    ERROR at line 1:
    ORA-01918: user 'SYSMAN' does not exist
    SQL> drop role MGMT_USER
    ERROR at line 1:
    ORA-01919: role 'MGMT_USER' does not exist
    SQL> drop user MGMT_VIEW cascade
    ERROR at line 1:
    ORA-01918: user 'MGMT_VIEW' does not exist
    SQL> drop public synonym MGMT_TARGET_BLACKOUTS
    ERROR at line 1:
    ORA-01432: public synonym to be dropped does not exist
    SQL> drop public synonym SETEMVIEWUSERCONTEXT
    ERROR at line 1:
    ORA-01432: public synonym to be dropped does not exist
    {code}
    I also tried this:
    2. coskan         
    {code}
    -bash-3.00$ sqlplus sys/qaz123@eric1 as sysdba
    SQL*Plus: Release 10.2.0.2.0 - Production on Wed Jun 2 12:51:34 2010
    Copyright (c) 1982, 2005, Oracle.  All Rights Reserved.
    Connected to:
    Oracle Database 10g Release 10.2.0.2.0 - Production
    SQL> SELECT tablespace_name FROM dba_tablespaces WHERE contents='TEMPORARY' AND status='ONLINE';
    SELECT tablespace_name FROM dba_tablespaces WHERE contents='TEMPORARY' AND status='ONLINE'
    ERROR at line 1:
    ORA-00942: table or view does not exist
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Issue with Generate Create Script in new ODT 11.1.0.6.10 beta

    I've tried this on several tables in my database. I choose Generate Script to ... a file, for a given table it gives me the error message "An error occurred while writing to fil: \nValue was either too large or too smal for an Int32."
    (It doesn't matter if I'm in a Oracle database project or some other project.)
    Trying to Generate Script To Project... when I'm in a Oracle Database Project, Visual Studio (2005) crashes. It appears to be some overflow exception according to crashinfo:
    EventType : clr20r3 P1 : devenv.exe P2 : 8.0.50727.762 P3 : 45716759
    P4 : mscorlib P5 : 2.0.0.0 P6 : 461eee3d P7 : 407b P8 : a3
    P9 : system.overflowexception
    (With ODT 11.1.0.5.10 beta it worked fine dispite the issue discussed in thread: Re: Issue with Generate Create Script in new ODT 11.1.0.5.10 beta
    /Tomas

    Tried to debug this error and got these exception details. Hope it helps!
    /Tomas
    System.OverflowException was unhandled
    Message="Value was either too large or too small for an Int32."
    Source="mscorlib"
    StackTrace:
    Server stack trace:
    at System.Decimal.ToInt32(Decimal d)
    at System.Decimal.op_Explicit(Decimal value)
    at Oracle.Management.Omo.TableSpaceQuotaDetails.FillTableSpaceQuota(OracleDataReader reader)
    at Oracle.Management.Omo.User.FillTableSpaceQuotas(OracleDataReader reader)
    at Oracle.Management.Omo.Connection.GetUserCollection(Boolean refresh)
    at Oracle.Management.Omo.Connection.GetUsers(Boolean refresh)
    at Oracle.Management.Omo.TableSQLGenerator.GetCreateSQLs(OmoObject obj, ArrayList& typeAndNames, Boolean checkRequired, Boolean appendSchemaName)
    at Oracle.Management.Omo.TableViewBase.GetCreateSQLs(Boolean appendSchemaName)
    at Oracle.VsDevTools.OracleUILDBProjectServices.GenerateCreateScript(OracleUILConnCtx connCtx, String[] objectNames, String objectOwner, OracleUILObjectType objectType)
    at Oracle.VsDevTools.OracleUILDBProjectServices.GenerateCreateScriptAsyncMethod(IntPtr ppvObj, OracleUILConnCtx connCtx, String[] objectNames, String objectOwner, OracleUILObjectType objectType, ICollection& scriptText)
    at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
    at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(RuntimeMethodHandle md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
    at System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)
    Exception rethrown at [0]:
    at System.Runtime.Remoting.Proxies.RealProxy.EndInvokeHelper(Message reqMsg, Boolean bProxyCase)
    at System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(Object NotUsed, MessageData& msgData)
    at Oracle.VsDevTools.OracleUILDBProjectServices.GenerateScriptAsyncMethodDelegate.EndInvoke(ICollection& scriptText, IAsyncResult result)
    at Oracle.VsDevTools.OracleUILDBProjectServices.OnGenerateScriptAsyncCompletion(IAsyncResult ar)
    at System.Runtime.Remoting.Messaging.AsyncResult.SyncProcessMessage(IMessage msg)
    at System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)
    at System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.ThreadPoolCallBack(Object o)
    at System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(Object state)
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
    at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object state)

  • Script for Compare same table 'TAB1' structures in different schemas

    Hello, i am having three schema and in all schema i have same table for example TAB1 and i want to Compare TAB1 table structures in all three schema but i don't know the script. the different should content at least  DATA_TYPE,DATA_LENGTH,DECODE(DATA_PRECISION,NULL,NULL,DATA_PRECISION||','||DATA_SCALE) columns in query. Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi Thanks..

    If you want a generic script use below function to get the difference.. Run the below script and let me know in case of any issues
    CREATE OR REPLACE TYPE nt_username IS TABLE OF VARCHAR2(50);
    CREATE OR REPLACE TYPE obj_struc IS OBJECT (user_name1     VARCHAR2(30),
                                               user_name2      VARCHAR2(30),
                                               column_name1    VARCHAR2(30),
                                               column_name2    VARCHAR2(30),
                                               data_type1      VARCHAR2(106),
                                               data_type2      VARCHAR2(106),
                                               data_length1    NUMBER(10),
                                               data_length2    NUMBER(10),
                                               data_precision1 VARCHAR2(50),
                                               data_precision2 VARCHAR2(50),
                                               column_id1      NUMBER(10),
                                               column_id2      NUMBER(10)
    CREATE OR REPLACE TYPE nt_struc IS TABLE OF obj_struc;
    CREATE OR REPLACE FUNCTION tabstruc_script (p_tabnm   VARCHAR2,
                                                p_usernm  nt_username
    RETURN nt_struc
    AS
    v_nt_struc nt_struc := nt_struc();
    v_ntusrnm nt_username := p_usernm;
    TYPE rec_stru IS RECORD (column_name    all_tab_columns.column_name%TYPE,
                             data_type      all_tab_columns.data_type%TYPE,
                             data_length    all_tab_columns.data_length%TYPE,
                             data_precision all_tab_columns.data_precision%TYPE,
                             data_scale     all_tab_columns.data_scale%TYPE,
                             column_id      all_tab_columns.column_id%TYPE
    TYPE nt_stru IS TABLE OF rec_stru;
    v_ntstru nt_stru  := nt_stru();
    v_columnname all_tab_columns.column_name%TYPE;
    v_reccnt NUMBER;
    v_cnt NUMBER;
    v_precision1 VARCHAR2(50);
    v_precision2 VARCHAR2(50);                    
    BEGIN
    FOR i IN 1..v_ntusrnm.COUNT
      LOOP
         SELECT COUNT(*) INTO v_reccnt
         FROM all_tables
         WHERE owner = v_ntusrnm(i)
         AND table_name = p_tabnm;
          IF v_reccnt >= 1 THEN
             SELECT column_name,  
                    data_type,    
                    data_length, 
                    data_precision,
                    data_scale,
                    column_id
             BULK COLLECT INTO v_ntstru
             FROM all_tab_columns
             WHERE owner = v_ntusrnm(i)
             AND table_name = p_tabnm;
              FOR j IN i+1..v_ntusrnm.COUNT
                LOOP
                     FOR k IN 1..v_ntstru.COUNT
                       LOOP
                          SELECT COUNT(*) INTO v_cnt
                          FROM all_tab_columns
                          WHERE owner = v_ntusrnm(j)
                          AND table_name = p_tabnm
                          AND column_name = v_ntstru(k).column_name;
                           IF v_cnt >= 1 THEN
                             FOR l IN (SELECT column_name,  
                                              data_type,    
                                              data_length, 
                                              data_precision,
                                              data_scale,
                                              column_id
                                       FROM all_tab_columns
                                       WHERE owner = v_ntusrnm(j)
                                       AND table_name = p_tabnm
                                       AND column_name = v_ntstru(k).column_name)
                                LOOP
                                  IF ((v_ntstru(k).column_id <> l.column_id)
                                      OR (v_ntstru(k).data_type <> l.data_type)
                                      OR (NVL(v_ntstru(k).data_length,0) <> NVL(l.data_length,0))
                                      OR (NVL(v_ntstru(k).data_precision,0) <> NVL(l.data_precision,0))
                                      OR (NVL(v_ntstru(k).data_scale,0) <> NVL(l.data_scale,0))) THEN
                                     v_nt_struc.EXTEND;
                                     SELECT DECODE(v_ntstru(k).data_precision,NULL,NULL,v_ntstru(k).data_precision||','||v_ntstru(k).data_scale),
                                            DECODE(l.data_precision,NULL,NULL,l.data_precision||','||l.data_scale)
                                     INTO v_precision1,
                                          v_precision2
                                     FROM DUAL;
                                     v_nt_struc(v_nt_struc.COUNT) := obj_struc(v_ntusrnm(i),
                                                                               v_ntusrnm(j),
                                                                               v_ntstru(k).column_name,
                                                                               l.column_name,
                                                                               v_ntstru(k).data_type,
                                                                               l.data_type,
                                                                               v_ntstru(k).data_length,
                                                                               l.data_length,
                                                                               v_precision1,
                                                                               v_precision2,
                                                                               v_ntstru(k).column_id,
                                                                               l.column_id);
                                  END IF;
                                END LOOP;
                           END IF;
                       END LOOP;
                      FOR m IN(SELECT column_name,  
                                      data_type,    
                                      data_length, 
                                      data_precision,
                                      data_scale,
                                      column_id
                               FROM all_tab_columns
                               WHERE owner = v_ntusrnm(i)
                               AND table_name = p_tabnm
                               AND column_name NOT IN(SELECT column_name
                                                      FROM all_tab_columns
                                                      WHERE owner = v_ntusrnm(j)
                                                      AND table_name = p_tabnm))
                          LOOP                                         
                            v_nt_struc.EXTEND;
                            SELECT DECODE(m.data_precision,NULL,NULL,m.data_precision||','||m.data_scale)
                            INTO v_precision1
                            FROM DUAL;
                            v_nt_struc(v_nt_struc.COUNT) := obj_struc(v_ntusrnm(i),
                                                                      v_ntusrnm(j),
                                                                      m.column_name,
                                                                      NULL,
                                                                      m.data_type,
                                                                      NULL,
                                                                      m.data_length,
                                                                      NULL,
                                                                      v_precision1,
                                                                      NULL,
                                                                      m.column_id,
                                                                      NULL);
                          END LOOP;
                         FOR n IN(SELECT column_name,  
                                          data_type,    
                                          data_length, 
                                          data_precision,
                                          data_scale,
                                          column_id
                                   FROM all_tab_columns
                                   WHERE owner = v_ntusrnm(j)
                                   AND table_name = p_tabnm
                                   AND column_name NOT IN(SELECT column_name
                                                          FROM all_tab_columns
                                                          WHERE owner = v_ntusrnm(i)
                                                          AND table_name = p_tabnm))
                           LOOP
                            v_nt_struc.EXTEND;
                            SELECT DECODE(n.data_precision,NULL,NULL,n.data_precision||','||n.data_scale)
                            INTO v_precision2
                            FROM DUAL;
                            v_nt_struc(v_nt_struc.COUNT) := obj_struc(v_ntusrnm(j),
                                                                      v_ntusrnm(i),
                                                                      n.column_name,
                                                                      NULL,
                                                                      n.data_type,
                                                                      NULL,
                                                                      n.data_length,
                                                                      NULL,
                                                                      v_precision2,
                                                                      NULL,
                                                                      n.column_id,
                                                                      NULL);
                           END LOOP;
                        END LOOP;
            END IF;
      END LOOP;
    RETURN v_nt_struc;
    EXCEPTION
    WHEN OTHERS THEN
      RAISE;
    END tabstruc_script;
    SELECT * FROM TABLE(tabstruc_script(:tabnm,nt_username(:user1,:user2,:user3)));
    You need to pass tablename and username to calling this function. Username is a nested table here so you can pass like nt_username(:user1,:user2,:user3)

Maybe you are looking for

  • Applying an LOV to a dynamically populated VO

    I am a newbie at ADF so I'm not totally sure how to explain this. But I have a generic VO defined as a part of say a common popup picker which populates a table based on an already defined VOs. My requirement is for one such VO that I have defined wh

  • Connect macbook pro to HP laptop [Vista OS]

    Hi All, I am really not all that clued up about things in networking, I was needing to transfer a few files from my macbook pro laptop to a HP laptop. I had hoped to use ethernet as I did not have a large enough flash drive. I connected the 2 laptops

  • Help required on netview and pipe()

    http://forum.java.sun.com/thread.jspa?threadID=202103&tstart=60 last post tells prob is being solved by Netview and pipe but I cud nt find much abt these either on sun /google. So can ny1 give out details abt these. references if possible

  • Marketplace and Multiple DDID

    Hi everyone, I'm sory for asking a question that was already posted here in the forum. I'm just doing that, because i never found an answer to this. Imagine i have one BPM to transform IDocs to XCBL and send (Purchase) Orders to suppliers. He use a t

  • Installing photoshop elements 8

    i had a chat the other day as i have this programme on another defunct computer.  it was released but now i have the problem that when i am trying to install on my new laptop i get as far as the preparig to install screen and then get the message 'sy