Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Diagnostics;
- using System.Threading;
- using System.Net.NetworkInformation;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text.RegularExpressions;
- using System.Text;
- namespace Import
- {
- class Program
- {
- public static void Main(string[] args)
- {
- string tabela;
- Program p = new Program();
- string[] table = File.ReadAllLines("tabele.txt");
- Process cmd = new Process();
- cmd.StartInfo.RedirectStandardInput = true;
- cmd.StartInfo.RedirectStandardOutput = true;
- cmd.StartInfo.UseShellExecute = false;
- cmd.StartInfo.CreateNoWindow = false;
- cmd.StartInfo.FileName = "cmd.exe";
- cmd.Start();
- string last = table.Last();
- for(int i=0; i<table.Length; i++)
- {
- cmd.StandardInput.WriteLine("imp market3_user/for8667319com file=expm.dat log=impm.log tables={0}", table[i]);
- if(i>0){
- tabela = table[i-1];
- p.Compres(tabela);
- }
- else if(table[i]==last){
- tabela=table[i];
- p.Compres(tabela);
- }
- else if(i%5==0&&i>0){
- p.sizeCheck();
- }
- }
- Console.ReadKey(true);
- }
- public void sizeCheck()
- {
- SQLplus size = new SQLplus("sys/oracle as sysdba");
- string rozmiar = size.execute("SELECT to_char(round(Sum(bytes)/1024/1024), '99990.99') FROM dba_segments WHERE TABLESPACE_NAME='USERS';");
- Console.WriteLine(rozmiar);
- }
- public void Compres(string tabela)
- {
- SQLplus query = new SQLplus("market3_user/for8667319com");
- string result = query.execute($@"set verify off;
- SET NEWPAGE 0;
- SET SPACE 0;
- SET LINESIZE 1000;
- SET PAGESIZE 0;
- SET ECHO OFF;
- SET FEEDBACK OFF;
- SET HEADING ON;
- SET COLSEP ' ';
- SET TRIMSPOOL ON;
- SET SERVEROUTPUT ON;
- SPOOL COMPRESS_LOG.log;
- DECLARE
- CURSOR cu_tabele_m IS
- SELECT table_name
- FROM all_tables
- WHERE temporary='N'
- AND owner = 'MARKET3_USER'
- AND tablespace_name = 'USERS'
- ORDER by table_name ASC;
- CURSOR cu_indeksy_m IS
- SELECT index_name
- FROM all_indexes
- WHERE index_type = 'NORMAL'
- AND temporary = 'N'
- AND table_owner = 'MARKET3_USER'
- ORDER by table_name ASC, index_name ASC;
- BEGIN
- FOR i IN cu_tabele_m LOOP
- Dbms_Output.put_line('Skompresowano tabele: ' || i.table_name);
- execute immediate 'alter table ' || i.table_name || ' move ROW STORE COMPRESS ADVANCED storage (INITIAL 65536)';
- END LOOP;
- FOR i IN cu_indeksy_m LOOP
- execute immediate 'alter index ' || i.index_name || ' rebuild COMPRESS ADVANCED HIGH storage (INITIAL 65536)';
- Dbms_Output.put_line('Skompresowano index: ' || i.index_name);
- END LOOP;
- END;
- /
- SPOOL OFF;
- exit;");
- logger.Info(result);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement