473,320 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Changing the size of a varchar field

Using PG 7.3.x, how stupid is this:

UPDATE pg_attribute SET atttypmod=<new size + 4> WHERE ....;

I had to do this on a database, and surprisingly it seems to have
worked just fine. The columns accept a larger value, the existing
values are still intact, and I've seen no other strange errors...

Am I living dangerously, or is this an "okay" thing to do?

eric
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 23 '05 #1
2 1228
Eric Ridge <eb*@tcdi.com> writes:
Using PG 7.3.x, how stupid is this:
UPDATE pg_attribute SET atttypmod=<new size + 4> WHERE ....;


It'll work okay for a varchar column (not char) at least as far as the
table itself is concerned. I think there are some issues for views
referencing the column, possibly also indexes.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 23 '05 #2
On May 6, 2004, at 12:40 PM, Tom Lane wrote:
Eric Ridge <eb*@tcdi.com> writes:
Using PG 7.3.x, how stupid is this:
UPDATE pg_attribute SET atttypmod=<new size + 4> WHERE ....;


It'll work okay for a varchar column (not char) at least as far as the
table itself is concerned. I think there are some issues for views
referencing the column, possibly also indexes.


We haven't discovered any issues. We do in fact have views sitting
infront of the these tables (w/ a bunch of update/insert rules too!)
and indexes. All seems to be well.

Can you speculate on what the issue would be? Perceived data loss (ie,
values that exceed the original size are truncated)? Inability to
update? Index scans not returning rows? Or would it be some kind of
fail-fast ERROR:?

eric
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 23 '05 #3

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

Similar topics

2
by: TZone | last post by:
I was hoping I can get some help regarding subject mater located at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/createdb/cm_8_des_02_92k3.asp MyTable has 23 fields with...
7
by: Rick Caborn | last post by:
Does anyone know of a way to execute sql code from a dynamically built text field? Before beginning, let me state that I know this db architecture is built solely for frustration and I hope to...
5
by: Good Man | last post by:
Hi there I'm adding form fields on the fly with some javascript DOM programming. I basically just clone a hidden <div>, then adjust node properties to make this new <div> have unique values...
1
by: Edwin Quijada | last post by:
Hi!! I got error about a length field varchar. I have a table with a field type varchar(20) but if I try to set to this field more than 20 characters I got error. I did a function to control the...
2
by: Steve Gallagher | last post by:
I create my database and a number of tables from within a .bat file. When I set the FULL_TXT field to 3800 or less, all is well. Above 3800, I get SQL0286N A default table space could not be...
2
by: Jon | last post by:
If I specify a type of parameter as varchar or decimal, etc, is there a time when you are required to specify the size of that param as well. Or is it safe to simply specify name, direction, type...
2
by: John | last post by:
Hi Everyone, I have a question about dynamically changing the length of a varchar(n) field, in case the value I'm trying to insert is too big and will give a "truncated" error, but before the...
4
by: Danny | last post by:
Hi All, I have a varchar(255) column for storing text in english and in hebrew. It was a stupid mistake to set the data type to be varchar, because now I need to store text in german and...
6
by: Neil | last post by:
I had a strange situation with a view in SQL 7, that I could use some input on. I had a very simple view -- select a, b, c from table1 where x=y and z=q. Field a in table1 originally was varchar...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.