select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

FUNCTIONS / NETWORK ADDRESS FUNCTIONS AND OPERATORS

Sets the netmask length for an inet value.

Signatures & examples

set_masklen ( inet, integer ) → inet
Sets the netmask length for an inet value. The address part does not change.
set_masklen(inet '192.168.1.5/24', 16) → 192.168.1.5/16
set_masklen ( cidr, integer ) → cidr
Sets the netmask length for a cidr value. Address bits to the right of the new netmask are set to zero.
set_masklen(cidr '192.168.1.0/24', 16) → 192.168.0.0/16
Version history 1
  1. PG 12 → 13changed

Definition snapshot: 2026-09-14T13:14:25.684213+00:00@99e6866c · English manual source