sqlcmd.net validated sql reference
beginner defining MySQL MariaDB SQL Server PostgreSQL SQLite

Create A Table

Define a new table with column names and data types using `CREATE TABLE`.

Docker-validated Not currently validation-green

Create a users table and insert the first row

The table is created with three columns, a row is inserted, and a SELECT confirms the structure works. In production, add PRIMARY KEY and NOT NULL constraints to enforce data integrity.

Shared across supported engines.
SQL
CREATE TABLE users (id INT, name VARCHAR(50), email VARCHAR(100));

INSERT INTO
  users (id, name, email)
VALUES
  (1, 'Alice', '[email protected]');

SELECT
  id,
  name,
  email
FROM
  users;
Returned rows for the shared example.
idnameemail
1Alice[email protected]

Output is identical across all engines.

Where this command helps.

  • setting up a new table before inserting data
  • defining the column structure and data types for a new entity

What the command is doing.

CREATE TABLE establishes a new table in the current database. Each column definition requires a name and a data type. Common types include INT for integers, VARCHAR(n) for variable-length strings, and DATE for calendar dates. The table is empty until rows are inserted.