I would like to create a copy of the structure only of an existing database without it data to a new database (same server).
I am using PHP 5.2.14
I tried:
CREATE DATABASE base3 WITH TEMPLATE base2 OWNER postgres;
And got this error:
ERROR: source database "base2" is being accessed by other users
********** Error **********
ERROR: source database "base2" is being accessed by other users SQL state: 55006
I tried adding this code:
SELECT pg_terminate_backend(pg_stat_activity.procpid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = 'base2' AND procpid <> pg_backend_pid();
and got this error:
ERROR: function pg_terminate_backend(integer) does not exist
LINE 1: SELECT pg_terminate_backend(pg_stat_activity.procpid) FROM p...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
********** Error **********
ERROR: function pg_terminate_backend(integer) does not exist
SQL state: 42883
Hint: No function matches the given name and argument types. You might need to add explicit type casts.
Character: 8
