Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

527
Views
PostgreSQL: ¿cuál es la diferencia entre 0 y (0)::smallint por defecto?

Estoy jugando con los tipos de columnas y los valores predeterminados, y encontré dos columnas, ambas smallint pero con diferentes valores predeterminados:

  1. tiene 0
  2. tiene (0)::smallint

Cuando cambio 2 al valor que tiene 1, ambos son iguales y nada parece haber cambiado. Por supuesto, busqué en Google para encontrar la respuesta a mi pregunta y descubrí que :: se usa para la conversión de tipos. Pero me pregunto, si es un valor predeterminado, ¿por qué necesitaría una conversión de tipos?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

No hay diferencia, y el yeso no es necesario.

 # create table somesmallints (a smallint default 0, b smallint default 0::smallint, c smallint default (0)::smallint); CREATE TABLE # \d+ somesmallints; Table "public.somesmallints" Column | Type | Collation | Nullable | Default | Storage | Stats target | Description --------+----------+-----------+----------+---------------+---------+--------------+------------- a | smallint | | | 0 | plain | | b | smallint | | | (0)::smallint | plain | | c | smallint | | | (0)::smallint | plain | | # select 0 = 0::smallint; ?column? ---------- t (1 row)
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!