Database schema

Started by Dhiraj Guptaover 13 years ago6 messagesgeneral
Jump to latest
#1Dhiraj Gupta
dhiraj.g@nic.in

 Hi All,
I have created a database name '"ofbiz". then the default schema name "public " created automatically. I want to create schema name ofbiz in the database "ofbiz"
 when I create database name "ofbiz" then the schema name "ofbiz" will create automatically.
how it is possible if yes,

Thanks
Dhiraj Gupta

#2Karsten Hilbert
Karsten.Hilbert@gmx.net
In reply to: Dhiraj Gupta (#1)
Re: Database schema

I have created a database name '"ofbiz". then the default schema name
"public " created automatically. I want to create schema name ofbiz in the
database "ofbiz"
 when I create database name "ofbiz" then the schema name "ofbiz" will
create automatically.
how it is possible if yes,

Pre-create the schema in the database that's used as a template when
creating database ofbiz.

It's all in the docs.

Karsten

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#3Laurenz Albe
laurenz.albe@cybertec.at
In reply to: Dhiraj Gupta (#1)
Re: Database schema

Dhiraj Gupta wrote:

I have  created a database name '"ofbiz". then the default  schema name "public "
created automatically. I want to create schema name ofbiz in the database "ofbiz"
 when I create database name "ofbiz" then the schema name "ofbiz" will create automatically.
how it is possible if yes,

There is no way to automatically create a schema when you create a database.
Connect to the newly created database and create it with CREATE SCHEMA.
You can DROP SCHEMA public if you don't need it.

Yours,
Laurenz Albe

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#4Greg Williamson
gwilliamson39@yahoo.com
In reply to: Dhiraj Gupta (#1)
Re: Database schema

Dhiraj --

________________________________
From: Dhiraj Gupta <dhiraj.g@nic.in>
To: pgsql-general@postgresql.org
Sent: Sunday, December 2, 2012 9:35 PM
Subject: [GENERAL] Database schema

 Hi All,
I have  created a database name '"ofbiz". then the default  schema name "public " created automatically. I want to create schema name ofbiz in the database "ofbiz"
 when I create database name "ofbiz" then the schema name "ofbiz" will create automatically.
how it is possible if yes,

Thanks
Dhiraj Gupta

When a new database is created, the template is the builtin database called "template1".

If you create the schema in that database, that schema will be made part of any new database you make. You could also make a new template database, create the schema in that one, and then create your new databases using the "WITH TEMPLATE = " option in CREATE DATABASE. So if you have need of different schemas with different databases, that would be more extensible by making new templates, onjhe3 for each type./.

HTH,

Greg Williamson

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#5Andreas Kretschmer
akretschmer@spamfence.net
In reply to: Laurenz Albe (#3)
Re: Database schema

Albe Laurenz <laurenz.albe@wien.gv.at> wrote:

Dhiraj Gupta wrote:

I have� created a database name '"ofbiz". then the default� schema name "public "
created automatically. I want to create schema name ofbiz in the database "ofbiz"
�when I create database name "ofbiz" then the schema name "ofbiz" will create automatically.
how it is possible if yes,

There is no way to automatically create a schema when you create a database.
Connect to the newly created database and create it with CREATE SCHEMA.
You can DROP SCHEMA public if you don't need it.

There is a way to create a so called schema in every new created
database: create that schema in the template1, or create a new template
database and use this template to create a new database.

Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect. (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly." (unknown)
Kaufbach, Saxony, Germany, Europe. N 51.05082�, E 13.56889�

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#6Laurenz Albe
laurenz.albe@cybertec.at
In reply to: Andreas Kretschmer (#5)
Re: Database schema

Andreas Kretschmer wrote:

Albe Laurenz <laurenz.albe@wien.gv.at> wrote:

Dhiraj Gupta wrote:

I have  created a database name '"ofbiz". then the default  schema name "public "
created automatically. I want to create schema name ofbiz in the database "ofbiz"
 when I create database name "ofbiz" then the schema name "ofbiz" will create automatically.
how it is possible if yes,

There is no way to automatically create a schema when you create a database.
Connect to the newly created database and create it with CREATE SCHEMA.
You can DROP SCHEMA public if you don't need it.

There is a way to create a so called schema in every new created
database: create that schema in the template1, or create a new template
database and use this template to create a new database.

Technically you are right, but from the original question I assumed
that the schema should have the same name as the database.

Yours,
Laurenz Albe

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general