PLSQL block for compression of multi tables

I have a user xxxxxx, he owned 65 paintings, I want to compress all these tables at once
one may suggest the write block plsql to compress all tables at once

to compress a table "alter table table_name move compress.

You can compress one at a time can therefore either use a loop in a PL/SQL like so block...

DECLARE

       TYPE tt_TabList IS TABLE OF user_tables.table_name%TYPE;

       l_TabList       tt_TabList;

BEGIN

     SELECT
           table_name
     BULK COLLECT INTO
          l_TabList
     FROM
         user_tables;

     FOR li_Tab IN 1..l_TabList.COUNT
     LOOP

         EXECUTE IMMEDIATE 'ALTER TABLE '||l_TabList(li_Tab)||' MOVE COMPRESS';

     END LOOP;

END;

Or you could generate the DDL statements and run them in SQL * more

SELECT 'ALTER TABLE '||table_name||' MOVE COMPRESS;' FROM user_tables

HTH

David

Tags: Database

Similar Questions

  • PLSQL block for childtable foreignkey account data columns

    Hello

    I want to generate report for child table foreign key column data number of records based on the entry in the parent table.


    for example:


    '' SELECT b.table_name as table_name, d.column_name, b.R_CONSTRAINT_NAME. ''
    From user_constraints a, user_constraints b, user_ind_columns c, user_cons_columns d
    WHERE a.constraint_type = 'P' AND
    a.CONSTRAINT_NAME = b.R_CONSTRAINT_NAME AND
    b.CONSTRAINT_TYPE = 'R' AND
    a.table_name = c.table_name AND
    a.constraint_name = c.index_name AND
    AND d.constraint_name = b.CONSTRAINT_NAME
    a.table_name = 'TABLENAME' "



    This above query give all the child tables and a list of the foreign key column (column childkey).

    based on the results of the above query I want to generate each number of records table foreign key column.


    example:

    I have the table DEPT / EMP in the query above, I'll give you table DEPT, it will give the output "EMP".

    My data in the table emp like that

    My emp table has the datalike
    EMPNO, ename, deptno
    100 10 aaa
    101 20 BBB
    102 30 cccc
    103 10 ddd
    Eee 104 20
    105 30 FFFF


    I want to report as
    number of records deptno table
    2 10 EMP
    2 20 EMP
    30 2 EMP

    Please any body has the solution please post your solutions here.
    If you have any logic please post here, I'll try with this logic.


    Thank you.
    :)

    Test data:

    drop table T2;
    drop table T3;
    drop table T1;
    
    create table T1(a, B, C, primary key(a,B)) as select 1,2,3 from DUAL;
    
    create table T2(a,B,D) as select 1,2,4 from DUAL connect by level <= 2;
    alter table T2 add constraint FK2 foreign key(a,B) references T1;
    
    create table T3(a,B,E) as select 1,2,5 from DUAL connect by level <=3;
    alter table t3 add constraint fk3 foreign key(a,b) references t1;
    

    First SQL to create the SELECT statements, you need:

    VARIABLE OWNER varchar2(30);
    VARIABLE TABLE_NAME varchar2(30);
    exec :table_name := 'T1';
    
    select
    'select ''' || R_OWNER || '.' || R_TABLE_NAME || ''' parent, '''
    || OWNER || '.' || TABLE_NAME || ''' child, '''
    || COLS || ''' fk_cols, '
    || COLS || ', count(*) cnt from ' || OWNER || '.' || TABLE_NAME
    || ' group by ' || cols as sql_text
    from (
      select NVL(:OWNER,user) r_owner,:TABLE_NAME r_table_name,
      OWNER, TABLE_NAME,
      LISTAGG(COLUMN_NAME, ',') within group(order by POSITION) COLS
      from ALL_CONS_COLUMNS
      where (owner, constraint_name, table_name) in (
        select owner, constraint_name, table_name from ALL_CONSTRAINTS
        where CONSTRAINT_TYPE = 'R'
        and (r_owner, r_constraint_name) = (
          select OWNER, CONSTRAINT_NAME from ALL_CONSTRAINTS
          where CONSTRAINT_TYPE = 'P'
          and (OWNER, TABLE_NAME) = ((NVL(:OWNER,user),:TABLE_NAME))
        )
      )
      group by OWNER, TABLE_NAME
    );
    
    SQL_TEXT
    -------------
    select 'STEW.T1' parent, 'STEW.T2' child, 'A,B' fk_cols, A,B, count(*) cnt from STEW.T2 group by A,B
    select 'STEW.T1' parent, 'STEW.T3' child, 'A,B' fk_cols, A,B, count(*) cnt from STEW.T3 group by A,B
    

    Test one of the SELECT statements:

    select 'STEW.T1' parent, 'STEW.T2' child, 'A,B' fk_cols, A,B, count(*) cnt from STEW.T2 group by A,B;
    
    PARENT  CHILD   FK_COLS A B CNT
    ------- ------- ------- - - ---
    STEW.T1 STEW.T2 A,B     1 2   2
    

    The SELECT statements must be tested separately because the number and type of foreign keys may vary.

  • IKM Oracle Multi Table Insert obsolete?

    The description for 'IKM Oracle Multi Table Insert' reads:

    -Snip-

    DEPRECATED: KM has been deprecated and may be removed without notice in future versions ODI. Please use the MTI ODI mappings feature.

    -Snip-

    Can someone tell me the right way to do it in 12 c?  Everything I tried publishes two inserts instead of an insert of all.

    Thank you

    Scott

    12 c, there is now a revenge for this called "IKM Oracle down".  He doesn't appear on the physical tab and cannot be imported because it is built in.

  • Is it Possible to have 2 multi table for a descriptor point

    Hello

    Is it Possible to have 2 multi table for a descriptor to point... If so, can u explain how to implement it


    If not, what is the other way to do it.

    Thanks in advance.

    Kind regards
    Mark

    For example, student point-descriptor can have so many tables as SenVideo, topics, address etc...
    -RMishra

  • Hi, I am not able to execute the procedure using dblink in PLSql block. Although he works outside the end of the beginning. Please suggest solution

    Hello

    I'm not able to execute the procedure using dblink in PLSql block.

    Although he works outside the end of the beginning.

    Please suggest solution

    Hello

    Thanks everone for your contributions,

    As well as the permissions, I used to run inside the PL sql block, which was not necessary, we can simply call the procedure using dblink.

    Thanks guys,.

  • OGG-01028 object with the number of the object 80673 is compressed. Compression of the table is not supported.

    (1) I received an email like this:

    Event_alert

    2013-09-17 22:00:16 ERROR OGG - 01028 Oracle GoldenGate Capture for Oracle, ext_1.prm: object with the number of the object 80673 is compressed. Compression of the table is not supported.

    2013-09-17 22:00:16 ERROR OGG - 01668 Oracle GoldenGate Capture for Oracle, ext_1.prm: PROCESS ABENDING.

    (2) I have not found the OBJ

    SQL > select OBJECT_ID, OBJECT_NAME from dba_objects where object_id = 80673;

    no selected line

    (3) change a few times the process EXT recover;

    (4) my excerpt settings

    Cat ext_1.prm

    EXTRACT ext_1

    Ogg, ogg PASSWORD USERID

    TRANLOGOPTIONS EXCLUDEUSER ogg

    SETENV (NLS_LANG = AMERICAN_AMERICA. ZHS16GBK)

    -SETENV (NLS_LANG = AMERICAN_AMERICA. AL32UTF8)

    EXTTRAIL ./dirdat/t1

    DYNAMICRESOLUTION

    TABLE YBK.*;

    This is a bug that has been fixed

    Excerpt from abending with Table of Compression is not supported, even if the database has no tables compressed. (Doc ID 1510691.1)

    event text: Oracle GoldenGate Capture for Oracle, ext_1.prm: object with the number of the object 86173 is compressed. Compression of the table is not supported.

    tableexclude *. DBMS_TABCOMP_TEMP *.

  • Dynamic performance of plsql block of relaxation.

    Dear oracle Experts.
    I'm using the following oracle database.

    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    CORE 10.2.0.4.0 Production
    AMT for Linux: release 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production

    I have a problem in the execution of the trigger. I have a small plsql block in the trigger, and I want to run it as a dynamic medium. but it gives the error. Please find the code of the trigger. Here my intension is that the column name used in trigger must be dynamic. In the future, if I want to pass the name of the column, I do without modification in the trigger.
    The error im getting is "ORA-01008: not all variables.

    Or y at - it another way to achieve this goal. Please suggest your ideas. Thank you!!!

    CREATE OR REPLACE TRIGGER ETM_AR_IU
    AFTER UPDATE ON
    EXTERNAL_MAPPING
    REFERRING AGAIN AS NINE OLD AND OLD
    FOR EACH LINE

    DECLARE
    V_COL_NAME VARCHAR2 (30);
    PL_SQL_BLOCK VARCHAR2 (1000);

    BEGIN

    SELECT T.COL_NAME IN THE TRIGGER_TABS_COLS V_COL_NAME T;
    PL_SQL_BLOCK: = '
    BEGIN
    IF: OLD.' | V_COL_NAME | "<>: NEW.'" V_COL_NAME |
    "THEN."
    INSERT INTO hema_clob VALUES (: NEW.'|) V_COL_NAME |') ;
    END IF;
    END;';
    IMMEDIATELY RUN PL_SQL_BLOCK;
    END;

    As immediate execution will execute the code as if it were a separate process of the trigger, this dynamic PL/SQL block is unlikely to have access to the: NEW and: OLD trigger variables.

    Dynamic SQL is pretty bad.
    Dynamic PL/SQL is just stupid.
    Dynamic PL/SQL within a trigger... ' enough said.

  • The default values on the retail block for dummy record gets inserted in detail blk

    Hi all

    I have a master block
    a block of detail and a detail for detail block block

    For every master I have or have no certain records in the block of retail

    for each master, I have a few detail records

    for each detail record I may or may not have the corresponding detail records

    Let's take an example
    I navigate a primary record to the detail record.
    in the 3rd block of retail, there is no record for the record in detail, but I have some default values.

    Now I navigate to the 3rd block of detail and I do not insert records and then exit the screen

    Here oracle asks me to save all the changes I made (I did no changes)
    and by clicking on Yes, there is a dummy record is created for a 3rd detail record

    Please help me

    Thank you

    This is the default values are to mark the block as being changed. That's why you get the message "do you want to save the changes.

    I suggest that you fill out elements of the base with the default values table and fill out the matching elements from the base on a prior insertion trigger table.

  • Possible to insert more than once in the same table using multi table insert?

    I used multi-table insert before insert a source separate from the tables without problem.

    However, when I want to insert into the same table two or more distinct lines, I encountered a problem because when I call nextval on the sequence since this is the same sequence # will try to use the same number for two inserts, which will raise a violation of PK constraint on the 2nd insert.

    A way around this problem?

    Another option is to create the sequence with increases of 2 or however many tables, you are targeting.
    When you then specify the. NEXTVAL, you must subtract the relative number of it, apart from the first table that you insert in to.

    Something like that;

    drop table t1;
    
    create table t1 (a number, b number);
    
    drop table t2;
    
    create table t2 (a number, b number);
    
    drop sequence test_seq
    /
    
    create sequence test_seq increment by 2 minvalue 0
    /
    
    insert all
    when 1 = 1 then
      into t1 (a, b) values (test_seq.nextval, 1)
    when 1 = 1 then
      into t2 (a, b) values (test_seq.nextval  - 1, 1)
    select 1, 1 from dual
    /
    
  • Deliver the trigger, multi-table insert logging of errors

    I find that if I try to perform an insert multi-table with logging of errors on a table that has a trigger, then some violations of constraints result in a raised exception being as connected:
    < pre >
    SQL > select * from v version $;

    BANNER
    --------------------------------------------------------------------------------
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE 11.2.0.1.0 Production
    AMT for 32-bit Windows: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production

    SQL > create table t1 (primary key of all id ;)

    Table created.

    SQL > create table t2 (id integer, t1_id integer primary key,
    2 constraint t2_t1_fk foreign key (t1_id) refers to t1);

    Table created.

    SQL > exec dbms_errlog.create_error_log ("T2");

    PL/SQL procedure successfully completed.

    SQL > insert all
    2 in t2 (id, t1_id)
    3 values (x, y)
    4 errors in the journal in err$ _t2 limit unlimited rejection
    5. Select 1 x, 2 double y;

    0 rows created.

    SQL > create or replace trigger t2_trg
    2 before insert or update on t2
    3 for each line
    4 start
    5 zero;
    6 end;
    5 m

    Trigger created.

    SQL > insert all
    2 in t2 (id, t1_id)
    3 values (x, y)
    4 errors in the journal in err$ _t2 limit unlimited rejection
    5. Select 1 x, 2 double y;
    Insert all
    *
    ERROR on line 1:
    ORA-02291: integrity constraint (enhanced oil recovery. T2_T1_FK) violated - key parent not found
    < code >

    This does not seem to be a documented restriction. Anyone know if this is a bug?

    Hi Tony,.

    Looks like you ran into Bug 9539578: INSERT ALL AND TRIGGER CAUSES ERROR LOGGING to FAIL (ROLLBACK)

    Concerning
    Peter

  • How to get the error thrown in plsql block

    Hello


    I remember there is a table that keeps track of the error raised in plsql block. and if we want to see what the error thrown in our block, we can query this table. but unfortunately I forgot the name of the table.

    can someone help me with the name of the table.

    Thank you

    Well maybe I am not aware of such a table, but I believe there are no table of this type

    SELECT *
    FROM   ALL_ERRORS;
    

    * 009 *.

  • Need an anonymous block for false update,

    I have a table called sk_a

    create table sk_a (number, date of b, c varchar2 (10));

    and an audit table

    create a sk_a_audit (audit_id number, issue date, b, c varchar2 (10), dml_action varchar2 (4));

    and the sk_a_audit_seq sequence

    create sequences sk_a_audit_seq

    When any insert or update occurs in the table sk_a, respective data must insert into the table sk_a_audit

    and trigger is

    CREATE OR REPLACE TRIGGER SK_A_TRG
    AFTER INSERT OR UPDATE
    ON SK_A
    FOR EACH LINE
    DECLARE
    l_code NUMBER;
    l_errm VARCHAR2 (64);
    BEGIN
    IF (INSERT OR UPDATE)
    THEN
    INSERT INTO SK_A_audit
    VALUES (sk_a_audit_seq. NEXTVAL,: NEW.a.
    : NEW. B: NEW. C, « I ») ;
    END IF;
    EXCEPTION
    WHILE OTHERS
    THEN
    l_code: = SQLCODE;
    l_errm: = SUBSTR (SQLERRM, 1, 64);
    Dbms_output.put_line ('DML Operation is failed' | l_code | l_errm);
    END;

    can sk_a or mentioned have unique, or primary keys

    now my requirement is

    verification Panel is removed by professional users,

    and then I have to run an update on table sk_a (false update) so that the data will come and inserted into the audit table,

    so this table of audit will once again return with all of the data in table sk_a

    I need an anonymous block for this, can someone help on this.

    Try this to update the table (no need to do it with PK)

     update table
      set col1 = col1;
    

    Bangoura
    [My Oracle Blog | http://baigsorcl.blogspot.com/]

  • compressing all the tables in my diagram

    How to compress all my tables in my schema, if already compress, ignore?

    Oracle 10G

    Thank you!

    SQL or PL/SQL

    Kodiak_Seattle wrote:
    OK, what about this?

    DECLARE
    table-name user_tables.table_name%TYPE;

    CURSOR cursor1 IS SELECT table_name FROM user_tables where compression = "DISABLED";

    BEGIN
    Cursor1 OPEN;

    LOOP
    Fetch cursor1 INTO table-name; -pick up the names of Tables that are not compressed
    OUTPUT WHEN cursor1% NOTFOUND;
    ALTER table table_name move compress
    END LOOP;

    NARROW Cursor1;
    END;

    begin
    for t in (SELECT table_name FROM user_tables where compression='DISABLED') loop
      execute immediate 'alter table ' || t.table_name || ' move compress';
    end loop;
    end;
    
  • PLSQL block

    I have small PLSQL block with a variable binding in it which throws an error on its execution.

    declare
    cursor c1 is product_name PRODUCT selection where month =: m;
    Start
    I'm looping c1
    dbms_output.put_line (i.product_name);
    end loop;
    end;


    It throws the error

    ORA-01008: not all variables

    Is it not possible to have a variable binding in a slider?

    Help, please

    Concerning

    Yes. You use a local variable rather than an external variable bound...

    SQL> ed
    Wrote file afiedt.buf
    
      1  declare
      2    v_deptno number := 20;
      3    cursor c1 is select ename from emp where deptno=v_deptno;
      4  begin
      5    for i in c1 loop
      6      dbms_output.put_line(i.ename);
      7    end loop;
      8* end;
    SQL> /
    SMITH
    JONES
    SCOTT
    ADAMS
    FORD
    
    PL/SQL procedure successfully completed.
    
  • FOR the UPDATE OF table.field

    Why the following does it
    create table division (code varchar2(2) primary key, div_desc varchar2(20));
    
    insert into division values ('01', 'Ninja assassins');
    insert into division values ('02', 'Working for the man');
    
    
    create table employees (tk number, first_name varchar2(10), last_name varchar2(10), code varchar2(2) references division(code));
    
    insert into employees values (1, 'Chuck', 'Smith', '01');
    insert into employees values (2, 'John',  'Smith', '02');
    
    DECLARE
    
      CURSOR my_csr IS
        Select e.tk, e.first_name, e.last_name
        From employees e, division d
        Where e.code = d.code
          and e.code = '01'
          and e.last_name = 'Smith'
        For update;
        
        cnt_updated NUMBER;
    
    BEGIN
    
      cnt_updated := 0; 
    
      FOR my_row IN my_csr
      LOOP
    
        Update employees
        Set last_name = 'Forbes'
        Where current of my_csr;
        
        cnt_updated := cnt_updated + SQL%ROWCOUNT;
        dbms_output.put_line('You updated '||cnt_updated||' records');
    
      END LOOP;
    END;
    but just add the clause "for update" allows to make the point?
    DECLARE
    
      CURSOR my_csr IS
        Select e.tk, e.first_name, e.last_name
        From employees e, division d
        Where e.code = d.code
          and e.code = '01'
          and e.last_name = 'Smith'
        For update *of e.tk*;
    We discovered this recently, and fellow developers are wondering "why?" Is there a reason documented, or is - just how it is?

    Thank you
    -= Chuck

    of 'of the user to the database PL/SQL Oracle® reference Guide. "
    "10g Release 2 (10.2):
    "During the interrogation of several tables, you can use the FOR UPDATE clause to limit the line blocking to specific tables. Rows in a table are locked unless done FOR UPDATE OF clause refers to a column in the table. For example, the following query locks the rows in the employees table, but not in the departments table:

    DECLARE
    CURSOR c1 IS SELECT last_name, department_name FROM employees, departments
    WHERE employees.department_id = departments.department_id
    AND job_id = "SA_MAN."
    FOR the UPDATE OF treatment; »

    a little demo:

    SQL> select * from v$version;
    
    BANNER
    -------------------------------------------------------------------------
    
    Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
    PL/SQL Release 11.1.0.6.0 - Production
    CORE    11.1.0.6.0      Production
    TNS for 32-bit Windows: Version 11.1.0.6.0 - Production
    NLSRTL Version 11.1.0.6.0 - Production
    
      1   DECLARE
      2     CURSOR my_csr IS
      3       Select e.tk, e.first_name, e.last_name, e.rowid
      4       From employees_t e, division d
      5       Where e.code = d.code
      6         and e.code = '01'
      7         and e.last_name = 'Smith'
      8       For update of e.tk;
      9       cnt_updated NUMBER;
     10   BEGIN
     11     cnt_updated := 0;
     12     FOR my_row IN my_csr
     13     LOOP
     14       Update employees_t
     15       Set last_name = 'Forbes'
     16       Where current of my_csr;
     17       cnt_updated := cnt_updated + SQL%ROWCOUNT;
     18       dbms_output.put_line('You updated '||cnt_updated||' records');
     19     END LOOP;
     20*  END;
    SQL> /
    You updated 1 records
    
    PL/SQL procedure successfully completed.
    
    SQL> ed
    Wrote file afiedt.buf
    
      1   DECLARE
      2     CURSOR my_csr IS
      3       Select e.tk, e.first_name, e.last_name, e.rowid
      4       From employees_t e, division d
      5       Where e.code = d.code
      6         and e.code = '01'
      7         and e.last_name = 'Smith'
      8       For update;-- of e.tk;
      9       cnt_updated NUMBER;
     10   BEGIN
     11     cnt_updated := 0;
     12     FOR my_row IN my_csr
     13     LOOP
     14       Update employees_t
     15       Set last_name = 'Forbes'
     16       Where current of my_csr;
     17       cnt_updated := cnt_updated + SQL%ROWCOUNT;
     18       dbms_output.put_line('You updated '||cnt_updated||' records');
     19     END LOOP;
     20*  END;
    SQL> /
    
    PL/SQL procedure successfully completed.
    

    Amiel

Maybe you are looking for

  • No NVIDIA on T520

    I ran a program and he pointed out that I had no 3D graphics features. I checked the specifications of the computer and it shows that NVIDIA NVS 4200 M 1 GB should be incoluded. i5 - 2540M (2.6GHz), 4 GB of RAM, HD 250 GB at 7200 RPM, 15.6 LCD at 192

  • Officejet 5610 prints a line waits 20 seconds etc etc.

    Using the new imac with the driver downloaded on apple store

  • USB does not recognize not material

    I had to uninstall a printer I use, and now when I try to reinstall, my computer can not say it is connected. At the same time, my computer has ceased to recognize other devices like my Iphone and I touch are connected.

  • Lost multimedia all-in-one keyboard usb receiver

    Hello It is possible to replace the USB receiver? Or I have to buy a new package?

  • Time blackBerry Smartphones number my phone rings?

    I'm embarrassed to ask this question, but I can't find an answer anywhere.  When my curve 8520 Blackberry rings it does so twice which means I never answer and I always have to remind.  How can I change the number of times it sounds before cutting in