← Back to PostgreSQL Course | Chapter 1: Introduction | Lesson 7 of 7

Data Types का Overview

PostgreSQL कई column types offer करता है, और सही वाला चुनना space बचाता है और mistakes रोकता है।

In this page:

  1. Data Types Overview
Syntax
sql
column_name integer
column_name numeric(precision, scale)
column_name text
column_name boolean
column_name timestamp

Data Types Overview

Common types हैं integer types (smallint, integer, bigint), numeric(p,s), real और double precision, text और varchar(n), boolean, date, time, timestamp और timestamptz, uuid, json और jsonb, arrays, और bytea।

PostgreSQL enums, ranges, और custom types भी support करता है। जो fit हो सबसे narrow type चुनें और money के लिए numeric इस्तेमाल करें।

Note: time के moments के लिए timestamptz और currency के लिए numeric prefer करें।

उदाहरण: Data types overview

bash
shop=# CREATE TABLE sample (
shop(#   id        bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
shop(#   qty       integer,
shop(#   price     numeric(10,2),
shop(#   title     text,
shop(#   active    boolean,
shop(#   created   timestamptz DEFAULT now(),
shop(#   attrs     jsonb,
shop(#   tags      text[]
shop(# );
CREATE TABLE

⚠️ Run this in your own terminal or Node.js environment.

Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. money के लिए float इस्तेमाल करना
  2. dates को text की तरह store करना
  3. बिना किसी वजह के हर जगह varchar(255) इस्तेमाल करना
चैप्टर सारांश
  • Integers के लिए: smallint, integer, bigint
  • Text: text और varchar(n)
  • Time के लिए: date, timestamp, timestamptz
  • साथ में boolean, numeric, uuid, jsonb, arrays
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.