admin 发表于 2022-4-15 09:26:14

mariadb删除glance数据库中镜像文件,使用update set 修改运行状态一次操作记录

mariadb删除glance数据库中镜像文件,使用update set 修改运行状态一次操作记录:
MariaDB > select *from images\G
*************************** 1. row ***************************
            id: 0470245c-ee24-488f-89c9-622fd85e9ade
            name: centOS7.9-x86-ssd
            size: 3221225472
          status: deleted
      created_at: 2022-04-08 12:48:27
      updated_at: 2022-04-15 01:04:25
      deleted_at: 2022-04-15 01:04:25
         deleted: 1
   disk_format: raw
container_format: bare
      checksum: 6067ba67d340d6849fb08ad2dc1dc752
         owner: 6f0124196ea74eb79fbcf370add3ca7e
      min_disk: 0
         min_ram: 0
       protected: 0
    virtual_size: NULL
      visibility: public
*************************** 2. row ***************************
            id: 18804abd-9cba-4a94-8ceb-ba9b12f9fc47
            name: RHEL-Server-7.9-hdd-2.4T
            size: 3006477312
          status: active
      created_at: 2022-04-12 02:44:15
      updated_at: 2022-04-15 01:04:39
      deleted_at: NULL
         deleted: 0
   disk_format: raw
container_format: bare
      checksum: 3ddbd59c32a4ec8141018ee9a433c78e
         owner: 6f0124196ea74eb79fbcf370add3ca7e
      min_disk: 0
         min_ram: 0
       protected: 0
    virtual_size: NULL
      visibility: private
*************************** 3. row ***************************
            id: b9c335c4-34a8-498c-a735-82567f7ef186
            name: rhel-server-7.9-ssd
            size: 2684354560
          status: deleted
      created_at: 2022-04-11 07:22:43
      updated_at: 2022-04-11 08:02:40
      deleted_at: 2022-04-11 08:02:40
         deleted: 1
   disk_format: raw
container_format: bare
      checksum: 67e20fa3da128b17c3ec01d03e1e293d
         owner: 6f0124196ea74eb79fbcf370add3ca7e
      min_disk: 0
         min_ram: 0
       protected: 0
    virtual_size: NULL
      visibility: public
*************************** 4. row ***************************
            id: ea333f95-79c3-4ce4-856b-a397cc963d77
            name: windows_2019_x64-hdd-2.4T
            size: 12884901888
          status: active
      created_at: 2022-04-13 01:25:56
      updated_at: 2022-04-14 03:42:54
      deleted_at: NULL
         deleted: 0
   disk_format: raw
container_format: bare
      checksum: 2eabbd70218411fdb021c4cdb790b82f
         owner: 6f0124196ea74eb79fbcf370add3ca7e
      min_disk: 0
         min_ram: 0
       protected: 0
    virtual_size: NULL
      visibility: public
*************************** 5. row ***************************
            id: fb5fe7ed-ba56-4ae2-a483-af3cc0cce891
            name: RHEL-Server-7.9-ssd
            size: 3006477312
          status: active
      created_at: 2022-04-12 02:16:14
      updated_at: 2022-04-15 01:04:46
      deleted_at: NULL
         deleted: 0
   disk_format: raw
container_format: bare
      checksum: 3ddbd59c32a4ec8141018ee9a433c78e
         owner: 6f0124196ea74eb79fbcf370add3ca7e
      min_disk: 0
         min_ram: 0
       protected: 0
    virtual_size: NULL
      visibility: private
5 rows in set (0.00 sec)

MariaDB > update glance.images set deleted='1' where id="fb5fe7ed-ba56-4ae2-a483-af3cc0cce891";
Query OK, 1 row affected (0.01 sec)
Rows matched: 1Changed: 1Warnings: 0
MariaDB > select *from images\G
*************************** 1. row ***************************
            id: 0470245c-ee24-488f-89c9-622fd85e9ade
            name: centOS7.9-x86-ssd
            size: 3221225472
          status: deleted
      created_at: 2022-04-08 12:48:27
      updated_at: 2022-04-15 01:04:25
      deleted_at: 2022-04-15 01:04:25
         deleted: 1
   disk_format: raw
container_format: bare
      checksum: 6067ba67d340d6849fb08ad2dc1dc752
         owner: 6f0124196ea74eb79fbcf370add3ca7e
      min_disk: 0
         min_ram: 0
       protected: 0
    virtual_size: NULL
      visibility: public
*************************** 2. row ***************************
            id: 18804abd-9cba-4a94-8ceb-ba9b12f9fc47
            name: RHEL-Server-7.9-hdd-2.4T
            size: 3006477312
          status: active
      created_at: 2022-04-12 02:44:15
      updated_at: 2022-04-15 01:04:39
      deleted_at: NULL
         deleted: 0
   disk_format: raw
container_format: bare
      checksum: 3ddbd59c32a4ec8141018ee9a433c78e
         owner: 6f0124196ea74eb79fbcf370add3ca7e
      min_disk: 0
         min_ram: 0
       protected: 0
    virtual_size: NULL
      visibility: private
*************************** 3. row ***************************
            id: b9c335c4-34a8-498c-a735-82567f7ef186
            name: rhel-server-7.9-ssd
            size: 2684354560
          status: deleted
      created_at: 2022-04-11 07:22:43
      updated_at: 2022-04-11 08:02:40
      deleted_at: 2022-04-11 08:02:40
         deleted: 1
   disk_format: raw
container_format: bare
      checksum: 67e20fa3da128b17c3ec01d03e1e293d
         owner: 6f0124196ea74eb79fbcf370add3ca7e
      min_disk: 0
         min_ram: 0
       protected: 0
    virtual_size: NULL
      visibility: public
*************************** 4. row ***************************
            id: ea333f95-79c3-4ce4-856b-a397cc963d77
            name: windows_2019_x64-hdd-2.4T
            size: 12884901888
          status: active
      created_at: 2022-04-13 01:25:56
      updated_at: 2022-04-14 03:42:54
      deleted_at: NULL
         deleted: 0
   disk_format: raw
container_format: bare
      checksum: 2eabbd70218411fdb021c4cdb790b82f
         owner: 6f0124196ea74eb79fbcf370add3ca7e
      min_disk: 0
         min_ram: 0
       protected: 0
    virtual_size: NULL
      visibility: public
*************************** 5. row ***************************
            id: fb5fe7ed-ba56-4ae2-a483-af3cc0cce891
            name: RHEL-Server-7.9-ssd
            size: 3006477312
          status: active
      created_at: 2022-04-12 02:16:14
      updated_at: 2022-04-15 01:04:46
      deleted_at: NULL
         deleted: 1
   disk_format: raw
container_format: bare
      checksum: 3ddbd59c32a4ec8141018ee9a433c78e
         owner: 6f0124196ea74eb79fbcf370add3ca7e
      min_disk: 0
         min_ram: 0
       protected: 0
    virtual_size: NULL
      visibility: private
5 rows in set (0.00 sec)
MariaDB > select id,name,deleted,statusfrom images;
+--------------------------------------+---------------------------+---------+---------+
| id                                 | name                      | deleted | status|
+--------------------------------------+---------------------------+---------+---------+
| 0470245c-ee24-488f-89c9-622fd85e9ade | centOS7.9-x86-ssd         |       1 | deleted |
| 18804abd-9cba-4a94-8ceb-ba9b12f9fc47 | RHEL-Server-7.9-hdd-2.4T|       0 | active|
| b9c335c4-34a8-498c-a735-82567f7ef186 | rhel-server-7.9-ssd       |       1 | deleted |
| ea333f95-79c3-4ce4-856b-a397cc963d77 | windows_2019_x64-hdd-2.4T |       0 | active|
| fb5fe7ed-ba56-4ae2-a483-af3cc0cce891 | RHEL-Server-7.9-ssd       |       1 | active|
+--------------------------------------+---------------------------+---------+---------+
5 rows in set (0.00 sec)
MariaDB > update glance.images set deleted='1' where id="18804abd-9cba-4a94-8ceb-ba9b12f9fc47";
Query OK, 1 row affected (0.00 sec)
Rows matched: 1Changed: 1Warnings: 0
MariaDB > select id,name,deleted,statusfrom images;
+--------------------------------------+---------------------------+---------+---------+
| id                                 | name                      | deleted | status|
+--------------------------------------+---------------------------+---------+---------+
| 0470245c-ee24-488f-89c9-622fd85e9ade | centOS7.9-x86-ssd         |       1 | deleted |
| 18804abd-9cba-4a94-8ceb-ba9b12f9fc47 | RHEL-Server-7.9-hdd-2.4T|       1 | active|
| b9c335c4-34a8-498c-a735-82567f7ef186 | rhel-server-7.9-ssd       |       1 | deleted |
| ea333f95-79c3-4ce4-856b-a397cc963d77 | windows_2019_x64-hdd-2.4T |       0 | active|
| fb5fe7ed-ba56-4ae2-a483-af3cc0cce891 | RHEL-Server-7.9-ssd       |       1 | active|
+--------------------------------------+---------------------------+---------+---------+
5 rows in set (0.01 sec)


完成更新数据。切记不要delete数据,因为这些数据库表之间有关联,会导致数据库凌乱。解决办法一般都是update状态。切记切记。
页: [1]
查看完整版本: mariadb删除glance数据库中镜像文件,使用update set 修改运行状态一次操作记录