I am aware about pros and cons of using a text as primary key in table
(there is discussion).
However I just wonder if I must use varchar(10)
or char(10)
or other
Values will look like 1-115115151 (length may differ)
I am aware about pros and cons of using a text as primary key in table
(there is discussion).
However I just wonder if I must use varchar(10)
or char(10)
or other
Values will look like 1-115115151 (length may differ)
For that string, I would recommend varchar(11).
If the string length can grow EVER, I'd recommend making it 12 or even 15.
Varchar uses space equal to the number of characters in use + 2. Data that can fit in either varchar(11) or varchar(15) will use the same amount space in both.
Strictly speaking you can use either, but agreed with the others here - you'll want to use varchar for variable length items.
Do not use text datatype as a primary key, only integers. It's important for easier programming, and SQL connections.