Basic Table & Column Types in Drizzle ORM
From the Drizzle ORM cheat sheet · Schema Definition · verified Jul 2026
Basic Table & Column Types
Define a table with common column types and constraints.
typescript
import { pgTable, serial, text, integer,
boolean, timestamp, varchar } from 'drizzle-orm/pg-core';
export const users = pgTable('users', {
id: serial('id').primaryKey(),
name: text('name').notNull(),
email: varchar('email', { length: 255 }).unique().notNull(),
age: integer('age'),
isActive: boolean('is_active').default(true).notNull(),
createdAt: timestamp('created_at').defaultNow().notNull(),
});💡 Use $type<T>() to add TS typing to json cols
⚡ $onUpdate is a JS callback, not a DB trigger
📌 Column name string maps to actual DB column name
🟢 Use .notNull() to prevent null — safer types
schemacolumnstypestable