The SELECT statement allows you to precisely specify which columns to retrieve from a table. This precision is often exactly what is needed for analysis. However, particularly when first encountering a new dataset or table, there are times when you might want to see everything a table contains. Instead of looking up and typing out every single column name, SQL provides a convenient shortcut.
To select all columns from a table, you can use the asterisk (*) character, often referred to as a wildcard, in place of a list of column names.
The syntax is straightforward:
SELECT *
FROM table_name;
Let's consider our Products table again, which might contain columns like product_id, product_name, category, price, and stock_quantity.
If you wanted to view all information for every product currently listed, you would write:
SELECT *
FROM Products;
Executing this query instructs the database management system (DBMS) to return all rows from the Products table and, for each row, to include the data from every column defined in that table's schema. The result would look something like this (showing a few sample rows):
| product_id | product_name | category | price | stock_quantity |
|---|---|---|---|---|
| 101 | Quantum Widget | Electronics | 49.99 | 150 |
| 102 | Flux Capacitor | Gadgets | 19.95 | 88 |
| 103 | Hyper Spanner | Tools | 24.50 | 210 |
| 201 | Turbo Encabulator | Electronics | 99.99 | 45 |
| ... | ... | ... | ... | ... |
The columns appear in the order they were defined when the table was created (though this order isn't always guaranteed or relied upon in strict SQL standards).
SELECT *Using SELECT * is particularly useful in a few scenarios:
SELECT * combined with a LIMIT clause (which you learned about previously) is an excellent way to quickly preview the table's structure and the type of data it holds. For example, SELECT * FROM Products LIMIT 5; shows you all columns for the first 5 rows.* can be quicker than typing each column name.WHERE clause, which we'll cover in the next chapter).While SELECT * is convenient, it's often not recommended for use in production code, automated scripts, or complex analyses. Here’s why:
SELECT product_name, price FROM Products; immediately tells the reader what data is being used. Furthermore, if the underlying table structure changes (e.g., a new column is added, or columns are reordered), SELECT * might return unexpected results or even break application code that expects a specific number or order of columns. Explicitly naming columns makes your query more resilient to such changes.SELECT * can lead to ambiguity if tables share column names. Explicitly selecting table_alias.column_name prevents confusion.Recommendation: Use SELECT * primarily for interactive querying and initial exploration. For queries used in applications, reports, or further analysis steps, get into the habit of explicitly listing the columns you require. This leads to more efficient, readable, and maintainable SQL code.
Was this section helpful?
* wildcard and its implications.* wildcard.SELECT statement in Transact-SQL, often includes performance considerations and usage guidelines.© 2026 ApX Machine LearningEngineered with