Advertisement
Guest User

Untitled

a guest
Jan 17th, 2020
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.73 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. using System.Diagnostics;
  4. using System.Threading;
  5. using System.Net.NetworkInformation;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text.RegularExpressions;
  9. using System.Text;
  10.  
  11. namespace Import
  12. {
  13. class Program
  14. {
  15. public static void Main(string[] args)
  16. {
  17. string tabela;
  18. Program p = new Program();
  19. string[] table = File.ReadAllLines("tabele.txt");
  20. Process cmd = new Process();
  21. cmd.StartInfo.RedirectStandardInput = true;
  22. cmd.StartInfo.RedirectStandardOutput = true;
  23. cmd.StartInfo.UseShellExecute = false;
  24. cmd.StartInfo.CreateNoWindow = false;
  25. cmd.StartInfo.FileName = "cmd.exe";
  26. cmd.Start();
  27. string last = table.Last();
  28. for(int i=0; i<table.Length; i++)
  29. {
  30. cmd.StandardInput.WriteLine("imp market3_user/for8667319com file=expm.dat log=impm.log tables={0}", table[i]);
  31.  
  32. if(i>0){
  33. tabela = table[i-1];
  34. p.Compres(tabela);
  35. }
  36. else if(table[i]==last){
  37. tabela=table[i];
  38. p.Compres(tabela);
  39. }
  40. else if(i%5==0&&i>0){
  41. p.sizeCheck();
  42. }
  43. }
  44. Console.ReadKey(true);
  45. }
  46.  
  47. public void sizeCheck()
  48. {
  49. SQLplus size = new SQLplus("sys/oracle as sysdba");
  50. string rozmiar = size.execute("SELECT to_char(round(Sum(bytes)/1024/1024), '99990.99') FROM dba_segments WHERE TABLESPACE_NAME='USERS';");
  51. Console.WriteLine(rozmiar);
  52. }
  53.  
  54. public void Compres(string tabela)
  55. {
  56. SQLplus query = new SQLplus("market3_user/for8667319com");
  57. string result = query.execute($@"set verify off;
  58. SET NEWPAGE 0;
  59. SET SPACE 0;
  60. SET LINESIZE 1000;
  61. SET PAGESIZE 0;
  62. SET ECHO OFF;
  63. SET FEEDBACK OFF;
  64. SET HEADING ON;
  65. SET COLSEP ' ';
  66. SET TRIMSPOOL ON;
  67. SET SERVEROUTPUT ON;
  68.  
  69. SPOOL COMPRESS_LOG.log;
  70.  
  71. DECLARE
  72.  
  73. CURSOR cu_tabele_m IS
  74. SELECT table_name
  75. FROM all_tables
  76. WHERE temporary='N'
  77. AND owner = 'MARKET3_USER'
  78. AND tablespace_name = 'USERS'
  79. ORDER by table_name ASC;
  80.  
  81. CURSOR cu_indeksy_m IS
  82. SELECT index_name
  83. FROM all_indexes
  84. WHERE index_type = 'NORMAL'
  85. AND temporary = 'N'
  86. AND table_owner = 'MARKET3_USER'
  87. ORDER by table_name ASC, index_name ASC;
  88.  
  89. BEGIN
  90.  
  91. FOR i IN cu_tabele_m LOOP
  92. Dbms_Output.put_line('Skompresowano tabele: ' || i.table_name);
  93. execute immediate 'alter table ' || i.table_name || ' move ROW STORE COMPRESS ADVANCED storage (INITIAL 65536)';
  94. END LOOP;
  95.  
  96. FOR i IN cu_indeksy_m LOOP
  97. execute immediate 'alter index ' || i.index_name || ' rebuild COMPRESS ADVANCED HIGH storage (INITIAL 65536)';
  98. Dbms_Output.put_line('Skompresowano index: ' || i.index_name);
  99. END LOOP;
  100.  
  101. END;
  102. /
  103.  
  104. SPOOL OFF;
  105. exit;");
  106. logger.Info(result);
  107. }
  108. }
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement