Oracle extracts data through dblink

Source: Internet
Author: User

You can use select * from user_sequence and select * from all_tables to obtain the names of sequence and table for concatenation.

The biggest fear is that the current account has insufficient permissions. It's a testing environment, so I can do whatever I want.

 

  1. Create or replace package extraction_dataIs
  2. -- Author: ADMINISTRATOR
  3. -- Created: 03:36:28
  4. -- Purpose: extract data
  5. Cursor TNAMEIsSELECT table_name AS table_name FROM all_tables@TB.REGRESS.RDBMS.DEV.US.Oracle.COM where owner = upper ('Tidba');
  6. PROCEDURE EXT_DATA;
  7. PROCEDURE EXT_SEQ;
  8. End extraction_data;
  9. /
  10. Create or replace package body extraction_dataIs
  11. PROCEDURE EXT_DATA IS
  12. BEGIN
  13. FOR T IN TNAME LOOP
  14. /* Dbms_output.put_line ('execute the insert process' | T. table_name );*/
  15. -- Delete a table to prevent repeated data insertion.
  16. Begin
  17. EXECUTE IMMEDIATE'Drop table'| T. table_name;
  18. Exception when others then null;
  19. End;
  20. -- Output the SQL statement to be executed
  21. Dbms_output.put_line ('Create table tieba .'| T. table_name |'As select * from'| T. table_name |'@ TB. REGRESS. RDBMS. DEV. US. ORACLE. COM');
  22. Dbms_output.put_line ('Commit ;');
  23. -- You may not be able to execute the remote table data to a local directory.
  24. /* Execute immediate 'create table tieba. '| T. table_name | 'as select * from '| T. table_name | '@ TB. REGRESS. RDBMS. DEV. US. ORACLE. COM ';*/
  25. End loop;
  26. END EXT_DATA;
  27. -- This process is not successfully executed. You can assemble sequence strings as needed.
  28. PROCEDURE EXT_SEQ IS
  29. BEGIN
  30. -- Create sequence
  31. -- Create sequence ADMIN_MESSAGE_SEQ minvalue 1 maxvalue 999999999 start with 100000 increment by 1 cache 20;
  32. -- Select * from user_sequence;
  33. For t in (select * from user_sequences@TB.REGRESS.RDBMS.DEV.US.ORACLE.COM) LOOP
  34. /* Dbms_output.put_line ('execute the insert process' | T. table_name );*/
  35. -- Delete a table to prevent repeated data insertion.
  36. Begin
  37. EXECUTE IMMEDIATE'Drop sequence'| T. sequence_name;
  38. Exception when others then null;
  39. End;
  40. -- Output the SQL statement to be executed
  41. Dbms_output.put_line ('Create sequence tieba .'| T. sequence_name |'Minvalue 1 maxvalue 999999999 start'| T. LAST_NUMBER |'Increment by 1 cache 20 ;');
  42. /* Execute immediate 'create sequence tieba. '| T. sequence_name | 'minvalue 1 maxvalue 999999999 start with' | T. LAST_NUMBER | 'crement by 1 cache 20 ;';*/
  43. End loop;
  44. Dbms_output.put_line ('Commit ;');
  45. END EXT_SEQ;
  46. End extraction_data;
  47. /

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.