Answers for "drop database in psql"

SQL
8

postgres remove database

DROP DATABASE IF EXISTS database_name;
Posted by: Guest on September-04-2020
14

postgres delete database

CREATE DATABASE testdb1;
DROP DATABASE testdb1;
Posted by: Guest on June-19-2020
2

drop database postgres

DROP DATABASE base_de_datos;

// SI SALE ESTE MESAJE DE ERROR HAGA LOS PASOS QUE ESTAN A CONTINUACION
ERROR: database "base_de_datos" is being accessed by other users
SQL state: 55006
Detail: There is 1 other session using the database.
----------------------------------------------------------------------

// primer paso ---------------------------------
SELECT *
FROM pg_stat_activity
WHERE datname = 'base_de_datos';

//segundo paso --------------------------------
SELECT
	pg_terminate_backend (pg_stat_activity.pid)
FROM
	pg_stat_activity
WHERE
	pg_stat_activity.datname = 'base_de_datos';
    
// tercer paso --------------------------------
DROP DATABASE 'base_de_datos';

// retira las comillas si no funciona
DROP DATABASE base_de_datos;
Posted by: Guest on April-05-2021
0

drop database using terminal postgres

sql -U <user>  -c "drop database protodb"
Posted by: Guest on November-04-2020

Code answers related to "SQL"

Browse Popular Code Answers by Language