Re: Creating a new database with a TEMPLATE did not work

From: Ben Morrow <ben(at)morrow(dot)me(dot)uk>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Creating a new database with a TEMPLATE did not work
Date: 2013-02-26 02:46:54
Message-ID: 20130226024654.GA64903@anubis.morrow.me.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Quoth adrian(dot)klaver(at)gmail(dot)com (Adrian Klaver):
> On 02/25/2013 02:49 PM, mkumbale wrote:
> > Hi, I am new to PostgreSQL. I have an empty PostgreSQL DB containing tables
> > but no data. I issued the following command in PGADMIN SQL editor:
> >
> > CREATE DATABASE "NewDefault"
> > WITH OWNER = postgres
> > ENCODING = 'UTF8'
> > TEMPLATE = Default
> > TABLESPACE = pg_default
> > LC_COLLATE = 'English_United States.1252'
> > LC_CTYPE = 'English_United States.1252'
> > CONNECTION LIMIT = -1;
> >
> > Although it created the NewDefault DB, it does not contain any of the tables
> > in Default. Default was disconnected when I executed this command.
> >
> > What am I doing something wrong?
>
> So you have a database named Default?
>
> Probably not a good name because:
> http://www.postgresql.org/docs/9.2/interactive/sql-createdatabase.html
>
> template
> The name of the template from which to create the new database, or
> DEFAULT to use the default template (template1).
>
> So at a guess you are actually creating the new database from template1.

Also, SQL names are folded to lowercase unless they are quoted, so

TEMPLATE = Default

would refer to a database called "default" (if it weren't special syntax
for template1), but

TEMPLATE = "Default"

should find a database created with CREATE DATABASE "Default".

Ben

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Igor Neyman 2013-02-26 14:01:58 Re: Using Ltree For Hierarchical Structures
Previous Message Adrian Klaver 2013-02-25 22:56:23 Re: Creating a new database with a TEMPLATE did not work