postgresqlHow do I use PostgreSQL float type?
PostgreSQL float type is a data type used to store real numbers with precision up to 8 bytes. It is a variable precision type, which means that the actual number of bytes allocated to store the number depends on its value.
Example code
CREATE TABLE float_example (
id serial PRIMARY KEY,
float_number float
);
INSERT INTO float_example (float_number)
VALUES (3.1415);
SELECT * FROM float_example;
Output example
id | float_number
----+--------------
1 | 3.1415
(1 row)
In the example code above:
CREATE TABLE float_examplecreates a table calledfloat_examplewith anidcolumn of typeserialas primary key and afloat_numbercolumn of typefloat.INSERT INTO float_exampleinserts a row into the table with a value of3.1415for thefloat_numbercolumn.SELECT * FROM float_exampleretrieves all the records from the table.
Helpful links
More of Postgresql
- How do I use PostgreSQL's XMLTABLE to parse XML data?
- How can I retrieve data from PostgreSQL for yesterday's date?
- How do I use PostgreSQL's XMIN and XMAX features?
- How do I use the PostgreSQL quote_ident function?
- How do I round a number in PostgreSQL?
- How do I use the PostgreSQL NVL function?
- How do I use PostgreSQL with Qt?
- How can I use PostgreSQL XOR to compare two values?
- How do I use the WITH statement in PostgreSQL?
- How can I decide between PostgreSQL and MySQL for my software development project?
See more codes...