SQL → TS / Zod / Go
PostgreSQL, MySQL, SQLite의 CREATE TABLE 문을 파싱해 TypeScript 인터페이스, Zod 스키마, Go 구조체, Prisma 모델, Pydantic 클래스를 생성합니다. camelCase와 null 표기 옵션도 지원합니다.
브라우저 안에서만 실행됩니다. 입력한 내용은 어디에도 업로드되지 않습니다.
CREATE TABLE만 읽습니다. ALTER TABLE, 인덱스, INSERT 문은 무시합니다.
export interface User {
id: number;
email: string;
display_name: string | null;
plan: string;
created_at: string;
}
export interface Order {
id: number;
user_id: number;
total: number;
metadata: unknown;
placed_at: string;
}외래 키는 Prisma 밖에서는 일반 컬럼으로 남습니다. Prisma는 관계 필드가 필요합니다.
SQL DDL → 모델 참고
빠른 참조- CREATE TABLE users (…);
- 이 툴이 읽는 유일한 문장입니다. 컬럼 이름, 타입, NOT NULL, DEFAULT, 키 제약이 모두 대상 모델로 번역됩니다.
- serial / bigserial
- PostgreSQL 자동 증가입니다. Prisma에서는 @default(autoincrement())가 되고, 값을 DB가 채우므로 TypeScript에서는 그냥 number입니다.
- timestamptz
- 시간대가 있는 타임스탬프입니다. TypeScript와 Zod에서는 ISO 8601 문자열, Prisma에서는 DateTime, Pydantic에서는 datetime이 됩니다.
- numeric(12, 2)
- 정밀도와 스케일을 가진 정확한 십진수입니다. Prisma·Pydantic은 Decimal, Go는 float64, 나머지는 number입니다. SQL에서 돈은 절대 부동소수로 쓰지 마세요.
- REFERENCES users(id)
- 외래 키입니다. TypeScript와 Go는 일반 컬럼으로 두고, Prisma는 양쪽 모델에 관계 필드가 필요하므로 생성된 Prisma 모델은 평평하게 유지됩니다.
- PRIMARY KEY (a, b)
- 복합 기본 키입니다. Prisma에서는 한 필드에 @id를 붙이는 대신 @@id([a, b])로 씁니다.
자주 묻는 질문
도구 아래에서 답을 확인하세요어떤 SQL 방언을 읽나요?
PostgreSQL, MySQL, SQLite의 CREATE TABLE 문입니다. serial·uuid 키, varchar 길이, numeric 정밀도, 배열, 기본값까지 읽습니다.
nullable 컬럼이 TypeScript에서 유니온인 이유는 무엇인가요?
TypeScript는 string | null이 필요하고 Prisma는 ?로 표시합니다. nullable 옵션으로 null 유니온과 선택 키를 바꿀 수 있습니다.
외래 키 관계도 만들어 주나요?
참조를 알려 주고 컬럼은 남기지만, Prisma 관계는 양쪽 모델에 필드가 필요해 생성된 Prisma 모델은 평평하게 유지됩니다.
SQL 관련 문법 가이드
SQL 가이드 전체Postgres permission denied for sequence: GRANT USAGE and nextval
Sequences carry their own ACL, so table grants never cover nextval. The USAGE grant, default privileges, and why identity columns behave differently.
SQLPostgres RLS 42P17: infinite recursion detected in policy
A policy on members that reads members re-enters itself. One security definer function with a pinned search_path ends the recursion and leaves the rest of the policy intact.
SQLPostgres: could not serialize access due to concurrent update
At REPEATABLE READ and SERIALIZABLE a conflicting write aborts with SQLSTATE 40001. Retry the whole transaction with backoff, then remove the conflict instead of retrying it.
SQLPostgres: cached plan must not change result type
A prepared statement or PL/pgSQL plan outlived a schema change. Disable statement caching, force custom plans, discard plans, and order the deploy so no connection straddles DDL.