Where Opinions Differ on SELECT * for Beginners
SELECT * means "give me every column". It is often the very first query a beginner learns. Some teachers say it is perfectly fine; others say to stop using it as soon as possible. This page sets out the viewpoints side by side. They are composite positions, not quotes from named people.
View 1: it is the perfect first query
The argument: when you are exploring a table you have never seen, SELECT * shows you everything. It removes the need to know column names before you start.
SELECT * FROM books LIMIT 5;
Strength: fast, friendly, ideal for looking around.
View 2: fine for exploring, not for app code
The argument: use SELECT * in a shell or a GUI to look at data, but in your program's code, list the columns you need.
SELECT id, title, author_id FROM books WHERE id = ?;
Reasons given:
- If someone adds a column later, your code still gets exactly what it expects.
- You do not fetch large columns, such as long descriptions or images, that the page does not show.
- The query documents itself: a reader sees which data is used.
View 3: avoid it from the start
The argument: learning to name columns from day one builds a good habit and makes you look at the table structure properly.
Criticism of this view: it adds friction at the stage when beginners most need quick wins.
View 4: it depends on the tool
The argument: ORMs often select all columns by default, so the debate moves into ORM settings. What matters is knowing what is fetched and choosing deliberately when it matters.
A closer look at the risks in app code
| Risk | What can happen |
|---|---|
| Column order changes | Code that reads columns by position gets the wrong values |
| New large column added | Every query suddenly transfers more data |
| Sensitive column added | Data such as a password hash may be sent where it should not be |
| Joins with same-named columns | Two id columns in one result can confuse your code |
Side by side
| View | When exploring | In app code |
|---|---|---|
| 1. Perfect first query | Use it | Not discussed |
| 2. Explore only | Use it | List columns |
| 3. Avoid from the start | List columns | List columns |
| 4. Depends on the tool | Use it | Check what the ORM fetches |
Where most people end up
The most common position among teachers is View 2. Use SELECT * freely while you explore, add LIMIT so you do not print thousands of rows, and name the columns once a query goes into your program.
A small exercise
Take a query you wrote with SELECT * in a project. Rewrite it listing only the columns your page uses. Then add a new column to the table and see which version still behaves exactly the same. That one experiment usually settles the debate for learners.
For more on writing SELECT queries step by step, see our five short beginner modules on SELECT.
A free learning page for beginners. Practise on a test database, never on real customer data, and check the official documentation for your database version.
Illustrative outline only: no live session, recording, registration or certificate is offered on this site. Any speakers, panels or schedules mentioned are hypothetical.