From icecrew@gmail.com Mon Feb 26 16:54:27 2007 Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 5D5899FB7C3 for ; Mon, 26 Feb 2007 12:54:27 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-new, port 10024) with ESMTP id 21132-04-3 for ; Mon, 26 Feb 2007 12:54:10 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.239]) by postgresql.org (Postfix) with ESMTP id 3F89A9FB793 for ; Mon, 26 Feb 2007 12:54:10 -0400 (AST) Received: by wx-out-0506.google.com with SMTP id i28so1457760wxd for ; Mon, 26 Feb 2007 08:54:09 -0800 (PST) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:from:to:subject:date:message-id:mime-version:content-type:x-mailer:x-mimeole:thread-index; b=lW6iPuT6Ba2cTrNYiKqKgZsb6qEG3GY8FGrd0n8QWJoAd1xKsACe64899DGFL24lJrMjNIy8JbttbWO4PCqh2465NgbuWms5MTdWOHOuaO7Rlt/cKP2cyvTPc3oTomIDWKL5VWsnVIyEFGFhnGni13avVkR90dLZ7+nJgOaUWag= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:from:to:subject:date:message-id:mime-version:content-type:x-mailer:x-mimeole:thread-index; b=Ahz/OgobTbihHG0q4nQRKA/6z86vuStM5cFtag/TEZy+R+COQHnS4WP+al1HTosiL/z3gVywzz2RRm6lY6Ij4e+wyZRexk4L0gihII5vk000kTta4dNPOAzoMla0yuCiH7CAZIlUzP8zvbxTMLEo9A1qKxzLpj1siJ5M0NyIV8M= Received: by 10.90.56.14 with SMTP id e14mr4959918aga.1172508849658; Mon, 26 Feb 2007 08:54:09 -0800 (PST) Received: from mis06 ( [205.214.220.146]) by mx.google.com with ESMTP id j4sm6012954nzd.2007.02.26.08.53.57; Mon, 26 Feb 2007 08:54:09 -0800 (PST) From: "Rommel the iCeMAn" To: Subject: Change Default Database Date: Mon, 26 Feb 2007 12:52:19 -0400 Message-ID: <008401c759c6$81bef2c0$b364a8c0@theport.com> MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_NextPart_000_0085_01C759A4.FAAD52C0" X-Mailer: Microsoft Office Outlook 11 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2962 Thread-Index: AcdZxnVzN5WxP4cOSe24Dq7GN3Z65A== X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200702/265 X-Sequence-Number: 27599 This is a multi-part message in MIME format. ------=_NextPart_000_0085_01C759A4.FAAD52C0 Content-Type: multipart/alternative; boundary="----=_NextPart_001_0086_01C759A4.FAAD52C0" ------=_NextPart_001_0086_01C759A4.FAAD52C0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi list, I wrote a database creation script that begins with commands to drop the existing database (if it exists) and create it from scratch. These commands execute fine, the problem is that all subsequent commands are executed on the default database 'postgres'. What command can I use to set the default database to my newly created database (for the duration of the script)? SQL Server has a 'USE [dbname]' command, is there an equivalent command in PostgreSQL? Thanks in advance, Rommel Edwards Software Developer, Barbados, Caribbean. ------=_NextPart_001_0086_01C759A4.FAAD52C0 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable
Hi=20 list,
 
I wrote a=20 database creation script that begins with commands to drop the = existing database (if it exists) and create it from scratch. These = commands=20 execute fine, the problem is that all subsequent commands are executed = on the=20 default database 'postgres'. What command can I use to set the default = database=20 to my newly created database (for the duration of the script)? SQL = Server=20 has a 'USE [dbname]' command, is there an equivalent command in=20 PostgreSQL?
 
Thanks in=20 advance,
Rommel = Edwards
Software=20 Developer,
Barbados,=20 Caribbean.
 
------=_NextPart_001_0086_01C759A4.FAAD52C0-- ------=_NextPart_000_0085_01C759A4.FAAD52C0 Content-Type: image/jpeg; name="Notebook.jpg" Content-Transfer-Encoding: base64 Content-ID: <188014716@26022007-10BD> /9j/4AAQSkZJRgABAgEASABIAAD/7QSyUGhvdG9zaG9wIDMuMAA4QklNA+kAAAAAAHgAAwAAAEgA SAAAAAADBgJS//f/9wMPAlsDRwUoA/wAAgAAAEgASAAAAAAC2AIoAAEAAABkAAAAAQADAwMAAAAB Jw8AAQABAAAAAAAAAAAAAAAAYAgAGQGQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4 QklNA+0AAAAAABAASAAAAAEAAQBIAAAAAQABOEJJTQPzAAAAAAAIAAAAAAAAAAA4QklNBAoAAAAA AAEAADhCSU0nEAAAAAAACgABAAAAAAAAAAI4QklNA/UAAAAAAEgAL2ZmAAEAbGZmAAYAAAAAAAEA L2ZmAAEAoZmaAAYAAAAAAAEAMgAAAAEAWgAAAAYAAAAAAAEANQAAAAEALQAAAAYAAAAAAAE4QklN A/gAAAAAAHAAAP////////////////////////////8D6AAAAAD///////////////////////// ////A+gAAAAA/////////////////////////////wPoAAAAAP////////////////////////// //8D6AAAOEJJTQQAAAAAAAACAAA4QklNBAIAAAAAAAIAADhCSU0ECAAAAAAAEAAAAAEAAAJAAAAC QAAAAAA4QklNBAkAAAAAAqIAAAABAAAAgAAAAAIAAAGAAAADAAAAAoYAGAAB/9j/4AAQSkZJRgAB AgEASABIAAD//gAnRmlsZSB3cml0dGVuIGJ5IEFkb2JlIFBob3Rvc2hvcKggNC4wAP/uAA5BZG9i ZQBkgAAAAAH/2wCEAAwICAgJCAwJCQwRCwoLERUPDAwPFRgTExUTExgRDAwMDAwMEQwMDAwMDAwM DAwMDAwMDAwMDAwMDAwMDAwMDAwBDQsLDQ4NEA4OEBQODg4UFA4ODg4UEQwMDAwMEREMDAwMDAwR DAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDP/AABEIAAIAgAMBIgACEQEDEQH/3QAEAAj/xAE/ AAABBQEBAQEBAQAAAAAAAAADAAECBAUGBwgJCgsBAAEFAQEBAQ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KfqpJfKqSSn6qSXyqkkp+qkl8qpJKfqpJfKqSSn6qSXyqkkp +qkl8qpJKfqpJfKqSSn6qSXyqkkp+qkl8qpJKfqpJfKqSSn6qSXyqkkp+qkl8qpJKfqpJfKqSSn6 qSXyqkkp+qkl8qpJKfqpJfKqSSn6qSXyqkkp+qkl8qpJKfqpJfKqSSn6qSXyqkkp+qkl8qpJKfqp JfKqSSn6qSXyqkkp+qkl8qpJKfqpJfKqSSn6qSXyqkkp+qkl8qpJKfqpJfKqSSn6qSXyqkkp+qkl 8qpJKfqpJfKqSSn6qSXyqkkp+qkl8qpJKfqpJfKqSSn6qSXyqkkp+qkl8qpJKfqpJfKqSSn6qSXy qkkp+qkl8qpJKfqpJfKqSSn6qSXyqkkp+qkl8qpJKfqpJfKqSSn6qSXyqkkp+qkl8qpJKfqpJfKq SSn6qSXyqkkp+qkl8qpJKfqpJfKqSSn6qSXyqkkp+qkl8qpJKfqpJfKqSSn6qSXyqkkp+qkl8qpJ KfqpJfKqSSn6qSXyqkkp+qkl8qpJKfqpJfKqSSn6qSXyqkkp+qkl8qpJKfqpJfKqSSn6qSXyqkkp +qkl8qpJKfqpJfKqSSn6qSXyqkkp+qkl8qpJKfqpJfKqSSn6qSXyqkkp+qkl8qpJKfqpJfKqSSn6 qSXyqkkp+qkl8qpJKfqpJfKqSSn6qSXyqkkp+qkl8qpJKfqpJfKqSSn/2Q== ------=_NextPart_000_0085_01C759A4.FAAD52C0-- From dev@archonet.com Mon Feb 26 17:04:40 2007 Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 319399FB943 for ; Mon, 26 Feb 2007 13:04:40 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-new, port 10024) with ESMTP id 56972-04 for ; Mon, 26 Feb 2007 13:04:34 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) by postgresql.org (Postfix) with ESMTP id 4A76A9FB4E8 for ; Mon, 26 Feb 2007 13:04:35 -0400 (AST) Received: from server3.office.archonet.com (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id 6359E76A7A; Mon, 26 Feb 2007 16:58:41 +0000 (GMT) Received: from [192.168.1.36] (dell36.office.archonet.com [192.168.1.36]) by server3.office.archonet.com (Postfix) with ESMTP id 6B9AE274090; Mon, 26 Feb 2007 16:58:40 +0000 (GMT) Message-ID: <45E311C0.5090909@archonet.com> Date: Mon, 26 Feb 2007 16:58:40 +0000 From: Richard Huxton User-Agent: IceDove 1.5.0.9 (X11/20061220) MIME-Version: 1.0 To: Rommel the iCeMAn Cc: pgsql-sql@postgresql.org Subject: Re: Change Default Database References: <008401c759c6$81bef2c0$b364a8c0@theport.com> In-Reply-To: <008401c759c6$81bef2c0$b364a8c0@theport.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.216 tagged_above=0 required=5 tests=AWL, BAYES_50, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200702/266 X-Sequence-Number: 27600 Rommel the iCeMAn wrote: > Hi list, > > I wrote a database creation script that begins with commands to drop the > existing database (if it exists) and create it from scratch. These commands > execute fine, the problem is that all subsequent commands are executed on > the default database 'postgres'. What command can I use to set the default > database to my newly created database (for the duration of the script)? SQL > Server has a 'USE [dbname]' command, is there an equivalent command in > PostgreSQL? See "man psql" (or the client applications section of the manuals) for details on the backslash commands. \c will be what you're after. -- Richard Huxton Archonet Ltd From rdeleonp@gmail.com Mon Feb 26 17:09:46 2007 Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 7BC319FB84F for ; Mon, 26 Feb 2007 13:09:46 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-new, port 10024) with ESMTP id 58951-08 for ; Mon, 26 Feb 2007 13:09:27 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from wr-out-0506.google.com (wr-out-0506.google.com [64.233.184.227]) by postgresql.org (Postfix) with ESMTP id 2500F9FB5AE for ; Mon, 26 Feb 2007 13:09:28 -0400 (AST) Received: by wr-out-0506.google.com with SMTP id 71so237444wri for ; Mon, 26 Feb 2007 09:09:27 -0800 (PST) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=jb7QYDEvdS4KCpg8kZBcR0ZmVbC8+UvvvzWnhDY+iuTJkhZgIMymYVXYdiUtv/wJvAozXacq6Ub1JfBwkMrL5AUuGZ4e2LkPE7srHO0yBdvTsVnA20AC7ck1PY8oE/i+htVQWX7WUnZu7ema1bXKu043Oy3ca7n6lC6yYlzHXmE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=smNEFXMntvoa5rH6n+1HhNYoe6vy5IPXcukkqieucRLGeTo9EpkLv4mLW+zWie4rx2F4y1vHNd7GFgvIBH1YpopZrvUmPtv31A7VQ3WTrOkZxhXBHr+sut8Qr3/zgSG8paC7Rerc4/PnvpAvO+Osx75vWj00KeQ+HQz/etr8/ZE= Received: by 10.114.112.1 with SMTP id k1mr743500wac.1172509765000; Mon, 26 Feb 2007 09:09:25 -0800 (PST) Received: by 10.114.169.12 with HTTP; Mon, 26 Feb 2007 09:09:24 -0800 (PST) Message-ID: Date: Mon, 26 Feb 2007 12:09:24 -0500 From: "=?ISO-8859-1?Q?Rodrigo_De_Le=F3n?=" To: pgsql-sql@postgresql.org Subject: Re: Change Default Database In-Reply-To: <008401c759c6$81bef2c0$b364a8c0@theport.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <008401c759c6$81bef2c0$b364a8c0@theport.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200702/267 X-Sequence-Number: 27601 On 2/26/07, Rommel the iCeMAn wrote: > Hi list, > > I wrote a database creation script that begins with commands to drop the > existing database (if it exists) and create it from scratch. These commands > execute fine, the problem is that all subsequent commands are executed on > the default database 'postgres'. What command can I use to set the default > database to my newly created database (for the duration of the script)? SQL > Server has a 'USE [dbname]' command, is there an equivalent command in > PostgreSQL? > > Thanks in advance, > > Rommel Edwards > Software Developer, > Barbados, Caribbean. If using psql: \c dbname then the rest of the commands. From icecrew@gmail.com Mon Feb 26 17:24:38 2007 Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id B05219FB341 for ; Mon, 26 Feb 2007 13:24:38 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-new, port 10024) with ESMTP id 28016-09 for ; Mon, 26 Feb 2007 13:24:27 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from py-out-1112.google.com (py-out-1112.google.com [64.233.166.182]) by postgresql.org (Postfix) with ESMTP id 730429FB31E for ; Mon, 26 Feb 2007 13:24:27 -0400 (AST) Received: by py-out-1112.google.com with SMTP id a73so863127pye for ; Mon, 26 Feb 2007 09:24:26 -0800 (PST) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:from:to:subject:date:message-id:mime-version:content-type:content-transfer-encoding:x-mailer:in-reply-to:x-mimeole:thread-index; b=TMmkJxReX/biz3wxC7eb3yR+wVa9wl4pHBlLPaN8pah05iW90MGtQsx09B7viGlMvojwX1w3Tweqn6x6FOypX2yAXSfsHVVnxPA10uhpkfy4pj5KmkCAcYcWR5JujlNuYyCrFuCLR2WxOjFMA6vDVMBaT2yNXVO2VHAVTR6LoC4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:from:to:subject:date:message-id:mime-version:content-type:content-transfer-encoding:x-mailer:in-reply-to:x-mimeole:thread-index; b=sQMELSIR5MGiB+zdDDxR5z+/RHSq7tPn2hG5SIRgsPg+qHcHYP2v3YbFfBx3K+bWAtCbdM+sgUvIHCNDUiaZnj9uYRxQ3liM2+ML7XW1GZlrfuuZNzhybITzP5jWp3hvkzxU15sYomH6o6s9MkETR5inyEpdx+YA9XEwoafMioU= Received: by 10.35.58.8 with SMTP id l8mr12449206pyk.1172510666727; Mon, 26 Feb 2007 09:24:26 -0800 (PST) Received: from mis06 ( [205.214.220.146]) by mx.google.com with ESMTP id e1sm6065487nzd.2007.02.26.09.24.25; Mon, 26 Feb 2007 09:24:26 -0800 (PST) From: "Rommel the iCeMAn" To: Subject: Re: Change Default Database Date: Mon, 26 Feb 2007 13:22:54 -0400 Message-ID: <008d01c759ca$c131a2f0$b364a8c0@theport.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 11 In-Reply-To: X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2962 Thread-Index: AcdZyWTukV2ITBCUQXWLjfmOUUDD7gAAHx7A X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200702/268 X-Sequence-Number: 27602 Thanks for the swift responses, I tried the \c command but I got the following error: ERROR: syntax error at or near "\" SQL state: 42601 Character: 520 Here's a code snippet ... -- -- TOC entry 1685 (class 1262 OID 16453) -- Name: test_db; Type: DATABASE; Schema: -; Owner: postgres -- DROP DATABASE IF EXISTS test_db; CREATE DATABASE test_db WITH TEMPLATE = template0 ENCODING = 'UTF8'; ALTER DATABASE test_db OWNER TO postgres; \c test_db; -- query tool doesn't like this command :-( Rommel Edwards Software Developer, Barbados, Caribbean. From rdeleonp@gmail.com Mon Feb 26 18:43:10 2007 Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id D4C279FB8DA for ; Mon, 26 Feb 2007 14:43:10 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-new, port 10024) with ESMTP id 45217-07 for ; Mon, 26 Feb 2007 14:43:02 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from wr-out-0506.google.com (wr-out-0506.google.com [64.233.184.229]) by postgresql.org (Postfix) with ESMTP id 56DF89FB2A3 for ; Mon, 26 Feb 2007 14:43:02 -0400 (AST) Received: by wr-out-0506.google.com with SMTP id 71so279193wri for ; Mon, 26 Feb 2007 10:43:01 -0800 (PST) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=dsvFdwiUPrsxqJ/4D2wBP56zRwClqBis2oBj1+ucBiEyBRWGkPyZT/6iOPNZQpp/Au59qJ2sUo6VL0UYze2vMzotjpXmG4nVbLl1nwWd9SzudLCV9C1hftkoEDxMxpYgaXlaRJjBzvrXEgdmKOIjgTwMb8qHA3khnpUk+svpMQY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=lajIOouiozLiNDiqI8ztP1jgxgKeWvx32RP7PmOBXwlAQwH/ditP60V/EbJqqsE9G1r3iMKhg788oGZQaBuOk9DSeotqAj1GLHUZX1oDnwavrE5iUYj6UDbv8sjTMvt1HPpNdQtRcYgItFwKMmXLADjRFK5IMQ4eRDTvCWg5frE= Received: by 10.114.95.1 with SMTP id s1mr1044426wab.1172515380767; Mon, 26 Feb 2007 10:43:00 -0800 (PST) Received: by 10.114.169.12 with HTTP; Mon, 26 Feb 2007 10:43:00 -0800 (PST) Message-ID: Date: Mon, 26 Feb 2007 13:43:00 -0500 From: "=?ISO-8859-1?Q?Rodrigo_De_Le=F3n?=" To: pgsql-sql@postgresql.org Subject: Re: Change Default Database In-Reply-To: <008d01c759ca$c131a2f0$b364a8c0@theport.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <008d01c759ca$c131a2f0$b364a8c0@theport.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200702/270 X-Sequence-Number: 27604 On 2/26/07, Rommel the iCeMAn wrote: > Thanks for the swift responses, > > I tried the \c command but I got the following error: > > ERROR: syntax error at or near "\" > SQL state: 42601 > Character: 520 > > Here's a code snippet ... > > > -- > -- TOC entry 1685 (class 1262 OID 16453) > -- Name: test_db; Type: DATABASE; Schema: -; Owner: postgres > -- > > DROP DATABASE IF EXISTS test_db; > CREATE DATABASE test_db WITH TEMPLATE = template0 ENCODING = 'UTF8'; > > > ALTER DATABASE test_db OWNER TO postgres; > > \c test_db; -- query tool doesn't like this command :-( > > > > Rommel Edwards > Software Developer, > Barbados, Caribbean. \c only works in psql. See: http://www.postgresql.org/docs/8.2/static/app-psql.html From smarlowe@g2switchworks.com Mon Feb 26 19:40:55 2007 Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 959489FB368 for ; Mon, 26 Feb 2007 15:40:55 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-new, port 10024) with ESMTP id 01851-09 for ; Mon, 26 Feb 2007 15:40:42 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from exchange.g2switchworks.com (mail.g2switchworks.com [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id CD7E39FAA6E for ; Mon, 26 Feb 2007 15:40:43 -0400 (AST) Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; Mon, 26 Feb 2007 19:40:42 +0000 Received: from state.g2switchworks.com by mail.g2switchworks.com; 26 Feb 2007 13:40:42 -0600 Subject: Re: Change Default Database From: Scott Marlowe To: Rommel the iCeMAn Cc: pgsql-sql@postgresql.org In-Reply-To: <008401c759c6$81bef2c0$b364a8c0@theport.com> References: <008401c759c6$81bef2c0$b364a8c0@theport.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <1172518842.20651.19.camel@state.g2switchworks.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Mon, 26 Feb 2007 13:40:42 -0600 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200702/271 X-Sequence-Number: 27605 On Mon, 2007-02-26 at 10:52, Rommel the iCeMAn wrote: > Hi list, > > I wrote a database creation script that begins with commands to drop > the existing database (if it exists) and create it from scratch. These > commands execute fine, the problem is that all subsequent commands are > executed on the default database 'postgres'. What command can I use to > set the default database to my newly created database (for the > duration of the script)? SQL Server has a 'USE [dbname]' command, is > there an equivalent command in PostgreSQL? A couple of points: 1: PLEASE don't post html email, especially with an annoying background that makes it harder to read your message. 2: What kind of script is this? sql? bash? PHP? perl? If you post the script, we can probably help you out a bit. From smarlowe@g2switchworks.com Mon Feb 26 21:39:28 2007 Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 3561C9FB2CF for ; Mon, 26 Feb 2007 17:39:28 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-new, port 10024) with ESMTP id 52094-10 for ; Mon, 26 Feb 2007 17:39:25 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from exchange.g2switchworks.com (mail.g2switchworks.com [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id DE3FA9FB1BF for ; Mon, 26 Feb 2007 17:39:24 -0400 (AST) Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; Mon, 26 Feb 2007 21:39:23 +0000 Received: from state.g2switchworks.com by mail.g2switchworks.com; 26 Feb 2007 15:39:23 -0600 Subject: Re: Change Default Database From: Scott Marlowe To: Rommel the iCeMAn , pgsql-sql@postgresql.org In-Reply-To: <00c001c759e8$0b124560$b364a8c0@theport.com> References: <00c001c759e8$0b124560$b364a8c0@theport.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <1172525963.20651.39.camel@state.g2switchworks.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Mon, 26 Feb 2007 15:39:23 -0600 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.018 tagged_above=0 required=5 tests=AWL, BAYES_50, SPF_PASS, UNPARSEABLE_RELAY X-Spam-Level: X-Archive-Number: 200702/272 X-Sequence-Number: 27606 On Mon, 2007-02-26 at 14:52, Rommel the iCeMAn wrote: > Hi again, > > Apologies for the HTML. > > This is an SQL script, it was generated by doing a schema-only database dump > using pgAdminIII (which in turn uses pgdump I believe). I've attached the > entire script. I was attempting to run this script in pgAdminIII because > that's what I used to generate it, but the more I read it seems I should try > the psql command line tool to execute this script. I'm getting the > impression that pgAdmin doesn't recognize the /connect directive. Please CC the list, as more eyes are more likely to have an answer than just mine... Yeah, I always run my scripts from psql, often called from a bash shell script. That way I can substitute server / database names in the shell script depending on what I'm trying to do. \ commands exist within the framework of psql, not outside. If pgAdmin doesn't have an equivalent type of command structure, then it won't work for this. You could always drop the db by hand, create it, connect to it, and THEN run the rest of your script, but I too think it would be easier to just run the script against psql. From icecrew@gmail.com Mon Feb 26 22:04:34 2007 Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 6B8899FB4B6 for ; Mon, 26 Feb 2007 18:04:34 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-new, port 10024) with ESMTP id 23499-03 for ; Mon, 26 Feb 2007 18:04:23 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from nz-out-0506.google.com (nz-out-0506.google.com [64.233.162.230]) by postgresql.org (Postfix) with ESMTP id AD3099FB8E5 for ; Mon, 26 Feb 2007 18:04:26 -0400 (AST) Received: by nz-out-0506.google.com with SMTP id r28so514034nza for ; Mon, 26 Feb 2007 14:04:16 -0800 (PST) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:from:to:subject:date:message-id:mime-version:content-type:content-transfer-encoding:x-mailer:in-reply-to:x-mimeole:thread-index; b=Jf1xU36X7BJFD/gT5wmLR50Kt2JDZ2X1kwPa8LjDkygPqpHv9KF279sU8uDLVH0ipP7cJ2H/x4J5u/UHkTJFpS5ewyIRTCxxgnCkgA7bAfCeUkAM4wpGfnZZkyhQlRmUD6GFQ8itVBRX7AFNjpTy5cBuD46tbUY158kXooAzoQA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:from:to:subject:date:message-id:mime-version:content-type:content-transfer-encoding:x-mailer:in-reply-to:x-mimeole:thread-index; b=puAT0m3Dc/CKbui/YvfxuO5zfZ+A0+p39xrFKnP+E55U7WmGlS5owiFsRIZ17WLfELmfPUPvQ/mtiuVqJY1MFKByU7y5NlWzGyPwAA6/uGBS6mRNGBVXS3tfmECIdv2YxpVoiNE0Byh5p8sHQDAShnQaHUgM4gRG6PhPnBoWixI= Received: by 10.65.176.7 with SMTP id d7mr9146623qbp.1172527452065; Mon, 26 Feb 2007 14:04:12 -0800 (PST) Received: from mis06 ( [205.214.220.146]) by mx.google.com with ESMTP id r9sm6401909nza.2007.02.26.14.04.09; Mon, 26 Feb 2007 14:04:11 -0800 (PST) From: "Rommel the iCeMAn" To: Subject: Re: Change Default Database Date: Mon, 26 Feb 2007 18:02:38 -0400 Message-ID: <00d301c759f1$d61c2e70$b364a8c0@theport.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 11 In-Reply-To: <1172525963.20651.39.camel@state.g2switchworks.com> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2962 Thread-Index: AcdZ7pT8joAFMjAHTCKhtq8e8PdNnQAAiMQg X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200702/273 X-Sequence-Number: 27607 I seem to be blundering a lot today! I thought I was replying to the entire list, didn't realize I replied to one person :-) Nothing was wrong with my script, I assumed that since it was generated by pgAdmin that I could run it inside pgAdmin. It works perfectly when I run it using psql. It is very much like SQL Server's osql command line tool. Thanks to everyone that helped ... So I've learnt three valuable lessons: 1. It's better to execute scripts using the command line tool 'psql'. 2. Make sure I'm replying to the list and not to an individual. 3. Do not post HTML messages!!! :-)) Thanks again everyone. Rommel Edwards Software Developer, Barbados, Caribbean. From smarlowe@g2switchworks.com Mon Feb 26 22:09:11 2007 Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 75F609FA65C for ; Mon, 26 Feb 2007 18:09:11 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-new, port 10024) with ESMTP id 30347-08 for ; Mon, 26 Feb 2007 18:09:08 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from exchange.g2switchworks.com (mail.g2switchworks.com [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id 3B59F9FB466 for ; Mon, 26 Feb 2007 18:09:08 -0400 (AST) Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; Mon, 26 Feb 2007 22:09:07 +0000 Received: from state.g2switchworks.com by mail.g2switchworks.com; 26 Feb 2007 16:09:06 -0600 Subject: Re: Change Default Database From: Scott Marlowe To: Rommel the iCeMAn Cc: pgsql-sql@postgresql.org In-Reply-To: <00d301c759f1$d61c2e70$b364a8c0@theport.com> References: <00d301c759f1$d61c2e70$b364a8c0@theport.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <1172527746.20651.55.camel@state.g2switchworks.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Mon, 26 Feb 2007 16:09:06 -0600 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200702/274 X-Sequence-Number: 27608 On Mon, 2007-02-26 at 16:02, Rommel the iCeMAn wrote: > I seem to be blundering a lot today! I thought I was replying to the entire > list, didn't realize I replied to one person :-) > > Nothing was wrong with my script, I assumed that since it was generated by > pgAdmin that I could run it inside pgAdmin. It works perfectly when I run it > using psql. It is very much like SQL Server's osql command line tool. Thanks > to everyone that helped ... > > So I've learnt three valuable lessons: > > 1. It's better to execute scripts using the command line tool 'psql'. > > 2. Make sure I'm replying to the list and not to an individual. > > 3. Do not post HTML messages!!! :-)) And don't forget number 4. The pgsql mailing lists provide better support than most commercial db companies do. > Thanks again everyone. You're welcome, and considering the weather we're having here in Chicago, I might book a flight to come and visit you down there... :) From icecrew@gmail.com Mon Feb 26 22:15:36 2007 Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 992FF9FB68C for ; Mon, 26 Feb 2007 18:15:36 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 39057-04 for ; Mon, 26 Feb 2007 18:15:28 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from nz-out-0506.google.com (nz-out-0506.google.com [64.233.162.237]) by postgresql.org (Postfix) with ESMTP id 198979FB660 for ; Mon, 26 Feb 2007 18:15:27 -0400 (AST) Received: by nz-out-0506.google.com with SMTP id r28so517279nza for ; Mon, 26 Feb 2007 14:15:27 -0800 (PST) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:from:to:subject:date:message-id:mime-version:content-type:content-transfer-encoding:x-mailer:in-reply-to:x-mimeole:thread-index; b=PO2F4rSQaJjUxjzbhGDV7EULlMF1ZKHguNXARhGgi7tMzNhOrSMEfT0U5/dhr8q7Mw7nIPPsMJqJfMT08gYyiaiNIL2TfXN64MrEMoZglREN/V6dF5Pn31k5e+xjRDW6jZ8RMRWc4ICkWMdf5486e3/H6jBJa9p816BfkGMIUPQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:from:to:subject:date:message-id:mime-version:content-type:content-transfer-encoding:x-mailer:in-reply-to:x-mimeole:thread-index; b=cP0Vmxnqof+5eOdEZ0B+l7bAX2Tpd0M0K1LwH+HTOHbbisowLiQS266cG334wTTMO+RV9x4LwElwgUtDiQ1sh4qnkVMgA8eeHhq33e8QiykbXp82dxXAmn22N4EM+DrzIpzneNo/zSC+CdNFilPcK43EuUH+rlSLuqLofQzZm8c= Received: by 10.65.153.10 with SMTP id f10mr9203733qbo.1172528126909; Mon, 26 Feb 2007 14:15:26 -0800 (PST) Received: from mis06 ( [205.214.220.146]) by mx.google.com with ESMTP id 38sm6384161nzf.2007.02.26.14.15.25; Mon, 26 Feb 2007 14:15:26 -0800 (PST) From: "Rommel the iCeMAn" To: Subject: Re: Change Default Database Date: Mon, 26 Feb 2007 18:13:54 -0400 Message-ID: <00dd01c759f3$686457c0$b364a8c0@theport.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 11 In-Reply-To: <1172527746.20651.55.camel@state.g2switchworks.com> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2962 Thread-Index: AcdZ8rxVXgD6fnX/RLerfiaBoCwgeQAAE5xA X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200702/275 X-Sequence-Number: 27609 Brrrr!!!, I was there late last November, it must be far worse now! I'll be sticking close to the forums from now on :-)