SQL

CSV Header to CREATE TABLE

Generates a CREATE TABLE skeleton from a CSV header row, with cleaned identifier names.

Loading the tool…

Processing happens locally in your browser. What you paste or load is processed by this page and is not uploaded to a server. Nothing is stored unless you use a control that says it stores something, and you can clear anything this site has kept from the privacy page.

How to use this tool

  1. Paste the first line of your CSV, the header row.
  2. Set the table name, the dialect and the column type you want to start from.
  3. Select Generate DDL, then narrow the types before you use it.

What csv header to create table does

Loading a CSV into a database starts with a table to load it into. This takes the header row, converts each name into a safe lower-case identifier, and writes a CREATE TABLE statement quoted for the dialect you choose. Spaces, punctuation and leading digits are dealt with, so "Order Total (AUD)" becomes order_total_aud.

Every column comes out as text on purpose. Guessing a type from a header name is how a phone number becomes an integer and loses its leading zero, and guessing from the first few rows is how a column that is numeric for a thousand rows meets its first "N/A". Load as text if you like, then narrow the types deliberately once you have seen the data.

Frequently asked questions

Because guessing is worse than asking. A header cannot tell you a type, and the first few rows are routinely misleading — a numeric-looking column meets its first "N/A", a phone number loses its leading zero. Loading as text and narrowing deliberately is safer.

Runs of non-alphanumeric characters become a single underscore, leading and trailing underscores are dropped, and the name is lower-cased. So "Order Total (AUD)" becomes order_total_aud.

Yes. A header row says nothing about uniqueness, relationships or required fields, so the generated statement is a starting skeleton rather than a finished table definition.