Postgresql – change the size of a varchar column to lower length

I have a question about the ALTER TABLE command on a really large table (almost 30 millions rows). One of its columns is a varchar(255) and I would like to resize it to a varchar(40). Basically, I would like to change my column by running the following command: ALTER TABLE mytable ALTER COLUMN mycolumn TYPE … Read more

Is there a good reason I see VARCHAR(255) used so often (as opposed to another length)?

In multiple courses, books, and jobs, I have seen text fields defined as VARCHAR(255) as kind of the default for “shortish” text. Is there any good reason that a length of 255 is chosen so often, other than being a nice round number? Is it a holdout from some time in the past when there … Read more

Changing the maximum length of a varchar column?

I’m trying to update the length of a varchar column from 255 characters to 500 without losing the contents. I’ve dropped and re-created tables before but I’ve never been exposed to the alter statement which is what I believe I need to use to do this. I found the documentation here: ALTER TABLE (Transfact-SQL) however … Read more

What are the main performance differences between varchar and nvarchar SQL Server data types?

I’m working on a database for a small web app at my school using SQL Server 2005. I see a couple of schools of thought on the issue of varchar vs nvarchar: Use varchar unless you deal with a lot of internationalized data, then use nvarchar. Just use nvarchar for everything. I’m beginning to see … Read more

SQL Server Text type vs. varchar data type [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for … Read more