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 では 1 つのフィールドに @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.