Re: [SQL] Rename database?
Uh, we have ALTER DATABASE, but it doesn't rename. If no one is connected, you can connect to template1 and modify pg_database table to rename. That _should_ work. --- Wei Weng wrote: > Can I use a SQL statement to rename database? > > e.g Rename Database Bank to Database Bank_backup > > Thanks! > > Wei -- Bruce Momjian| http://candle.pha.pa.us [EMAIL PROTECTED] | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup.| Newtown Square, Pennsylvania 19073 ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly
[SQL] sequence question
Hey there, Does anybody have a nice way to identify what table.column is using a particular sequence on a database-wide basis? --Thanks. ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]
Re: [SQL] CAST from VARCHAR to INT
Sweet, worked the charm, thanks! P.S. Anyone know why it takes several hours[1] for my posts to come through the list? [1] Posted a message at ~9am friday, it got back to me ~4pm! - Original Message - From: "Bhuvan A" <[EMAIL PROTECTED]> To: "Luke Pascoe" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Friday, January 24, 2003 6:58 PM Subject: Re: [SQL] CAST from VARCHAR to INT > > > (Postgres 7.2.1) > > > > I screwed up when I was designing a table a while back and made a column a > > VARCHAR that referenced (and should have been) an INT. > > > > Now I'm trying to correct my mistake, I've created a new table and I'm > > trying to INSERT INTO...SELECT the data into it, but it's complaining that > > it can't stick a VARCHAR into an INT. All the values in the column are valid > > integers (the foreign key sees to that) but even a CAST won't do it. > > > > How can I force it to copy/change the values? > > > > varchar cannot be casted to integer directly. Rather we can do it this > way: > > => select your_varchar_field::text::int from your_table; > > regards, > bhuvaneswaran > > > > ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]
Re: [SQL] sequence question
select relname as table, attname as column from pg_class c join pg_attribute a on c.oid=a.attrelid join pg_attrdef d on a.attnum=d.adnum where adsrc='nextval(\'"SEQUENCE_NAME_SEQ"\'::text)'\ AND d.adrelid=c.oid; There may be a more efficient query, but I wasn't too worried about figuring it out... HTH Rod > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED]]On Behalf Of Marie G. Tuite > Sent: Monday, January 27, 2003 3:06 PM > To: Pgsql-Sql@Postgresql. Org > Subject: [SQL] sequence question > > > Hey there, > > Does anybody have a nice way to identify what table.column is using a > particular sequence on a database-wide basis? > > --Thanks. > > > > ---(end of broadcast)--- > TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED] > > ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])
Re: [SQL] Function for adding Money type
Oliver Elphick wrote: > On Sun, 2003-01-26 at 13:53, D'Arcy J.M. Cain wrote: > > > This year, my team is planning on improving the MONEY type. Of course, we can > > always make it a user defined type if PostgreSQL doesn't want it. We will at > > least put it into contrib. However, if people think that it is useful and > > want to leave it in the main tree that's good too. What we want to do is a) > > switch to a 64 bit integer from a 32 bit integer in order to hold amounts of > > any reasonabe size and b) allow it to be cast to and from more types. > > Perhaps we can also add the ability to specify the number of decimal places > > on output but I am not sure if that would affect the primary benefit of using > > it, speed. > > A money type needs to specify what currency is held. The current one > changes the currency with the locale, which makes nonsense of existing > data. Agreed. We can default to locale but need a way of overriding that, ideally with atttypmod at the column level. I assume this will be done for 7.4 (you said "this year")? -- Bruce Momjian| http://candle.pha.pa.us [EMAIL PROTECTED] | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup.| Newtown Square, Pennsylvania 19073 ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org