Hi,
which db you are using? SqlLite, MySql or something else? There is only way to check with table description if some field already exists or not... I guess you have xxx tables in database and want to have unique field in one of this tables? Or?
You can create the table with a field with auto_increment + primary key.
The database will increase the field by 1 each time you create a record, you don't need to do anything
B4X:
CREATE TABLE YOURTABLE
(
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(90),
birthday VARCHAR(16)
)
If you want to ensure two fields are unique try this:
B4X:
CREATE TABLE YOURTABLE
(
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(90),
birthday VARCHAR(16),
CONSTRAINT UC_Person UNIQUE (name,birthday)
)
But be aware, if your try to insert a record that collides there will be errors.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.