Beginner LevelPostgreSQL
What special built-in data types exist in PostgreSQL (JSONB, UUID, ARRAY, INET, TEXT)?
❓ Interview Prompt: Explain rich PostgreSQL native data types: JSONB (binary JSON), UUID, multidimensional ARRAYs, INET (IP addresses), and TEXT.
PostgreSQL extends standard SQL data types with rich native types:
•
JSONB: Binary format for JSON data supporting indexing and fast key lookups.
•
UUID: 128-bit universally unique identifiers ('gen_random_uuid()').
•
ARRAY: Native multidimensional arrays ('TEXT[]', 'INTEGER[]').
•
INET / CIDR: Validated IPv4 and IPv6 network addresses.
Code Implementation Example
sql
CREATE TABLE user_profiles (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
name TEXT NOT NULL,
tags TEXT[] DEFAULT '{}',
attributes JSONB DEFAULT '{}'::jsonb,
last_ip INET
);💡Creating a table leveraging UUID, ARRAY, JSONB, and INET data types.
🎯 Interview Key Takeaway
Use JSONB for flexible schema data, UUID for unique identifiers, and native ARRAY types for simple multi-value fields.
#Data Types#JSONB#UUID#ARRAY#INET#Beginner
Back to all PostgreSQL Questions→