Postgresql DROP TABLE doesn't work

前端 未结 7 1252
别跟我提以往
别跟我提以往 2020-12-08 02:43

I\'m trying to drop a few tables with the \"DROP TABLE\" command but for a unknown reason, the program just \"sits\" and doesn\'t delete the table that I want i

7条回答
  •  悲&欢浪女
    2020-12-08 02:58

    If this is for AWS postgres run the first statement to get the PID (Process ID) and then run the second query to terminate the process (it would be very similar to do kill -9 but since this is in the cloud that's what AWS recommends)

    -- gets you the PID
    SELECT pid, relname FROM pg_locks l JOIN pg_class t ON l.relation = t.oid AND t.relkind = 'r' WHERE t.relname = 'YOUR_TABLE_NAME'
    
    -- what actually kills the PID ...it is select statement but it kills the job!
    SELECT pg_terminate_backend(YOUR_PID_FROM_PREVIOUS_QUERY);
    

    source

提交回复
热议问题