Created
May 26, 2017 19:55
-
-
Save adrianvalenz/66f8da0a722d2d2e514822aee961742b to your computer and use it in GitHub Desktop.
postgresql datatypes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You might also find it useful to know generally what these data types are used for: | |
:string - is for small data types such as a title. (Should you choose string or text?) | |
:text - is for longer pieces of textual data, such as a paragraph of information | |
:binary - is for storing data such as images, audio, or movies. | |
:boolean - is for storing true or false values. | |
:date - store only the date | |
:datetime - store the date and time into a column. | |
:time - is for time only | |
:timestamp - for storing date and time into a column.(What's the difference between datetime and timestamp?) | |
:decimal - is for decimals (example of how to use decimals). | |
:float - is for decimals. (What's the difference between decimal and float?) | |
:integer - is for whole numbers. | |
:primary_key - unique key that can uniquely identify each row in a table | |
There's also references used to create associations. But, I'm not sure this is an actual data type. | |
New Rails 4 datatypes available in PostgreSQL: | |
:hstore - storing key/value pairs within a single value (learn more about this new data type) | |
:array - an arrangement of numbers or strings in a particular row (learn more about it and see examples) | |
:cidr_address - used for IPv4 or IPv6 host addresses | |
:inet_address - used for IPv4 or IPv6 host addresses, same as cidr_address but it also accepts values with nonzero bits to the right of the netmask | |
:mac_address - used for MAC host addresses | |
Learn more about the address datatypes here and here. | |
Also, here's the official guide on migrations: http://edgeguides.rubyonrails.org/migrations.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment