postgres常用命令
安装的时候用的是install 数据库
psql zone
查看数据库下的所有表名字
\dt
查询出来表名字就 直接看里面的数据
select * from node;
删除脏数据
update node set host_address = '' ;
---
参考资料
---
查看数据库里面的所有数据库名字
\l
查看数据库下的所有表名字
\dt
查询表里面数据
select * from image ; select * from instance ;
修改内容
update instance set host_machine = 'cqjxpoc3' where instance_id = 'i-ugb2syhv';
---
示例步骤
切换到 postgres 用户
> root@ks1:~# su - postgres > postgres@ks1:~$ psql > psql (9.3.17) > Type "help" for help.
退出数据库
> postgres=# \q
登陆 数据库 zone
> postgres@ks1:~$ psql zone > psql (9.3.17) > Type "help" for help.
修改日志
root@ks1:~# su - postgres postgres@ks1:~$ psql psql (9.3.17) Type "help" for help. postgres=# \q postgres@ks1:~$ psql zone psql (9.3.17) Type "help" for help. zone=# select * from in information_schema.administrable_role_authorizations information_schema.foreign_table_options information_schema.sql_sizing information_schema.applicable_roles information_schema.foreign_tables information_schema.sql_sizing_profiles information_schema.attributes information_schema.information_schema_catalog_name information_schema.table_constraints instance_id | instance_name | description | image_id | instance_type | vcpus_max | vcpus_current | cpu_topology | memory_max | memory_current | graphics_protocol | graphics_passwd | graphics_port | broker_host | broker_port | status | sub_code | transition_status | host_machine | controller | create_time | status_time | console_id | owner | root_user_id | place_group_id | instance_class | hostname -------------+-------------------------------------------+-------------+----------------------------+---------------+-----------+---------------+--------------+------------+----------------+-------------------+----------------------------------+---------------+------------------------+-------------+---------+----------+-------------------+--------------+------------+---------------------+---------------------+------------+-------+--------------+----------------+----------------+----------------- i-s670gldn | 21.10.vms.isos.ccdc.online.vps.d | | win2k8r2eechsj | c4m8 | 4 | 4 | | 8192 | 8192 | vnc | bzx5KCkRmICEnvf8bpvLFaaR7szwd8B6 | 5905 | | | ceased | 0 | | cqjxpoc1 | self | 2018-02-06 21:47:24 | 2018-04-02 10:26:56 | cqjxcloud | admin | admin | plg-00000001 | 1 | vms.isos i-ba26diu0 | 10.10.trx.isos.ccdc.online.vps.dc | | win2k8r2eechsj | c4m8 | 4 | 4 | | 8192 | 8192 | vnc | VP1P20mBDFwd zone=# select * from instance where instance_id = 'i-g2vg3eey'; zone=# select host_machine from instance where instance_id = 'i-g2vg3eey'; host_machine cqjxpoc2 (1 row) zone=# update instance set host_machine = 'cqjxpoc3' where instance_id = 'i-g2vg3eey'; UPDATE 1 zone=#zone=# update instance set host_machine = 'cqjxpoc3' where instance_id = 'i-g2vg3eey'; UPDATE 1 zone=# update volume set host_machine = 'cqjxpoc3' where volume_id = 'vol-yjcfik5d'; UPDATE 1 zone=# select * from volume where volume_id = 'vol-yjcfik5d'; zone=#
修改数据库
update instance set host_machine = 'cqjxpoc3' where instance_id = 'i-ugb2syhv'; select * from volume where volume_id = 'vol-meqi3kde'; update volume set host_machine = 'cqjxpoc3' where volume_id = 'vol-meqi3kde';