Code Snippet

Just another Code Snippet site

Random Post :




[Oracle] Deleting large amount of data

declare 
e number;
i number
begin
  select count(*) from <TABLE_NAME> where <CONDITION>;
  f :=trunc(e/10000)+1;
  for i in 1.. f
  loop
    delete from <TABLE_NAME> where <CONDITION> and rownum<=10000;
    commit;
    dbms_lock.sleep(600); -- purge old archive if it's possible
  end loop;
end;

DECLARE
 v_limit PLS_INTEGER :=100000;

CURSOR delete_cursor
IS 
  SELECT rowid 
  FROM <TABLE_NAME> p
  WHERE <CONDITION>;

TYPE recordsToDeleteType IS TABLE OF delete_cursor%ROWTYPE
        INDEX BY PLS_INTEGER;
		
recordsToDelete recordsToDeleteType;

BEGIN
  OPEN delete_cursor;
    LOOP
      FETCH delete_cursor 
        BULK COLLECT INTO recordsToDelete LIMIT v_limit;

    FORALL indx IN 1 .. recordsToDelete.COUNT 
      DELETE FROM <TABLE_NAME> WHERE rowid=recordsToDelete(indx);

    EXIT WHEN delete_cursor%NOTFOUND;

   END LOOP;

   CLOSE delete_cursor;
  COMMIT;
END;

BEGIN
LOOP

delete FROM <TABLE_NAME> 
  where <CONDITION> and rownum < 50000;

  exit when SQL%rowcount < 49999;

  commit;

END LOOP;

commit;

END;

,

[Unix] RHEL Setup RDP server

https://medium.com/@ndeepak_/how-to-install-xrdp-on-red-hat-8-and-centos-1b260c937890

Install EPEL
RHEL8

sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

Centos 8

sudo yum install -y epel-release

Install Gnome Desktop and VNC Server

sudo yum groupinstall -y "Server with GUI"
sudo yum install -y tigervnc-server xrdp

Start and check server

sudo systemctl start xrdp
sudo systemctl enable xrdp
sudo netstat -antup | grep xrdp

Firewall config, if needed:

sudo firewall-cmd --permanent --add-port=3389/tcp && sudo firewall-cmd --reload

For VNC/RDP, user/password is mandatory, SSH key is not possible.

, , , ,

[WordPress] Usefull plugin

http://www.it-connect.fr/11-plugins-indispensables-pour-votre-site-wordpress/

lsof

Répertorier les fichiers ouverts contenant le répertoire

lsof +D {path}

Liste des fichiers ouverts par PID

sudo lsof -p {process-id}

Répertorier les fichiers ouverts par processus

sudo lsof -c {process-name}

Répertorier les fichiers ouverts par nom d’utilisateur

sudo lsof -u {username}

Pour lister tous les processus qui ont ouvert un fichier spécifique, nous pouvons spécifier file-name comme argument:

sudo lsof {file-name}

Previous Posts Next posts