Advertisement
Guest User

Untitled

a guest
Jan 17th, 2020
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 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.  
  74. CURSOR cu_indeksy_m IS
  75. SELECT index_name
  76. FROM all_indexes
  77. WHERE index_type = 'NORMAL'
  78. AND temporary = 'N'
  79. AND table_owner = 'MARKET3_USER'
  80. ORDER by table_name ASC, index_name ASC;
  81.  
  82. BEGIN
  83.  
  84. Dbms_Output.put_line('Skompresowano tabele: ' {tabela});
  85. execute immediate 'alter table {tabela} move ROW STORE COMPRESS ADVANCED storage (INITIAL 65536)';
  86.  
  87. FOR i IN cu_indeksy_m LOOP
  88. execute immediate 'alter index ' || i.index_name || ' rebuild COMPRESS ADVANCED HIGH storage (INITIAL 65536)';
  89. Dbms_Output.put_line('Skompresowano index: ' || i.index_name);
  90. END LOOP;
  91.  
  92. END;
  93. /
  94.  
  95. SPOOL OFF;
  96. exit;");
  97. logger.Info(result);
  98. }
  99. }
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement