“Get Wisdom; develop good judgment. Don’t forget my words or turn away from them.
Don’t turn your back on wisdom, for she will protect you. Love her, and she will guard you.
Getting wisdom is the wisest thing you can do!
And whatever else you do, develop good judgment. If you prize wisdom, she will make you great.
Embrace her, and she will honor you.”
Main Source: (1) Practical SQL: A Beginner’s Guide To StoryTelling With Data by Anthony Debarros (2nd Edition). [Amazon Link].
(2) The PostgreSQL Documentation.
However, this post HAS variations to the above mentioned text.
Post #4 adds information about the datatypes utilized within the previous post, which created the table “administration” inside the database “testingthisout”.
What does this code mean?
What are datatypes in PostgreSQL?
In the previous post, we utilized this code, to create the “administration” table for the “testingthisout” database.
Here is a list of the built-in general-purpose datatypes that PostgreSQL utilizes in version 17.2.
*** Additionally, the user can utilize user-defined data types. These will not be discussed in this post. ***
(1) bigserial [or] serial8:
bigserial & serial8 are “autoincrementing eight-byte integers.”
There are additional autoincrementing integers of other sizes: smallserial, serial 2, serial, serial4.
(2) varchar(#) [or] character varying (#):
this is a variable-length character string.
For example: varchar(5) allows you to create a character string up to 5 characters long.
*** If you use text as a datatype, you can enter a character string of unlimited length.
The date datatype is part of the Date/Time datatypes.
Here is a chart that provides an overview of these types.
This table showcases some inputs that are possible for the date type.
Our code in post #5, uses the ISO 8601 recommended format.
Here is an example of ISO 8601 format for date:
('Amber', 'W', 'Michiganington', 'St. Petersburg HS', '2011-04-24', 80001);
“When I was a boy at my father’s knee, the pride & joy of my mother, He would sit me down & drill me:
‘Take this to heart. Do what I tell you–live! Sell everything and buy Wisdom! Forage for Understanding! Don’t forget one word! Don’t deviate an inch!
Never walk away from Wisdom–she guards your life; love her–she keeps her eye on you.
Above all & before all, do this: Get Wisdom! Write this at the top of your list: Get Understanding!
Throw your arms around her–believe me, you won’t regret it; never let her go–she’ll make your life glorious.
She’ll gardland your life with grace, she’ll festoon your days with beauty.’ ”
The numeric datatype has an alias called decimal.
Numeric / decimal is used to “store numbers with a very large number of digits,” where exactness & precision are required.
Here is a chart of the various Numeric types.
The numeric datatype has a selectable precision numeric(p, s) // decimal(p, s).
With the p = precision, and the s = scale.
The precision (p) must be positive. Whereas, the scale (s) can be either negative or positive.
Precision is defined as “the total count of significant digits in the whole number, that is, the number of digits to both sides of the decimal point.” The maximum precision that can be declared is 1000.
Scale is defined as “the count of decimal digits in the fractional part, to the right of the decimal point.”
PostgreSQL allows the scale to be declared from -1000 to 1000. However, the SQL standard is from “range 0 to precision. Using scales outside that range may not be portable to other database systems.”
Our next post, Post #5, demonstrates how to add rows of information to our “administration” table.
“Get wisdom! Get understanding!
Do not forget, nor turn away from the words of my mouth.
Do not forsake her, and she will preserve you; Love her, and she will keep you.
Wisdom is the principal thing; Therefore get wisdom.
And in all your getting, get understanding.
Exalt her, and she will promote you;
She will bring you honor, when you embrace her.”
Leave a Reply