Renaming Constraints In 8i

I was wondering if it is possible to rename a constraint once it has been created. Without going through the process of disabling it and then cascade dropping the constraint and then recreating. I have check all my current reference material. Any help would be appericated. Thanks

There is no direct statemtn as we have to rename to table.
Infact, I ask u to try this...
DECLARE
c_owner CONSTANT VARCHAR2 (30) := 'FLEETPRO';
CURSOR cons_cur
IS
SELECT C.owner, C.constraint_name, C.table_name,
TRANSLATE (C.table_name,'ABCDEFGHIJKLMNOPQRSTUVWXYZ_',
'ABCDEFGHIJKLMNOPQRSTUVWXYZ')
as RTrimTable
, CR.owner as ROwner, CR.constraint_name as RCName,
CR.table_name as RTable,
TRANSLATE (CR.table_name,'ABCDEFGHIJKLMNOPQRSTUVWXYZ_',
'ABCDEFGHIJKLMNOPQRSTUVWXYZ') as RtrimRTable
FROM all_constraints C, all_constraints CR
WHERE C.owner = 'FLEETPRO'
AND C.owner = CR.owner
AND C.constraint_type in ('R')
AND UPPER(SUBSTR(C.constraint_name,1,3)) <> 'FK_'
AND C.r_constraint_name = CR.constraint_name
ORDER BY C.table_name,CR.table_name;
-- AND rownum < 50;
cons_rec cons_cur%ROWTYPE;
CURSOR col_curs
IS
SELECT column_name, position
FROM all_cons_columns cc
WHERE cc.owner = cons_rec.owner
AND cc.constraint_name = cons_rec.constraint_name
AND cc.table_name = cons_rec.table_name
ORDER BY position;
CURSOR col_R_curs
IS
SELECT column_name, position
FROM all_cons_columns cc
WHERE cc.owner = cons_rec.ROwner
AND cc.constraint_name = cons_rec.RCname
AND cc.table_name = cons_rec.RTable
ORDER BY position;
v_table_name all_constraints.table_name%type;
v_Rtable_name all_constraints.table_name%type;
v_ctr int;
v_fklist VARCHAR2 (1000);
v_fklist_R VARCHAR2 (1000);
v_global_name VARCHAR2 (80);
BEGIN
OPEN cons_cur;
v_table_name := NULL;
v_Rtable_name := NULL;
v_ctr := 0;
LOOP
FETCH cons_cur INTO cons_rec;
EXIT WHEN cons_cur%NOTFOUND;
v_fklist := NULL;
v_fklist_R := NULL;
FOR col_rec IN col_curs
LOOP
IF v_fklist IS NULL THEN
v_fklist := '( ' || col_rec.column_name;
ELSE
v_fklist := v_fklist || ', ' || col_rec.column_name;
END IF;
END LOOP;
FOR col_rec IN col_R_curs
LOOP
IF v_fklist_R IS NULL THEN
v_fklist_R := '( ' || col_rec.column_name;
ELSE
v_fklist_R := v_fklist_R || ', ' || col_rec.column_name;
END IF;
END LOOP;
IF ((v_table_name = cons_rec.table_name)
AND (v_Rtable_name = cons_rec.Rtable))
THEN v_ctr := v_ctr + 1;
Else
v_ctr := 0;
v_table_name := cons_rec.table_name;
v_Rtable_name := cons_rec.Rtable;
End If;
v_fklist := v_fklist || ')';
v_fklist_R := v_fklist_R || ')';
DBMS_OUTPUT.put_line
'alter table ' || cons_rec.owner || '.' || cons_rec.table_name
DBMS_OUTPUT.put_line
'drop constraint ' || cons_rec.constraint_name || ';'
DBMS_OUTPUT.put_line
'alter table ' || cons_rec.owner || '.' || cons_rec.table_name
IF v_ctr > 0 THEN
v_global_name := 'FK_' || cons_rec.table_name || '_'
|| cons_rec.RTable || to_char(v_ctr);
ELSE
v_global_name := 'FK_' || cons_rec.table_name || '_'
|| cons_rec.RTable;
END IF;
IF length( v_global_name ) > 29 Then
IF v_ctr > 0 then
v_global_name := 'FK_' || cons_rec.RtrimTable || '_'
|| cons_rec.RtrimRTable || to_char(v_ctr);
ELSE
v_global_name := 'FK_' || cons_rec.RtrimTable || '_'
|| cons_rec.RtrimRTable;
END IF;
END IF;
DBMS_OUTPUT.put_line
'add constraint ' || v_global_name || ' foreign key ' ||
v_fklist
DBMS_OUTPUT.put_line
'references ' || cons_rec.ROwner || '.' || cons_rec.Rtable || ' '
||
v_fklist_R ||
DBMS_OUTPUT.new_line ();
END LOOP;
END;

Similar Messages

  • Can't import DDL file that has alter table rename constraint

    Hi:
    Version 3.1.0.691 on Windows 7 Enterprise 64-bit SP1
    I'm trying to import a DDL file with syntax similar to what's below. The <name> notes that I've replaced the actual names for obfuscation purposes.; the real names are in the script.
    ALTER TABLE <name>
    RENAME CONSTRAINT SYS_C0041150
    TO <name2>_CK;
    ALTER TABLE <name>
    RENAME CONSTRAINT AVCON_1281559518_ACTIV_022
    TO <name2>_CK;
    I get the following error:
    Oracle SQL Developer Data Modeler 3.1.0.691
    Oracle SQL Developer Data Modeler Import Log
    Date and Time: 2012-01-13 16:29:05 PST
    Design Name: <name>
    RDBMS : Oracle Database 11g
              All Statements:           819
              Imported Statements:      0
              Failed Statements:           0
              Not Recognized Statements:      819
    <<<<< Not Recognized >>>>>
    ALTER TABLE <name>
    RENAME CONSTRAINT SYS_<name>
    TO <name2>_CK
    ALTER TABLE <name>
    RENAME CONSTRAINT AVCON_1281559518_QVI_A_000
    TO <name2>_CK
    Thanks for any help you can provide.
    Doc

    Hi:
    The file was indeed comprised of just alter statements. As a test, I trimmed the file down to just one alter statement:
    ALTER TABLE <name> RENAME CONSTRAINT SYS_C0041413 TO <name2>_CK;
    The output file contained exactly the following, where the <<BEGIN OF FILE>> and <<END OF FILE>> were simply added here for clarity. There was no section called
    <<<<< ERRORS >>>>> and the ddl file contained no create table statements.
    <<BEGIN OF FILE>>
    Oracle SQL Developer Data Modeler 3.1.0.691
    Oracle SQL Developer Data Modeler Import Log
    Date and Time: 2012-01-16 10:16:42 PST
    Design Name: <name>
    RDBMS : Oracle Database 11g
              All Statements:           1
              Imported Statements:      0
              Failed Statements:           0
              Not Recognized Statements:      1
    <<<<< Not Recognized >>>>>
    ALTER TABLE <name> RENAME CONSTRAINT SYS_C0041413 TO <name2>_CK
    <<END OF FILE>>
    Other info.
    When I do an model import, none of the existing check constraint names get captured. Also, if I add names afterwards to two separates models via DM and then compare them. The output DDL shows a drop of the target constraint referencing its name, but the recreation of the not null constraint doesnt reference the source constraint name set for it manually in DM. Here's the example I did and the output ddl.
    ALTER TABLE <name>
    DROP CONSTRAINT SYS_C0041413
    ALTER TABLE <name>
    MODIFY ( <column_name> NOT NULL )
    That last line should have read as follows due to the constraint_name I added for it in DM.
    ALTER TABLE <name>
    MODIFY (<column_name> CONSTRAINT <name2>_CK NOT NULL);
    In the example directly above, <name2>_CK is the name I explicity set via DM and would have expected the compare to have used to recreated the constraint since it referenced the target constraint name when it constructed the drop constraint syntax.
    I believe at least one bug is involved here, most likely two.
    The first bug is that model imports are not capturing not null check constraint names.
    The second bug is that the source constraint name is not being used when generating the ddl necessary to change the not null constraint name in the target model.
    All of this is assuming that I haven't just goofed and forgotten to check a box somewhere telling it to do what I've been talking about here. :-)
    Doc

  • SQL-tab / refresh button: does not take into account renamed constraint.

    I discovered a small bug:
    1) find or create a table with system generated constraint names (SYS_C007289)
    2) open that table in SQL Developer (I'm using 3.0.04.34). On the constraints tab, there will be the SYS% constraints. On the SQL-tab, the constraints will be shown without a name (simply "not null" for example).
    3) Return to the Constraints tab and use Actions / Constraints / Rename single to rename a constraint.
    4) return to the SQL tab and press the Refresh button. Unexpectedly, the new constraint name is still not in the SQL!
    5) close the entire window/tab for the table
    6) re-open that table.
    7) go to the SQL-tab: now the name of the constraint is in the code.
    As shown above, the workaround is easy, so this is a very minor bug-let.

    Looks like you add an ActionListener to your button <next> every time yuou call buildGui() and, believe it or not, adding a listener more than once triggers additional events. Thus, it's okay on your first loop but on the second it now has 2 listeners and thus will skip 3 and go to four. After this it now has three listeners and will skip 4 and 5 and go to 6 etc, etc.
    // in your buldGui() method
    System.out.println("prints next");
    frameContainer.add(next);
    next.addActionListener(this);
    System.out.println("it has already printed next");
    exit.addActionListener(this);
    frameContainer.add(exit);

  • Rename constrain name or index name.

    When you change an index name, or a constrain name, and then, you want to sincronize the relational model with the data dictionary, the generated DLL(delta),
    use drop index, and create index.
    This will not work in certain scenarios like unique index name, due to the fact that you can not delete unique index.
    It is posible that instead of making drop create index, just make a rename statement?
    Thanks in advance.
    IEg:
    INSTEAD OF:
    DROP INDEX schema_name.index_name
    CREATE UNIQUE INDEX shcema_name.new_index_name ON schema_name.table_name
    DO:
    ALTER TABLE schema_name.table_name
    RENAME CONSTRAINT schema_name.index_name
    TO shcema_name.new_index_name;

    Hi,
    Thanks for your suggestion. In fact, we are already planning to include this in the next release of Data Modeler.
    David

  • Updating pk constraint name

    Hi all
    is thr any simple way to remane all primary key constraint names,
    like if i have all pk constraints with name say in_abcd
    and i want to update them all to pk_asdf,
    how can we achieve this.
    Thanks :)

    [http://www.oracle-base.com/articles/9i/RenamingColumnsAndConstraints9i.php]
    ALTER TABLE test RENAME CONSTRAINT test1_pk TO pk_test;

  • Assistance Needed With Creating a Dynamic Query

    I am attempting to rename several of my primary key/foreign key constraints from the default "SYS" names to something actually meaningful. I have several "semi-dynamic" queries that look something like this:
    SELECT 'ALTER TABLE L_ROLE RENAME CONSTRAINT ' || CONSTRAINT_NAME || ' TO NN_ROLE_ID; ' FROM USER_CONSTRAINTS WHERE CONSTRAINT_TYPE ='C' AND TABLE_NAME='L_ROLE' AND search_cond(constraint_name)='"ID" IS NOT NULL';
    Unfortunately, I have to capture the output of this script and run THOSE statements to get anything done.
    I would like to convert this to simply use EXECUTE IMMEDIATE or if necessary a stored procedure. Unfortunately, I'm a bit confused on what the end result would look like. Any assistance would be appreciated.
    Jason
    p.s."search_cond" is a custom function defined as follows:
    create function search_cond( p_cons_name in varchar2 ) return varchar2
    as
    l_search_condition varchar2(4000);
    begin
         select SEARCH_CONDITION into l_search_condition
         from user_constraints
         where constraint_name = p_cons_name;
    return l_search_condition;
    end;
    For some reason, just running the query outside the function doesn't work.

    OK, try this. Please note that I commented out the actual exec immediate line and instead just dbms_output the commands that will get executed. This way you can try this first to make sure it produces what you expect. Then just put the exec immediate back in when you are ready.
    DECLARE
        TYPE cur_typ IS REF CURSOR;
        v_cursor cur_typ;
        v_query VARCHAR2(1000);
        v_exec VARCHAR2(1000);
    BEGIN
        v_query := 'SELECT ''ALTER TABLE ''||uc.table_name||''  RENAME CONSTRAINT '' || uc.constraint_name ||
                          '' TO NN_''||ucc.column_name||'' '' thequery
                    FROM  user_constraints uc,
                          user_cons_columns ucc
                    WHERE uc.constraint_name = ucc.constraint_name
                    AND   uc.constraint_type =''C''
                    AND   search_cond(uc.constraint_name)=''"ID" IS NOT NULL''
                    AND   uc.constraint_name LIKE ''SYS%'' ';
        DBMS_OUTPUT.PUT_LINE(v_query);
        OPEN v_cursor FOR v_query;
        LOOP
            FETCH v_cursor INTO v_exec;
            EXIT WHEN v_cursor%NOTFOUND;
            --EXECUTE IMMEDIATE (v_exec);
            dbms_output.put_line(v_exec);
        END LOOP;
        CLOSE v_cursor;   
    END;
    /Greg

  • Updated Information About TimeCapsule Errors!

    I updated the firmware on my TimeCapsule and now, I no longer see the spinning arrow icon spinning! Also, when I go into TimeMachine, after several seconds, it closes and goes back to the desktop. The WiFi seems to be working ok and when I check for the latest back, the times and dates seems to be current. However, when I try to do a manual backup, the TimeMachine appears and then after a while, disappears and then reappears and disappears again and again!
    Update One: I just notice that when I go into my backup drive in the TimeCapsule, the icon on the desktop keeps disappearing and reappearing every few seconds!
    Update Two: Another odd thing happens. When the TimeCapsule is turned on and the WiFi connection is active, my MacBook Pro Retina-desktop refreshes every 1 minute (I timed it)! I even unplug it and the desktop was acting normal.
    What the **** is going on? By the way, I did upgrade to maverick and I am using a MacBook Pro Retina.

    What’s new in Oracle9i
         Automatic undo management
         Automatic Segment Space Management
         Rename Column
         Rename Constraints
         Data Compression
         Index Key Compression
         Flashback Query
         Object Privileges by DBA
         Default Temporary Tablespace
         Resumable Space Allocation
         List Partitioning
         Range-list Partitioning
         External Tables
         Tuning Advisories
         Dynamic Sampling of Optimizer Statistics
         Dynamic Database Parameters
         Dynamic Memory Management / Automatic Memory Tuning
         Server Parameter File
         Oracle Managed Files
         Using multiple block sizes
         Multi-table INSERT
         Index Skip Scan
         DBMS_METADATA
         DBMS_XPLAN
         ANSI Style Outer Joins
         Random Sampling of Data
         New Data Types
         “Upsert” or the MERGE statement
    regards

  • Differnet between 8i and 9i

    There is any different between oracle 8i and 9i.
    recently we upgraded from 8i to 9i after that the applications are working very fast.
    anybody know what is the reason.
    Thank, Raghu.K

    just a glance, new features in 9i
    What’s new in Oracle9i?
         Automatic undo management
         Automatic Segment Space Management
         Rename Column
         Rename Constraints
         Data Compression
         Index Key Compression
         Flashback Query
         Object Privileges by DBA
         Default Temporary Tablespace
         Resumable Space Allocation
         List Partitioning
         Range-list Partitioning
         External Tables
         Tuning Advisories
         Dynamic Sampling of Optimizer Statistics
         Dynamic Database Parameters
         Dynamic Memory Management / Automatic Memory Tuning
         Server Parameter File
         Oracle Managed Files
         Using multiple block sizes
         Multi-table INSERT
         Index Skip Scan
         DBMS_METADATA
         DBMS_XPLAN
         ANSI Style Outer Joins
         Random Sampling of Data
         New Data Types
         “Upsert” or the MERGE statement
    regards

  • ORA-14314: resulting List partition(s) must contain atleast 1 value

    Hi,
    Using: Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production, Windows 7 Platform.
    I'm trying to understand Exchange Partition and Split (List) partitioning. Below is the code I'm trying to work on:
      CREATE TABLE big_table (
      id            NUMBER(10),
      created_date  DATE,
      lookup_id     NUMBER(10),
      data          VARCHAR2(50)
    declare
      l_lookup_id big_table.lookup_id%type;
      l_create_date date;
    begin
      for i in 1 .. 1000000 loop
        if mod(i,3) = 0 then
           l_create_date := to_date('19-mar-2011','dd-mon-yyyy');
           l_lookup_id := 2;
        elsif mod(i,2) = 0 then
           l_create_date := to_date('19-mar-2012','dd-mon-yyyy');
           l_lookup_id := 1;
        else
           l_create_date := to_date('19-mar-2013','dd-mon-yyyy');
           l_lookup_id := 3;
        end if;
        insert into big_table(id, created_date, lookup_id, data)
           values (i, l_create_date, l_lookup_id, 'This is some data for '||i);
      end loop;
      commit;
    end;
    alter table big_table add (
    constraint big_table_pk primary key (id));
    exec dbms_stats.gather_table_stats(user, 'BIG_TABLE', cascade => true);
    create table big_table2 (
    id number(10),
    created_date date,
    lookup_id number(10),
    data varchar2(50)
    partition by list (created_date)
    (partition p20991231 values (TO_DATE(' 2099-12-31 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')));
    alter table big_table2 add (
    constraint big_table_pk2 primary key(id));
    alter table big_table2 exchange partition p20991231
    with table big_table
    without validation
    update global indexes;
    drop table big_table;
    rename big_table2 to big_table;
    alter table big_table rename constraint big_table_pk2 to big_table_pk;
    alter index big_table_pk2 rename to big_table_pk;
    exec dbms_stats.gather_table_stats(USER, 'BIG_TABLE', cascade => TRUE);
    I'm trying to split the data by moving created_date=19-mar-2013 to new partition p20130319. I tried to run the below query but failed with error. Where am I doing it wrong?
    Thanks.
    alter table big_table
    split partition p20991231 values (to_date('19-mar-2013','dd-mon-yyyy'))
    into (partition p20130319
         ,partition p20991231
    Error report:
    SQL Error: ORA-14314: resulting List partition(s) must contain atleast 1 value
    14314. 00000 -  "resulting List partition(s) must contain atleast 1 value"
    *Cause:    After a SPLIT/DROP VALUE of a list partition, each resulting
               partition(as applicable) must contain at least 1 value
    *Action:   Ensure that each of the resulting partitions contains atleast
               1 value

    I stand corrected.
    Below are the steps I have gone through to understand:
    1. How to partition a table with data in it.
    2. Exchange partition.
    3. Split partition (List).
    4. Split data to more than 2 partitions.
    Please correct me if I'm missing anything.
    CREATE TABLE big_table
        id           NUMBER(10),
        created_date DATE,
        lookup_id    NUMBER(10),
        data         VARCHAR2(50)
    DECLARE
      l_lookup_id big_table.lookup_id%type;
      l_create_date DATE;
    BEGIN
      FOR i IN 1 .. 1000000
      LOOP
        IF mod(i,3)= 0 THEN
          l_create_date := to_date('19-mar-2011','dd-mon-yyyy');
          l_lookup_id   := 2;
        elsif mod(i,2)   = 0 THEN
          l_create_date := to_date('19-mar-2012','dd-mon-yyyy');
          l_lookup_id   := 1;
        ELSE
          l_create_date := to_date('19-mar-2013','dd-mon-yyyy');
          l_lookup_id   := 3;
        END IF;
        INSERT INTO big_table(id, created_date, lookup_id, data)
          VALUES(i, l_create_date, l_lookup_id, 'This is some data for '||i);
      END LOOP;
      COMMIT;
    END;
    ALTER TABLE big_table ADD
    (CONSTRAINT big_table_pk PRIMARY KEY (id));
    EXEC dbms_stats.gather_table_stats(USER, 'BIG_TABLE', CASCADE => true);
    CREATE TABLE big_table2
      ( id           NUMBER(10),
        created_date DATE,
        lookup_id    NUMBER(10),
        data         VARCHAR2(50)
      partition BY list(created_date)
      (partition p0319 VALUES
        (TO_DATE(' 2013-03-19 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN') ,TO_DATE(' 2012-03-19 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN') ,TO_DATE(' 2011-03-19 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    ALTER TABLE big_table2 ADD
    (CONSTRAINT big_table_pk2 PRIMARY KEY(id));
    ALTER TABLE big_table2 exchange partition p0319
    WITH TABLE big_table without validation
    UPDATE global indexes;
    DROP TABLE big_table;
    RENAME big_table2 TO big_table;
    ALTER TABLE big_table RENAME CONSTRAINT big_table_pk2 TO big_table_pk;
    ALTER INDEX big_table_pk2 RENAME TO big_table_pk;
    EXEC dbms_stats.gather_table_stats(USER, 'BIG_TABLE', CASCADE => TRUE);
    SELECT p.partition_name, p.num_rows
    FROM user_tab_partitions p
    WHERE p.table_name = 'BIG_TABLE';
    ALTER TABLE big_table split partition p0319 VALUES
    (TO_DATE(' 2013-03-19 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    INTO (partition p20130319, partition p0319);
    ALTER INDEX big_table_pk rebuild;
    EXEC dbms_stats.gather_table_stats(USER, 'BIG_TABLE', CASCADE => TRUE);
    SELECT p.partition_name, p.num_rows
    FROM user_tab_partitions p
    WHERE table_name = 'BIG_TABLE';
    SELECT DISTINCT created_date FROM big_table partition(p20130319);
    SELECT DISTINCT created_date FROM big_table partition(p0319);
    ALTER TABLE big_table split partition p0319 VALUES
    (TO_DATE(' 2012-03-19 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    INTO (partition p20120319, partition p20110319);
    ALTER INDEX big_table_pk rebuild;
    EXEC dbms_stats.gather_table_stats(USER, 'BIG_TABLE', CASCADE => TRUE);
    SELECT p.partition_name, p.num_rows
    FROM user_tab_partitions p
    WHERE table_name = 'BIG_TABLE';
    SELECT DISTINCT created_date FROM big_table partition(p20130319);
    SELECT DISTINCT created_date FROM big_table partition(p20120319);
    SELECT DISTINCT created_date FROM big_table partition(p20110319);

  • Rename a Constraint?

    Is it possible to rename a system named constraint?
    I am using Oracle 8.1.7
    Thanks

    Not that I know of.
    However if the constraint is not an index-generating constraint, there should be little risk in opening the database in restricted mode, dropping the system named constraint and recreating one with a name of your choosing.
    If it is index-generating, than you have to decide if it is worth it.
    Sorry, but I don't that that you have an easy and totally painless solution in front of you; this is why so many DBAs are anile about DDL with constraints named up front.
    Michael

  • Help me create a procedure to rename plenty of constraints

    about 500 tables' constraints require to be renamed from SYS**** to the table's name.
    what procedure could you guys think of?
    If you've used a previous one please let me know, or if you know where I could download a package, procedure or something, show me the link to get it.
    My DB is: version 8173

    This Procedure renames PK to PK+TableName(excuse the german comments):
        procedure rename_primary_key
        is
            cursor c_user_cons is
                select
                    c.constraint_name,
                    c.constraint_type,
                    c.r_constraint_name,
                    rc.table_name r_table_name,
                    c.table_name,
                    to_char(NULL) key_columns,
                    i.tablespace_name
                from user_constraints c, user_constraints rc, user_indexes i
                where c.constraint_type in ('P','R')
                and (c.r_constraint_name like 'SYS%' or c.r_constraint_name is null)
                and c.constraint_name = i.index_name (+)
                and c.r_constraint_name = rc.constraint_name (+)
                order by c.constraint_type desc, c.table_name, c.constraint_name;
            type cons_list is table of c_user_cons%rowtype;
            key_columns varchar2(1000);
            constraint_liste cons_list := cons_list(NULL);
        begin
            for rec in c_user_cons loop
            -- Liste mit vorhandenen constraints erstellen
                constraint_liste(constraint_liste.last) := rec;
                for rec_col in (
                    select column_name, position
                    from user_cons_columns
                    where constraint_name = rec.constraint_name
                    order by position
                ) loop
                    if rec_col.position = 1 then
                        key_columns := rec_col.column_name;
                    else
                        key_columns := key_columns||','||rec_col.column_name;
                    end if;
                end loop;
                constraint_liste(constraint_liste.last).key_columns := key_columns;
                constraint_liste.extend;
            end loop;
            constraint_liste.trim;
            for i in constraint_liste.first..constraint_liste.last loop
            -- Aufgrund der Sortierung des Cursors sind Foreign Keys zuerst in der Liste und
            -- werden vor zugehörigem PK gelöscht
                if constraint_liste(i).constraint_type = 'P' then -- PK löschen und neu anlegen
                    if constraint_liste(i).tablespace_name is not NULL then
                    -- nur ausführen, wenn eigener Index für PK vorhanden
                        execute immediate 'alter table '||constraint_liste(i).table_name||' drop primary key';
                        execute immediate 'alter table '||constraint_liste(i).table_name||' add (constraint PK'
                            ||substr(constraint_liste(i).table_name, 1, 30)|| ' primary key ('
                            ||constraint_liste(i).key_columns||') using index tablespace '
                            ||constraint_liste(i).tablespace_name||')';
                    end if;
                else -- FK löschen
                    execute immediate 'alter table '||constraint_liste(i).table_name||' drop constraint '||constraint_liste(i).constraint_name;
                end if;
            end loop;
            for i in constraint_liste.first..constraint_liste.last loop
            -- FK neu anlegen
                if constraint_liste(i).constraint_type = 'R' then
                    execute immediate 'alter table '||constraint_liste(i).table_name||' add (constraint '
                        ||constraint_liste(i).constraint_name||' foreign key('||constraint_liste(i).key_columns
                        ||') references '||constraint_liste(i).r_table_name||' deferrable initially deferred)';
                end if;
            end loop;
         end rename_primary_key;

  • BI Publisher Multiple tray/ Renaming of file / Zipping of BI Publisher O/P

    Hi Team,
    I want to know, whether we can achieve the following task in embedded BI publisher or not.
    Also, if we can do, let me know what are the possible steps to achieve them:
    1. Multiple Tray selection
    Here multiple Tray means different tray available in a single printer i.e tray 1 can have A4 paper, tray 2 can have A3 paper , tray 3 can have pre- printed stationary etc. so our BIP output can be send to multiple tray.
    *2. Checking the groupings - how many levels*
    Embedded BIP can provide a maximum of upto 4 levels of grouping.
    our requirement demand to group upto 7 level, I have suggested that we can achieve this through manual coding in RTF.
    *3. Email Feature - HTML (body is dynamic).*
    BIP has this emailing facility where we can have dynamic body in a mail. We need to figure out what max no of character , we can have in the body.
    *4. Reports that are uploaded to different folders.*
    It means that PDF/RTF files should be able to be copied to different folders like C:\DMU, D:\CTA etc
    5. Inserting records into SQL
    We need to find way for connecting to database and inserting our BIP records.
    6. Renaming files for the Email and Doc Central.
    We need to find out methods where we can rename our BIP outputs.Generally BIP file name gets generated automatically with UBE engine when it generates XML file.
    *7. Integrate with Doc Central (PDFs and Common XML)*
    Client is having one DOC Central software where client keeps repository of all its documents. we need to figure out that can we integrate our JDE with DOC central for keeping our BIP outputs in it.
    *8.Zipping of the files and sending the documents by FTP.*
    we need to figure out ways where we can zip our BIP outputs and send it through FTP.
    Let me know possible ways to achieve above 8 constraints, any java/dot net program if require to meet those above 8 facilities are also welcome.
    Thanks!
    Deepak Mishra

    Hi ,
    Do not have an answer yet . but with some research and trials it seems this may not be possible.
    Regards,
    PKB

  • How to modify a column name & How to modify a constraint name

    How to modify a column name?
    How to modify a primary key constraint name if the pk has been referenced by another foreign key?
    Thanks.

    Hi,
    What version of oracle are you using? If it is 9i,
    then you can the command
    alter table <table_name> rename column <column_name> to <new_column>;
    if it is 8i or earlier, you can create a view with the required names.
    hth
    Always post the oracle version and the platform you are using to get better response.

  • Error while renaming indexes and keys in the tables

    hi gems...good afternoon..
    i am using oracle 11gr2 database.
    when i am trying to rename the primary key, foreign key, indexes of all the tables as per the standard, then the following error is given...
    ORA-00604: error occurred at recursive SQL level 1
    ORA-01000: maximum open cursors exceeded
    ORA-00604: error occurred at recursive SQL level 1
    ORA-01000: maximum open cursors exceeded
    ORA-01000: maximum open cursors exceeded
    currently the maximum open cursors parameter is set to 300.
    please help..thanks in advance

    thanks a lot for your help..
    there are total 162 records in the v$open_cursor for that user.
    among that the open cursor is only 4 and open-recursive cursor is only 6 for that user.
    in my session i am executing only the renaming of the constraints and nothing more.
    When i have queried the v$open_cursor for cursor_type='OPEN' for all the users, then i got that it has exceeded the value of open_cursors parameter.
    So how can i resolve that....

  • What are the restrictions &pitfalls of renaming a table vs select * into...

    Hello all,
    I've got a situation coming up possibly, that I'm looking at where I may need to rename a table that has about 3 TB of data in it.
    I'd looked at doing the oracle RENAME command, and it mentions that some restrictions that would error out would be:
    views, synonyms, and stored procedures and functions that reference the table.
    I'd been looking around on different sites researching more, and found some saying that tables with foreign keys, check constraints would also error out on this....but in the Oracle docs I see it saying:
    "Oracle Database automatically transfers integrity constraints, indexes, and grants on the old object to the new object."
    Were the other non-Oracle site references maybe to older versions? I'm using 11Gr2.
    The other part of this is that the app designers really want to recreate the original table. Essentially this is doing
    TABLENAME1 -> TABLENAME1_OLD
    Then recreating TABLENAME1 anew empty for new use.
    My original thoughts were to do select * from TABLENAME1 into TABLENAME1_OLD, and then truncate TABLENAME1....but with the size of the data (and this will eventually be done in PROD), I"m trying to say that doing the RENAME and recreating the empty table would be less resource intensive.
    Would the rename and recreate table be the way to go?
    If so, then I need to make sure I know all the restrictions and pitfalls on rename would have....
    Thanks in advance!!
    cayenne

    rp0428 wrote:
    >
    I've got a situation coming up possibly, that I'm looking at where I may need to rename a table that has about 3 TB of data in it.
    I'd looked at doing the oracle RENAME command, and it mentions that some restrictions that would error out would be:
    views, synonyms, and stored procedures and functions that reference the table.
    I'd been looking around on different sites researching more, and found some saying that tables with foreign keys, check constraints would also error out on this....but in the Oracle docs I see it saying:
    "Oracle Database automatically transfers integrity constraints, indexes, and grants on the old object to the new object."
    Were the other non-Oracle site references maybe to older versions? I'm using 11Gr2.
    The other part of this is that the app designers really want to recreate the original table. Essentially this is doing
    TABLENAME1 -> TABLENAME1_OLD
    Then recreating TABLENAME1 anew empty for new use.
    My original thoughts were to do select * from TABLENAME1 into TABLENAME1_OLD, and then truncate TABLENAME1....but with the size of the data (and this will eventually be done in PROD), I"m trying to say that doing the RENAME and recreating the empty table would be less resource intensive.
    Would the rename and recreate table be the way to go?
    {quote}
    You are missing a key piece of the requirements
    What is the intended use of the OLD and the NEW tables?
    Why do you need a new table with exactly the same name unless you intend to use it exactly the same way you were using the old table? And if that is the case it seems to me that other tables with foreign keys need to be truncated also and point to the new table and not the old one.Unfortunately, I don't know. This is just a request the devs have, and I'm not sure of their reasoning, but this is what they're asking for, so, I'm trying to research the best way to do what they request.
    Thanks,
    C

Maybe you are looking for

  • DVI to Video problem

    Hi everyone ! I've got a big problem using my MacMini with TV. I bought the Apple DVI to Video converter, and connected my Philips cathodic TV to the Mac. But the TV only displays gray and deformed pictures. I tried all resolutions available, but not

  • Transferring music from iPhone to MacBook Pro

    I  just bought a new macbook pro and went to transfer my music from my iPhone to the new iTunes, and only half transferred. The other half are in the iTunes music section but are not highlighted. Help?

  • DAC (analog output through sreapder?) on Spartan 3E FPGA

    Hi everyone, I've been looking over the LabView training excercises for the Spartan 3E board, specifically the DAC.vi and DAChost.vi in excercise 8. The vis are there in the solution folder, but there's no real explanation for the DAC specifically in

  • Strange entries in lighttpd access log -- help!

    Hi, I run a lighttpd server at home. I just use it for working with some scripts, and sharing stuff with my friends. I have a dynamic IP address, so I use dyndns for getting a hostname. Today I noticed some strange entries in the lighttpd access log:

  • Job Pricing - Match SAP fields to survey data

    I am in the process if importing my survey data and matching the fields and pay categories.  Are we able to use a SAP field name more than once for the columns within the survey data?  Example I have three sections listing the number of incumbents co