1
Hello, I was doing some activities and I differed from some colleagues. The end result was the same, but I was wondering if it is bad practice to use the following code
CREATE TABLE Estudio (
codEst SERIAL PRIMARY KEY,
nomeEst VARCHAR(25)
);
Instead of what my colleagues used:
CREATE TABLE Estudio (
codEst SERIAL NOT NULL,
nomeEst VARCHAR(25),
CONSTRAINT pk_est PRIMARY KEY(codEst)
);
The result, for me, was the same. I read the documentation but found nothing about it, nor in questions here at Stack.
The two are 'acceptable' and only writing style, or should I get used to using the second, in the sense that this may cause problems in the future?
Thank you!
P.S.: the specifications of this table, were those:
Thank you so much for the answer. I also came across this site, but I was kind of 'like' because it was the only place that mentioned it. Taking advantage, the way to declare the PK, in postgresql, always follows the standard table_field_tipochave. Would it be more appropriate to use a Constraint, as well as my colleagues, and declare as tipochave_tabela_fieldname? I wondered of using this other format, in a larger database would be easier to identify Fks and Pks. What do you think? Thank you once again.
– Aleczk
Trust the manual: https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-SERIAL
– anonimo
@Alecsandercamilo I will leave it to others to give an opinion, I do not have an opinion formed.
– Piovezan