Re: [GENERAL] Alter definition of a column

2007-02-05 Thread Gurjeet Singh
On 1/22/07, Jim C. Nasby <[EMAIL PROTECTED]> wrote: > kelly=# update pg_attribute set atttypid=25, atttypmod=-1 > kelly-# where attname = 'c1' and attrelid = > kelly-# (select oid from pg_class where relname = 'foo'); > UPDATE 1 Also, you could replace that pg_class sub-select with "'fo

Re: [GENERAL] Alter definition of a column

2007-01-21 Thread Jim C. Nasby
On Sat, Jan 20, 2007 at 11:19:50AM -0600, Kelly Burkhart wrote: > On 1/20/07, Shoaib Mir <[EMAIL PROTECTED]> wrote: > >Should help --> ALTER TABLE tablename ALTER columname TYPE text; > > I was looking for a way to alter a column from varchar(n) to text > without using the alter command and conseq

Re: [GENERAL] Alter definition of a column

2007-01-20 Thread Josh Williams
From: "Kelly Burkhart" <[EMAIL PROTECTED]> > On 1/20/07, Shoaib Mir <[EMAIL PROTECTED]> wrote: > > Should help --> ALTER TABLE tablename ALTER columname TYPE text; > > I was looking for a way to alter a column from varchar(n) to text > without using the alter command and consequently touching ever

Re: [GENERAL] Alter definition of a column

2007-01-20 Thread Shoaib Mir
I haven't used it this way, anyone else who did might be able to comment on it. Why will you not like to use the ALTER table command? I think a text should be use in case you don't know the limit for characters (much faster too in that case I guess) in a column but if you know the limits then you

Re: [GENERAL] Alter definition of a column

2007-01-20 Thread Kelly Burkhart
On 1/20/07, Shoaib Mir <[EMAIL PROTECTED]> wrote: Should help --> ALTER TABLE tablename ALTER columname TYPE text; I was looking for a way to alter a column from varchar(n) to text without using the alter command and consequently touching every single row. Below is sql which seems to work, but

Re: [GENERAL] Alter definition of a column

2007-01-19 Thread Shoaib Mir
Should help --> ALTER TABLE tablename ALTER columname TYPE text; Shoaib Mir EnterpriseDB (www.enterprisedb.com) On 1/20/07, Kelly Burkhart <[EMAIL PROTECTED]> wrote: On 1/19/07, Martijn van Oosterhout wrote: > > ALTER TABLE, to be correct, actually has to check the entire tab

Re: [GENERAL] Alter definition of a column

2007-01-19 Thread Kelly Burkhart
On 1/19/07, Martijn van Oosterhout wrote: ALTER TABLE, to be correct, actually has to check the entire table to make sure it's ok. By doing it directly you're basically telling the DB it's OK. For making a varchar column longer it's safe though, and the easiest way. Is it possible to use a s

Re: [GENERAL] Alter definition of a column

2007-01-19 Thread [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote: > Thanks. Am I correct in assuming that this scanning of the entire > table is done when I use the 'ALTER TABLE' command and not something I > must do after it's done? Yes, ALTAR TABLE ... scans through the entire table when it does the update, it's not something you ne

Re: [GENERAL] Alter definition of a column

2007-01-19 Thread Martijn van Oosterhout
On Thu, Jan 18, 2007 at 06:27:04AM -0800, [EMAIL PROTECTED] wrote: > [EMAIL PROTECTED] wrote: > > Using ALTER TABLE ALTER TYPE VARCHAR() to > > change the size requires scanning the entire table. For large tables, > > this will be much slower than the pg_attribute query. Both will get > > the j

Re: [GENERAL] Alter definition of a column

2007-01-18 Thread af300wsm
[EMAIL PROTECTED] wrote: > Hello, > > The +4 is for the overhead of a varchar field. > > Using ALTER TABLE ALTER TYPE VARCHAR() to > change the size requires scanning the entire table. For large tables, > this will be much slower than the pg_attribute query. Both will get > the job done. > Th

Re: [GENERAL] Alter definition of a column

2007-01-18 Thread [EMAIL PROTECTED]
Hello, The +4 is for the overhead of a varchar field. Using ALTER TABLE ALTER TYPE VARCHAR() to change the size requires scanning the entire table. For large tables, this will be much slower than the pg_attribute query. Both will get the job done. [EMAIL PROTECTED] wrote: > Hello, > > In thi