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
?
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.
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.
Go ahead and make use of VARCHAR(30).
here is the documentation
http://www.postgresql.org/docs/8.4/static/datatype.html
you can also use vachar(n)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With