Home >Database >Mysql Tutorial >How Can I Select All Columns Plus ROWNUM in an Oracle SELECT Statement?

How Can I Select All Columns Plus ROWNUM in an Oracle SELECT Statement?

Linda Hamilton
Linda HamiltonOriginal
2024-12-26 13:10:09277browse

How Can I Select All Columns Plus ROWNUM in an Oracle SELECT Statement?

Selecting Additional Columns with "ROWNUM"

In Oracle, the "SELECT" statement allows you to retrieve specific columns from a table. It's also possible to include additional columns, such as "ROWNUM," which returns the row number in the result set.

Problem

Instead of manually specifying each column name, you want to select all the columns in a table plus the "ROWNUM" column. Attempts to use "*" without explicitly qualifying it return only the table columns, omitting "ROWNUM."

Solution

To include all columns along with "ROWNUM," qualify the "*" with the table name:

select rownum, table.* from table

This query will retrieve the "ROWNUM" column as well as all the columns in the specified table.

The above is the detailed content of How Can I Select All Columns Plus ROWNUM in an Oracle SELECT Statement?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn