1.登陆

psql -h 127.0.0.1 -U postgres -p31800

postgres

--------------------------------------------------

(1)列出所有的数据库

mysql: show databases
psql: \l或\list

 

(2)切换数据库

mysql: use dbname
psql: \c dbname

 

(3)列出当前数据库下的数据表

mysql: show tables
psql: \d

 

(4)列出指定表的所有字段

mysql: show columns from table name
psql: \d tablename

 

(5)查看指定表的基本情况

 mysql: describe tablename
psql: \d+ tablename
 
参考: https://www.jb51.net/article/60742.htm
 
6. 查看t_user_info表的进程:
查看t_user_info表的进程:

SELECT * FROM pg_stat_activity where query ~ 't_user_info';

有时候如果发现某一个表锁住了,可以找到对应的进程,用如下命令中断进程:
select pg_terminate_backend('pid');
————————————————

 

相关文章:

  • 2021-09-30
  • 2022-12-23
  • 2022-12-23
  • 2021-10-15
  • 2022-12-23
  • 2021-07-10
  • 2022-01-10
猜你喜欢
  • 2021-05-23
  • 2021-11-20
  • 2022-01-19
  • 2021-10-07
  • 2021-06-04
相关资源
相似解决方案