Exploring Table Structures
Learn how to explore table structure and apply limitations while fetching table records.
Step 1: Start with curiosity
Previously, you asked: Who are the employees?
This query returns a complete list of all employee records.
Now ask a deeper question:
What kind of data does this table contain?
This isn’t about values yet, it’s about structure.
Prompt: Write a SQL query that shows the structure (columns and their data types) of the table employees.
Step 2: Run and observe
AI might return one of these, depending on the SQL flavor:
Run the query. You’ll see something like:
Field | Type | Null | Key | Default |
|
| NO | PRI | — |
|
| YES | — | |
|
| YES | — | |
|
| YES | — | |
|
| YES | — |
Step 3: Interpret together
Let’s unpack what you’re seeing.
Rows: Each record in the dataset (one employee).
Type: What kind of data fits here:
INT→ whole numbersVARCHAR→ textDECIMAL→ numbers with decimals
Schema → the table’s full design: column names, types, constraints.
Ask yourself:
Why might knowing data types matter before writing a query?
What could go wrong if you tried to sum a
VARCHARcolumn?
Step 4: Ask the table questions
Let’s explore one more idea: sometimes it helps to peek at the first few rows to match columns to values.
Prompt: Write a SQL query that shows the first 5 rows from the employees table.
AI should respond with:
Run it. Now connect the structure, values:
id: unique number per employee.department: text labels that repeat.salary: numbers you can aggregate later.
That mental link, column to data type to value, is the foundation of data literacy.
Step 5: Your turn to tweak
Try this small edit yourself: Change the query to show only two columns from the table employees: first_name and salary, but restrict the viewing to only top 3 rows of the table.
Notice how you used what you learned in 1.1 (SELECT columns) and what you now know about the schema to choose meaningful fields.
Quick recap
Concept | What It Means | Example |
Table | A collection of related data (like a spreadsheet) | employees |
Row | One record/observation | One employee |
Column | A single attribute | salary or department |
Schema | Blueprint describing all columns and types | use |
Practice prompts
Use the AI Prompt Widget to ask:
Show me the columns and data types of the employees table.
Show me the first 3 rows of the employees table.
How can I tell if a column is numeric or text?
Then adjust one query manually to limit or expand results.
Reflect before moving on
How do column names and types help you decide what question to ask next?
Which columns seem quantitative (numbers you can measure)?
Which seem categorical (labels you can group)?
You’ve completed Lesson 2. You can now inspect a table’s schema to understand its structure, connect what you see in SQL to what the data means, and choose columns confidently for your next query.