0
0
SQLquery~10 mins

Tables, rows, and columns concept in SQL - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Tables, rows, and columns concept
Start: Create Table
Define Columns
Insert Rows
Table with Rows and Columns
Query Table to See Data
Retrieve Rows and Columns
This flow shows how a table is created with columns, rows are added, and then data is retrieved by querying the table.
Execution Sample
SQL
CREATE TABLE Students (
  ID INT,
  Name VARCHAR(50),
  Age INT
);

INSERT INTO Students VALUES (1, 'Alice', 20);
INSERT INTO Students VALUES (2, 'Bob', 22);

SELECT * FROM Students;
This code creates a table named Students with three columns, inserts two rows, and then selects all data from the table.
Execution Table
StepActionTable StateOutput
1Create table Students with columns ID, Name, AgeTable created with columns: ID, Name, Age; no rows yetNo output
2Insert row (1, 'Alice', 20)Table has 1 row: (1, 'Alice', 20)No output
3Insert row (2, 'Bob', 22)Table has 2 rows: (1, 'Alice', 20), (2, 'Bob', 22)No output
4Select all rows from StudentsTable unchangedRows returned: ID | Name | Age 1 | Alice | 20 2 | Bob | 22
5End of operationsFinal table state with 2 rowsExecution complete
💡 All rows inserted and selected; no more operations
Variable Tracker
VariableStartAfter Step 2After Step 3Final
Table Rows0 rows1 row: (1, 'Alice', 20)2 rows: (1, 'Alice', 20), (2, 'Bob', 22)2 rows: (1, 'Alice', 20), (2, 'Bob', 22)
Key Moments - 3 Insights
Why does the table have columns before any rows are inserted?
Because the table structure is defined first with columns (Step 1 in execution_table). Rows can only be added after columns exist.
What happens if you select from the table before inserting rows?
The query returns zero rows because the table is empty (no data inserted yet), as shown before Step 2.
Are the rows ordered in the table?
Rows are stored in the order inserted here (Step 2 and 3), but SQL does not guarantee order unless ORDER BY is used.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, how many rows does the table have after Step 3?
A2 rows
B1 row
C3 rows
D0 rows
💡 Hint
Check the 'Table State' column at Step 3 in the execution_table.
At which step does the SELECT query return data?
AStep 2
BStep 4
CStep 1
DStep 5
💡 Hint
Look for the 'Output' column showing rows returned in the execution_table.
If we insert a third row after Step 3, how would the 'Table Rows' variable change in variable_tracker?
AIt stays at 2 rows
BIt resets to 0 rows
CIt changes to 3 rows after the next step
DIt becomes undefined
💡 Hint
Variable_tracker shows rows increasing after each insert step.
Concept Snapshot
Tables store data in rows and columns.
Columns define the data types and names.
Rows hold actual data entries.
Create table first, then insert rows.
Query to retrieve rows and columns.
Order of rows is not guaranteed without ORDER BY.
Full Transcript
This lesson shows how a database table is created with columns, how rows are added, and how data is retrieved by querying the table. First, the table structure is defined with columns like ID, Name, and Age. Then, rows of data are inserted one by one. Finally, a SELECT query retrieves all rows and columns from the table. The execution table traces each step, showing the table's state and output. Variables track how many rows exist after each insertion. Key moments clarify common confusions such as why columns exist before rows and how row order works. The visual quiz tests understanding of row counts and query results. The concept snapshot summarizes the basics of tables, rows, and columns in SQL.