Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Displaying RowID in Select * (all) Statement

I am trying to display the RowID alongside all columns from a Select * statement.

I am using Oracle with Toad to run the SQL statement.

I have two tables that I need to compare, but I do not have any unique identifiers to use when sorting the two tables for comparison. So I thought that using the RowID to sort the two tables in order to compare them could help.

Is there a way to add RowID to a Select * statement? I cannot add all the columns names as there are over 50 of them. I will be doing this to multiple sets of tables where the number and name of columns will vary.

Any help or ideas around this would be greatly appreciated.

Thanks in advance,

Marwan

like image 381
Marwan مروان Avatar asked Mar 01 '12 18:03

Marwan مروان


People also ask

How do I see Rowid in SQL?

ROWIDTOCHAR can be used to display a rowid. select ROWIDTOCHAR(rowid) from <table name>; – S.P.

Can we use Rowid in WHERE clause?

You can use a ROWID value to refer to a row in a table in the WHERE clauses of a query. These values have several valuable uses: They are the fastest way to access a single row. They are a built-in, unique identifier for every row in a table.

What is Rowid in SQL with example?

A row ID is a value that uniquely identifies a row in a table. A column or a host variable can have a row ID data type. A ROWID column enables queries to be written that navigate directly to a row in the table because the column implicitly contains the location of the row. Each value in a ROWID column must be unique.


1 Answers

You can do something like

SELECT rowid, a.*
  FROM table_name a

But I'm not sure that is actually going to help you. Sorting the data on ROWID is not going to be particularly useful since that is just a physical location on disk. It's just as arbitrary as presenting the data unsorted.

like image 80
Justin Cave Avatar answered Oct 24 '22 07:10

Justin Cave