0
0
Supabasecloud~10 mins

Creating tables via SQL editor in Supabase - Visual Walkthrough

Choose your learning style9 modes available
Process Flow - Creating tables via SQL editor
Open SQL Editor
Write CREATE TABLE statement
Run the SQL command
Database processes command
Table created in database
Verify table exists
END
This flow shows how you open the SQL editor, write a CREATE TABLE command, run it, and the database creates the table.
Execution Sample
Supabase
CREATE TABLE users (
  id SERIAL PRIMARY KEY,
  name VARCHAR(100),
  email VARCHAR(100) UNIQUE
);
This SQL command creates a 'users' table with id, name, and email columns.
Process Table
StepActionSQL CommandDatabase ResponseResult
1Open SQL editorSQL editor readyReady to write SQL
2Write CREATE TABLECREATE TABLE users (id SERIAL PRIMARY KEY, name VARCHAR(100), email VARCHAR(100) UNIQUE);SQL command enteredCommand ready to run
3Run SQL commandCREATE TABLE users (id SERIAL PRIMARY KEY, name VARCHAR(100), email VARCHAR(100) UNIQUE);Command executed successfullyTable 'users' created
4Verify tableSELECT * FROM users;Empty result setTable exists and is empty
💡 Table 'users' created successfully and verified by empty SELECT query
Status Tracker
VariableStartAfter Step 2After Step 3After Step 4
SQL Editor StateClosedOpen with command typedCommand executedTable verified
Table 'users' ExistsNoNoYesYes
Table 'users' RowsN/AN/A00
Key Moments - 3 Insights
Why does the table not show any rows immediately after creation?
Because the table is just created and no data has been inserted yet, as shown in execution_table step 4 where SELECT returns empty.
What happens if you run the CREATE TABLE command twice without changes?
The database will return an error because the table already exists. This is not shown in the current execution but is important to avoid.
Why do we use SERIAL for the id column?
SERIAL automatically creates a unique number for each new row, acting as a primary key, ensuring each row can be uniquely identified.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the database response after running the CREATE TABLE command?
AEmpty result set
BSQL editor ready
CCommand executed successfully
DCommand entered but not run
💡 Hint
Check the 'Database Response' column at Step 3 in the execution_table
At which step does the table 'users' first exist in the database?
AStep 1
BStep 3
CStep 2
DStep 4
💡 Hint
Look at the 'Result' column in execution_table where the table creation is confirmed
If you add a new column after creation, how would the execution table change?
AA new step with ALTER TABLE command and success response
BThe table would be created twice
CThe SQL editor would close automatically
DThe table would be deleted
💡 Hint
Think about how SQL commands modify tables after creation, not shown but logically following the flow
Concept Snapshot
CREATE TABLE syntax:
CREATE TABLE table_name (
  column_name data_type constraints,
  ...
);

Run this in SQL editor to create a new table.
Use SERIAL for auto-increment IDs.
Verify creation with SELECT query.
Full Transcript
To create a table using the SQL editor, first open the editor. Then write a CREATE TABLE statement defining the table name and columns with their data types and constraints. Run the command. The database processes it and creates the table. You can verify the table exists by running a SELECT query which will show no rows initially since the table is empty. The id column often uses SERIAL to auto-generate unique IDs. Running the CREATE TABLE command twice without changes causes an error because the table already exists.