Answer the question
In order to leave comments, you need to log in
What data type to choose for ID in PostgreSQL?
I'm working with PostgreSQL 10.5
1. My database contains ID and share name.
As I understand it is better to choose int for ID, not smallint.
Since Int contains up to +32767, and if the base grows, you will have to change the type
2. There is a type for the stock name character varying(n), varchar(n) Do I need to set its length? Or can the field be left blank?
3. How does setting the field length affect the saving of space in the database? For example varchar(10) and varchar(100) will take up different disk space? For example, now all the names of shares are no more than 10 letters, but what will happen if a name of 30 letters appears in the future? Should I change the length of the string? Is it possible to do this when the database is already partially filled?
4. Why set the field -Not null? Suppose my script cannot parse the name of the ticker correctly and does not pass anything to the line, but writes information to the remaining columns. In this case, the line will not be written or will it give an error?
Answer the question
In order to leave comments, you need to log in
As I understand it is better to choose int for ID, not smallint.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question