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.

Writing your first SQL queries illustration

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:

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

RiskWhat can happen
Column order changesCode that reads columns by position gets the wrong values
New large column addedEvery query suddenly transfers more data
Sensitive column addedData such as a password hash may be sent where it should not be
Joins with same-named columnsTwo id columns in one result can confuse your code

Side by side

ViewWhen exploringIn app code
1. Perfect first queryUse itNot discussed
2. Explore onlyUse itList columns
3. Avoid from the startList columnsList columns
4. Depends on the toolUse itCheck 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.

Related pages on this site