- 登录另外一个服务器的数据库
- xhell5连接上在之前申请的远程服务器
- psql -h 10.249.104.136 -p 5434 -U postgres -W lomic 登录pgsql(部署在另外一台远程服务器)
- 密码:hh123456789
- 登录开发机postgres数据库
- su postgres
- psql
- 进入了postgres数据库,用户名postgres,可以开始对数据库操作了
- 数据库操作常用命令
- \d 显示pgsql中全部的表
- \du 显示所有role
- SELECT * FROM operation; 查看表
- SELECT COUNT(*) FROM operation; 查询operation表有多少条记录
- select column_name,data_type from information_schema.columns where table_name = ‘operation’; 查每个字段的类型
- select * from operation_100w where module_id=‘100810001011’; 查询表中module_id='100810001011’的记录
- DELETE FROM COMPANY; 删除COMPANY表中所有记录
su postgres 登录postgres数据库软件自带的postgres role(这个role具有login权限,所以可以称之为user)
psql 此时进入postgres role
\q 退出postgres role
exit 退出bash
https://www.bookstack.cn/read/getting_started_with_postgresql/pgsql.md