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
ROWIDTOCHAR can be used to display a rowid. select ROWIDTOCHAR(rowid) from <table name>; – S.P.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With