2024.06.21 - [DB/postgreSQL] - DELETE와 UPDATE 쿼리문의 차이점

 

DELETE와 UPDATE 쿼리문의 차이점

DELETE와 UPDATE를 통한 "삭제"의 차이점 DELETE로 삭제: 해당 행이 테이블에서 완전히 제거된다. 이 작업은 데이터 복구가 어렵거나 불가능할 수 있습니다. 삭제된 데이터를 복구하려면 백업이 필요

nomajorkorean.tistory.com

 

 

# SELECT * FROM agentinfo ;

 _agentid |          _agentname          | _enabled | _connected | _updated | _shorttermbasic | _shorttermproc | _shorttermio | _shorttermcpu | _longtermbasic | _longtermproc | _longtermio | _longtermcpu |   _model   | _serial  | _group |  _ipaddress   | _pscommand |                       _logevent                       | _processevent | _timecheck | _disconnectedtime | _skipdatatypes | _virbasicperf | _hypervisor |  _serviceevent  | _installdate | _ibmpcrate | _updatedtime
----------+------------------------------+----------+------------+----------+-----------------+----------------+--------------+---------------+----------------+---------------+-------------+--------------+------------+----------+--------+---------------+------------+-------------------------------------------------------+---------------+------------+-------------------+----------------+---------------+-------------+-----------------+--------------+------------+--------------
        4 | jwchoi_ol7_2                 |        1 |          1 |        0 |               2 |              5 |            5 |             5 |            600 |           600 |         600 |          600 | VirtualBox | 0        |        | 192.168.0.34  |            | "1,*,/var/log/messages"                               |               |          1 |        1718974447 |              0 |             1 |           0 |                 |   1718273170 |          0 |   1718974485
        0 | NULL                         |        0 |          0 |          |                 |                |              |               |                |               |             |              |            |          |        |               |            |                                                       |               |            |                   |                |               |             |                 |              |            |
        3 | jwchoi_ol7                   |        1 |          1 |        0 |               2 |              5 |            5 |             5 |            600 |           600 |         600 |          600 | VirtualBox | 0        |        | 192.168.0.34  |            |                                                       |               |          1 |        1718974447 |              0 |             1 |           0 |                 |   1718271967 |          0 |   1718974486
        1 | OL7.9.myguest.virtualbox.org |        1 |          0 |        0 |               2 |              5 |            5 |             5 |            600 |           600 |         600 |          600 | VirtualBox | 0        |        | 192.168.138.1 |            |                                                       |               |          1 |        1718271964 |              0 |             1 |           0 |                 |   1718015944 |          0 |   1718271964
        2 | jaewoochoi                   |        1 |          1 |        0 |               2 |              5 |            5 |             5 |            600 |           600 |         600 |          600 | 21F6S00M00 | PF40J09A |        | 192.168.0.34  |            | "2,postgresqlDB,windowsevent messageon : application" | postgres.exe  |          1 |        1718982916 |              0 |             1 |           0 | onTuneService,0 |   1718270569 |          0 |   1718982930
(5개 행)
// Agentinfo 테이블 조회

 

 

 

# SELECT _agentid, _agentname, _enabled  FROM agentinfo WHERE _agentname='jaewoochoi';  

 _agentid | _agentname | _enabled
----------+------------+----------
        2 | jaewoochoi |        1
(1개 행)
// onTune Agent 삭제 및 onTuneAdmin.exe 에서 대상 호스트를 삭제했다면 _enabled가 2로 조회된다.

 

 

# UPDATE agentinfo set _enabled='2' WHERE _agentname='jaewoochoi';

UPDATE 1
// 상태 변경 -> 2

 

 

# SELECT _agentid, _agentname, _enabled FROM agentinfo WHERE _agentname='jaewoochoi';

 _agentid | _agentname | _enabled
----------+------------+----------
        2 | jaewoochoi |        2
(1개 행)
// 다시 조회

 

 

 

 

Admin으로 확인 ,

Agent 서버가 삭제된 것을 확인할 있다.

 

 

 

 

# SELECT _agentid ,_agentname ,_enabled FROM agentinfo WHERE _agentname='jaewoochoi';

 _agentid | _agentname | _enabled
----------+------------+----------
        2 | jaewoochoi |        2
(1개 행)

 

 

 

# UPDATE agentinfo SET _enabled='1' WHERE _agentname='jaewoochoi';

UPDATE 1
// 서버 상태 변경 -> 1

 

 

# SELECT _agentid ,_agentname ,_enabled FROM agentinfo WHERE _agentname='jaewoochoi';

 _agentid | _agentname | _enabled
----------+------------+----------
        2 | jaewoochoi |        1
(1개 행)
// _enabled가 1로 변경되었으면, onTuneAdmin 에서 대상 호스트의 에이전트와 통신이 되는지 확인한다.

 

 

 

Admin으로 확인 ,

Agent 서버가 활성화 것을 확인할 있다.

 

 

 

 

+ Recent posts