code_junkie

PostgreSQL - Rename database

Nov 11th, 2011
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. ALTER DATABASE people RENAME TO customers;
  2.  
  3. c postgres
  4.  
  5. SELECT pg_terminate_backend( procpid )
  6. FROM pg_stat_activity
  7. WHERE procpid <> pg_backend_pid( )
  8. AND datname = 'name of database';
  9.  
  10. ALTER DATABASE 'name of database' RENAME TO 'new name of database';
Add Comment
Please, Sign In to add comment