Lazarus
Programming => Databases => Topic started by: Pe3s on September 25, 2022, 05:21:23 pm
-
Hello forum members, we have a database: id, Name, Surname, Age, City.
we ask 'SELECT Name, Surname, Age, City FROM table'. How can you, for example, delete a record if we do not have access to id?
-
You can delete with a more elaborate WHERE clause like
delete from table where name:='a' and surname:='b' and etc.
But you risk deleting possible duplicates of people with the same name and age in the same city (this could happen).
But why don't you have access to the ID?
You should always include it.
You could hide it from grids but it should be there.
-
Not to have the PK is a design fault.
-
there is an id in the project, but I don't want to see it in the table
-
Not to have the PK is a design fault.
And a big one.
-
there is an id in the project, but I don't want to see it in the table
I already said you could hide it in the tdbgrid.
But it should be in the sql.
-
Thank you :)
-
And since it's SQLite it doesn't even matter if you have an explicit Primarykey (though i do agree that leaving out an explicit PK is a big design-fault).
As long as your table is not created with the option "WITHOUT ROWID" you'll always have a "hidden" primary Key
https://sqlite.org/rowidtable.html