PostgreSQLIntermediate
Common Data Types — text, numeric, date, uuid
সচরাচর ব্যবহার হওয়া PostgreSQL types — কখন কোনটা।
3টি অংশবাংলা ভাষায়
| Type | কখন | উদাহরণ |
|---|---|---|
| text / varchar(n) | text অংশ; varchar-এ length limit | name |
| integer / bigint | সব small/medium number | qty |
| numeric(p, s) | money/যথার্থতা ওয়ালা decimal | price |
| boolean | true/false | in_stock |
| timestamp / timestamptz | moment | created_at |
| date | শুধু দিন | birth_date |
| uuid | globally unique id | order_id |
| jsonb | structure-less data | product_spec |
types দেখতেsql
sql
CREATE TABLE measurements (
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
label text NOT NULL,
amount numeric(10, 2),
taken_at timestamptz DEFAULT now()
);numeric vs float
money-তে কখনও float/double নয় — rounding error। numeric(p,s)-এ decimal exact থাকে।
শেষ প্যারায় নিজে practice করুন — কোড কপি করে নিজের এডিটরে চালিয়ে দেখুন।