If you receive a data-set as a file or from querying without an explicit primary key and you are not permitted to add one to the actual or visible (to you) schema, below are some suggestions and options.
First we need to distinguish between "persistent" keys and "temporary" keys. As a working term, "persistent keys" here will mean that the same record will have the same key if we re-query that some record at a different time.
Temporary Keys
- ODBC/JDBC will generally provide the rows in a sequential order. The obtaining software can use a counter to create a sequence number.
- Some RDBMS vendors have functions that will return arbitrary or internal row numbers. The Oracle RowNum?() function will return a unique row number per query. There is also another function that returns an internal row ID code and is generally a supplied as a string, but this is only per table, not per query. And the values can be reused, such as upon deletion and insertion. Thus, they are only unique for a given snapshot of a table.
- More to come...