Reputation: 109
I'm migrating my MySQL database to PostgreSQL and have a simple question:
What is the best equivalent of varchar(30)
in PostgreSQL? Is it text
?
Upvotes: 8
Views: 17753
Reputation: 181
The best mapping to varchar(30) in MySQL is varchar(30) in PostgreSQL. varchar is part of the sql standard and can be used as is in postgresql.
TEXT is non standard, since you are in a migration situation it might be best to stick to standard elements.
Upvotes: 8
Reputation: 15058
According to PostgreSQL documentation you can use the following data types:
Of the above the only type that is unlimited is text
. So, if you need unlimited space then use text
. However, if you know how large the field can be I would use varchar(n)
. There is no point in using an unlimited data type for a finite requirement. By doing so, you are just wasting space.
Upvotes: 8
Reputation: 5458
here is the documentation
http://www.postgresql.org/docs/8.4/static/datatype.html
you can also use vachar(n)
Upvotes: 1