473,799 Members | 3,005 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Creating database problem

Hi All,

I'm unsure if this is the correct mailinglist for my question. I have a
problem with CREATE DATABASE, but as the docs state that officially this
is not an SQL statement, I was unsure if I should subscribe to pgsql-sql
or pgsql-general.

NOTE: I've searched on google, postgresql.org, FAQ's and the
static/dynamic documentation, but I couldn't find a solution to my problem.

When I try to execute "CREATE DATABASE somename" while connected to
database template1 as a non-superuser with createdb-rights, I get the
error message "source database "template1" is being accessed by other
users". This is correct, as I'm connected to the same server using
pgAdmin III on a different PC. But my question is, why this error
message? I understand that I need to be using at least _some_ database
in other to connect. But why can I only create a new database (which, as
far as I know, has nothing to do with template1 itself) if I'm the only
connected user? Or am I missing something? I do need to be able to
create databases while other users are connected.

I've used MySQL in the past, which allows a user to create databases
whenever he likes, no matter how many people are connected. I expected
Postgres to do the same, but maybe I'm doing something wrong... :)

Thanks in advance for any help!

Marc

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postg resql.org so that your
message can get through to the mailing list cleanly

Nov 23 '05 #1
2 9139
> When I try to execute "CREATE DATABASE somename" while connected to
database template1 as a non-superuser with createdb-rights, I get the
error message "source database "template1" is being accessed by other
users". This is correct, as I'm connected to the same server using
pgAdmin III on a different PC. But my question is, why this error
message? I understand that I need to be using at least _some_ database
in other to connect. But why can I only create a new database (which, as
far as I know, has nothing to do with template1 itself) "Create database" does have to do with template1. Template1 is
used as the template for the new database ;-)
if I'm the only
connected user? Or am I missing something? I do need to be able to
create databases while other users are connected.

Sure, but not while they are connected to template1. There is
no real reason that I know of why ordinary users should be
connected to template1 for any significant amount of time.

HTH,
Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 23 '05 #2
"M.A. Oude Kotte" <ma**@solcon.nl > writes:
When I try to execute "CREATE DATABASE somename" while connected to
database template1 as a non-superuser with createdb-rights, I get the
error message "source database "template1" is being accessed by other
users". This is correct, as I'm connected to the same server using
pgAdmin III on a different PC. But my question is, why this error
message?


It's a locking issue: if the other guy is changing the database while
you copy it, you'd get an inconsistent copy.

The test is not bulletproof, since in theory someone could connect to
the source database after we make the check and alter it underneath us
while the copy is still proceeding. But it's better than no defense at all.

One possible way to work around the issue is to specify TEMPLATE template0
in CREATE DATABASE; there shouldn't be anybody connected there.

In retrospect it was probably a misfeature that template1 is both the
default database-to-copy and the default database-to-connect-to, but
this usage is so deeply entrenched that no one really wants to change it.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postg resql.org so that your
message can get through to the mailing list cleanly

Nov 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4483
by: John Mullan | last post by:
Hi I have a problem creating a backup in SQL Server 6.5. Although, the backup produced does restore ok, I want to stop this error message appearing everytime I make a backup. The error message is: " Can't allocate space for object 'sysbackupdetail' in database 'msdb' because the 'default' segment is full. If you ran out of space in Syslogs, dump the transaction log. Otherwise, use ALTER DATABASE or sp_extendsegment to increase the size...
3
1452
by: Erik Thorsen | last post by:
Hello! I am in the process of creating a database listing tours, something similar to what you can find on www.infohub.com. This means that I need to create a database which can be searchable with destination, category, price and so forth. Unfortunately I can not seem to be able to create the relationships, neither can I make my head learn how to do this. I would be extremely happy if anyone could help me solve this problem for me or...
6
4485
by: di | last post by:
Does anyone have any recommendations on Examples or experience on creating a multilevel commission in Access Database. I realize this can be a very complicated set up so would like some advise. Thanks
3
2040
by: Dave | last post by:
I've run across a strange error when creating a simple ADO.Net connection in VB.Net 2003 To replicate an error: Create an Access database (2002) with table named "Student" and fields SID (Autofill), FirstName and LastName. Put some dummy data in table. Start a new VB.Net application, create a new connection to your
1
2314
by: ROO | last post by:
Hi Everyone, I need some help Creating Database Connection at runtime and writing Connection String to App.Config, I have 3mxtboxes on a form txtUsername = SQL admin User txtPassword = Sql admin password txtServername = Sql Server name I want to be able to write the input supplied by users to the App.config file..
3
2197
by: ATXTech | last post by:
I am using a Access created database with a program I wrote in C# to create and track helpdesk tickets. I store basic stuff like customer name, number, issue, tech assigned, etc. with in the database. **PROBLEM** The database worked fine in saving and displaying records until it reaced the 26th record. When ever you open the ticket program, it retrieves the data from the database on the server and shows the last entry in the database...
1
1449
by: =?Utf-8?B?TWFya0F1cml0?= | last post by:
Im trying to help a friend who is attempting to deploy an asp.net 2.0 app. She wants to use the membership/role system, and the necessary database and its tables, etc, exist in the sql server 2000 instance (which is on a seperate server). When she brings up the asp.net admin app from within vs.net, she can do the database connection test to her membership/role database and her application's database. However, if she clicks on the...
0
872
by: Mani kansal | last post by:
hi, Actually i m gettin the problem in creating the database.Problem comin in my control file.oracle couldn't be able to read it from pfilethough i have given the correct paramter control_files='f:\oracle\databases\control01.ctl' cn smone pls help me on this
0
9687
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10482
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10251
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10225
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10027
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9072
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
4139
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.