Thread: how to create a database

how to create a database

From
ranjitha ullasa
Date:
hi ,
i am encoutering the following error while trying to create a database ,
kindly provide the solution to this as soon as possible,
regards
ranjitha

bash-2.05$ createdb sat_demo1
/Program Files/Mercury Interactive/LoadRunner/bin/sed.exe: Unexpected End-of-file
psql: connectDBStart() -- connect() failed: No such file or directory
Is the postmaster running locally
and accepting connections on Unix socket '/tmp/.s.PGSQL.5432'?
createdb: database creation failed



Nokia 5510 looks weird sounds great.
Discover and win it! The competition ends 16 th of December 2001.

Re: how to create a database

From
William WAISSE
Date:
Le Tuesday 04 December 2001 01:09, ranjitha ullasa a écrit :
> i am encoutering the following error while trying to create a database ,
> kindly provide the solution to this as soon as possible,

> bash-2.05$ createdb sat_demo1
> /Program Files/Mercury Interactive/LoadRunner/bin/sed.exe: Unexpected

 hum, so you are not using a _normal_ linux ?
 This is a pseudo_linux running under Windows ?
 Not sure Everything can work on this kind of _pseudo_linux_

> End-of-file psql: connectDBStart() -- connect() failed: No such file or
> directory Is the postmaster running locally
> and accepting connections on Unix socket '/tmp/.s.PGSQL.5432'?
> createdb: database creation failed
>

 This means that the postmaster is not running.
 You should launch the postmaster before
 ( with '/etc/init.d/posgresql start' for example ) see below :

----------------

[root@waisse william]# createdb a
psql: connectDBStart() -- connect() failed: No such file or directory
        Is the postmaster running at 'localhost'
        and accepting connections on Unix socket '5432'?
createdb: database creation failed
[root@waisse william]# /etc/init.d/po
portmap     postfix     postgresql
[root@waisse william]# /etc/init.d/pos
postfix     postgresql
[root@waisse william]# /etc/init.d/postgresql start
Checking postgresql installation: looks good!
Starting postgresql service: postmaster [14253]
[root@waisse william]# createdb a
CREATE DATABASE
[root@waisse william]#

-----------

 This works all the time on a _normal_ linux.


--
cordialement,  William WAISSE fpr = 9CCD 7DA2 7050 8805 F471  03D1 DF76 B78C
690B 4E07
  --
Computers are like air conditionners. They work better when you close windows.
  --
Visitez donc mon site perso (version 0.4 du 29/05/2001) :
http://www.neofutur.net
  --
Vous habitez dans l'Essonne et vous aimez les Pingouins ???
visitez donc la GAULE(=LUG91) : http://www.gaule.org
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCS/E/MU d- s: a- C++++ UL+++ P+ L++++ E--- W++ N o-- K- w---
O- M- V- PS+ PE-- Y++ PGP++ t+ 5 X++ R++ tv- b+++ DI- D G e++ h* r++ y+++
------END GEEK CODE BLOCK------

Re: how to create a database

From
Stephan Szabo
Date:
On Tue, 4 Dec 2001, [iso-8859-1] ranjitha ullasa wrote:

> hi ,
> i am encoutering the following error while trying to create a database ,
> kindly provide the solution to this as soon as possible,
> regards
> ranjitha
>
> bash-2.05$ createdb sat_demo1
> /Program Files/Mercury Interactive/LoadRunner/bin/sed.exe: Unexpected End-of-file
> psql: connectDBStart() -- connect() failed: No such file or directory
> Is the postmaster running locally
> and accepting connections on Unix socket '/tmp/.s.PGSQL.5432'?
> createdb: database creation failed


For the first message, Are you running under cygwin or something and is
the sed above actually the correct sed? It may just be having problems
with spaces or something too, but it doesn't hurt to check.

The second does seem to imply that the server isn't actually running, have
you started the postmaster?



What can I use as a [non-aggregate] minimum function

From
"Paul Wehr"
Date:
I need to find the minimum of dates in a number of tables, but "min(date)"
is, of course, an aggregate function.  For example:

select key, min(a.date, b.date, c.date) as first_date
from table_a a, table_b b, table_c c
where a.key=b.key and a.key=c.key

right now I'm using:

case
  when a.date < b.date and a.date < c.date then a.date
  when b.date < c.date then b.date
  else c.date
end

But there must be a better way.  I've even looked into createing a
recursive function using an date[] as an argument (since I don't know how
to specify a function with a variable number of arguments)

Sorry if this is a FAQ but muc.lists.postgres doesn't return anything
useful, and the searchable archive seems to be down.

Thanks,

-paul



Re: What can I use as a [non-aggregate] minimum function

From
Tom Lane
Date:
"=?iso-8859-1?Q?Paul_Wehr?=" <postgresql@industrialsoftworks.com> writes:
> I need to find the minimum of dates in a number of tables, but "min(date)"
> is, of course, an aggregate function.  For example:

> select key, min(a.date, b.date, c.date) as first_date
> from table_a a, table_b b, table_c c
> where a.key=b.key and a.key=c.key

Does that really express the computation you want, ie produce a result
only for key values that occur in all three tables?

I was going to suggest

select key, min(date) as first_date from
(select key, date from table_a
 union all
 select key, date from table_b
 union all
 select key, date from table_c) subsel
group by key;

but it occurs to me that this produces different results, ie, it will
include key values that only occur in one or two of the tables ...

            regards, tom lane

Re: What can I use as a [non-aggregate] minimum function

From
"Paul Wehr"
Date:
I knew I shouldn't have cut corners.  More specifically, I have tables with
date ranges, for example:

  --table company--
ssn         company    employ_from    employ_to
123456789   whiznet    1999-01-01     2000-06-30

  --table hmo--
ssn         hmo        enroll_from    enroll_to
123456789   goodhealth 1999-01-01     1999-07-31
123456789   careplan   1999-08-01     2000-06-30

  --table ira--
ssn         broker     member_from    member_to
123456789   bigbroker  1999-01-01     1999-12-31
123456789   tinybroker 2000-01-01     2000-06-30

I want to get:

ssn         company        hmo          broker      from        to
123456789   whiznet        goodhealth   bigbroker   1999-01-01  1999-07-31
123456789   whiznet        careplan     bigbroker   1999-08-01  1999-12-31
123456789   whiznet        careplan     tinybroker  2000-01-01  2000-05-30

The idea is to smash all the tables together (by ssn), then keep the
records where the dates from each table share at least one common day, then
pick the max start date, and min end date, but the max and min are the
stickler.

Since you didn't volunteer "just use not_aggregate_max()", I'm assuming
there's no built-in thing, so the follow-up question(s) would be:
  1) can a function be defined with a variable number of arguments
  2) can a function be created that calls itself (i.e. recursive)
  3) can you do it for me? :)

Thanks,

-paul


hmmm... nice name I seem to have set for myself...
> "=?iso-8859-1?Q?Paul_Wehr?=" <postgresql@industrialsoftworks.com>
> writes:
>> I need to find the minimum of dates in a number of tables, but
>> "min(date)"  is, of course, an aggregate function.  For example:
>
>> select key, min(a.date, b.date, c.date) as first_date
>> from table_a a, table_b b, table_c c
>> where a.key=b.key and a.key=c.key
>
> Does that really express the computation you want, ie produce a result
> only for key values that occur in all three tables?
>
> I was going to suggest
>
>select key, min(date) as first_date from
> (select key, date from table_a
>  union all
>  select key, date from table_b
>  union all
>  select key, date from table_c) subsel
> group by key;
>
> but it occurs to me that this produces different results, ie, it will
> include key values that only occur in one or two of the tables ...
>
>             regards, tom lane
>
> ---------------------------(end of
> broadcast)--------------------------- TIP 2: you can get off all lists
> at once with the unregister command
>     (send "unregister YourEmailAddressHere" to
>     majordomo@postgresql.org)



Re: Re: What can I use as a [non-aggregate] minimum function

From
Tom Lane
Date:
"=?iso-8859-1?Q?Paul_Wehr?=" <postgresql@industrialsoftworks.com> writes:
> Since you didn't volunteer "just use not_aggregate_max()", I'm assuming
> there's no built-in thing, so the follow-up question(s) would be:
>   1) can a function be defined with a variable number of arguments

No, although sometimes you can fake it by defining a family of functions
with the same name and different numbers of arguments.

>   2) can a function be created that calls itself (i.e. recursive)

Sure, although I don't see how that helps in this case.

>   3) can you do it for me? :)

Nope, got too many things to do already...

            regards, tom lane

Re: What can I use as a [non-aggregate] minimum function

From
Chris Albertson
Date:
All you need is a "max" function with two arguments.  To find the
max of four numbers you can do this

            max(max(max(a,b),c),d)

It is not even all that ugly.

Tom Lane wrote:
>
> "=?iso-8859-1?Q?Paul_Wehr?=" <postgresql@industrialsoftworks.com> writes:
> > Since you didn't volunteer "just use not_aggregate_max()", I'm assuming
> > there's no built-in thing, so the follow-up question(s) would be:
> >   1) can a function be defined with a variable number of arguments
>
> No, although sometimes you can fake it by defining a family of functions
> with the same name and different numbers of arguments.
>
> >   2) can a function be created that calls itself (i.e. recursive)
>
> Sure, although I don't see how that helps in this case.
>
> >   3) can you do it for me? :)
>
> Nope, got too many things to do already...
>
>                         regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

--

--
   Chris Albertson
   Redondo Beach, California
   home:   310-376-1029   chrisalbertson90278@yahoo.com
   cell:   310-990-7550
   office: 310-336-5189   Christopher.J.Albertson@aero.org

Re: What can I use as a [non-aggregate] minimum function

From
Martijn van Oosterhout
Date:
On Mon, Dec 10, 2001 at 09:07:28PM -0800, Chris Albertson wrote:
>
> All you need is a "max" function with two arguments.  To find the
> max of four numbers you can do this
>
>             max(max(max(a,b),c),d)
>
> It is not even all that ugly.

This function even exists, though it's called int4larger. I know the
function exists but I can never remember the name and have to scan through
the function list each time to find it.

There's also cashlarger, date_larger, float4larger, float8larger,
int2larger, int8larger, interval_larger, numeric_larger, text_larger,
time_larger, timestamp_larger and timetz_larger. (Consistant naming huh?).
The opposites are *smaller.

HTH,
--
Martijn van Oosterhout <kleptog@svana.org>
http://svana.org/kleptog/
> Terrorists can only take my life. Only my government can take my freedom.

best solution for BLOB storage across networks?

From
Terrence Brannon
Date:
I was reading the Momjian section on Large Objects (BLOBS) and
was wondering what I might do if I am on one machine and my
Postgresql database is on another machine and I want to store
BLOBS in my database.


Re: best solution for BLOB storage across networks?

From
Doug McNaught
Date:
Terrence Brannon <metaperl@mac.com> writes:

> I was reading the Momjian section on Large Objects (BLOBS) and was wondering
> what I might do if I am on one machine and my Postgresql database is on
> another machine and I want to store BLOBS in my database.

You can do all BLOB operations over the network.

-Doug
--
Let us cross over the river, and rest under the shade of the trees.
   --T. J. Jackson, 1863