This is a read-only copy of the MariaDB Knowledgebase generated on 2024-11-15. For the latest, interactive version please visit https://mariadb.com/kb/.

ROWID in *.dbf Files

Is there a way to get the recno() / ROWID as field from the *dbf File?

Answer

Yes indeed. Just use a CONNECT special column, for instance:

create table t1 (
id int(6) not null,
msg char(10),
recno int(4) not null default 0 special=rowid
) engine=connect table_type=DBF file_name='afile.dbf';

insert into t1(id,msg) values(2,'two'),(3,'three'),(5,'five');

select * from t1;

The table will be displayed like this:

idmsgrecno
2two1
3three2
5five3

This is true for all file based CONNECT tables. However, for DBF tables:

Note 1: The current CONNECT version has a bug that causes an error being raised when inserting in a new void table (because special columns are wrongly kept when writing the header) This will be fixed in next versions. Meanwhile, you can insert in a new void table with a table defined without the special column and later add the special column with an ALTER TABLE statement.

Note 2: If instead of a ROWID special column you use a ROWNUM special column, it will give the record number including the "soft" deleted lines.

Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.