First time here? Check out the FAQ!
Hi, In BASE. I have created a table for my database for customers which works fine with all the fields etc and a Primary Key that auto increments for CustomerID which must be unique. How can I create another field that must be unique that will bring an error if someone tries to imput a repeated data entry.
For instance I am trying to create a field that displays the first four letters of the surname plus a number i.e. 01 for the first person with this surname. Then If there is another surname its should be 02...and so on. If someone tries putting in two of the same it should bring up an error. Can this be done? The field will presumably be a VARCHAR as I want it to be letters and numbers?
I can't figure it out, please help...
You want to give your column a unique constraint. Here is a link to the general SQL method.
To apply this to the default embedded LibreOffice database, use these specific steps.
For example if your column is called MYCODE, then in the SQL tool (from the main menu choose Tools/SQL, and execute this command 'ALTER TABLE MYTABLE ADD CONSTRAINT MYCONSTRAINT UNIQUE ("MYCODE");
There's no GUI to do this; instead, use Menu "Tools" -> "SQL..." with the following SQL command:
ALTER TABLE "Customers" ADD UNIQUE ("CustomerID");
or
ALTER TABLE "Customers" ADD CONSTRAINT customer_id_unique UNIQUE ("CustomerID");
You can find more info in the HSQLDB User Guide on SQL Syntax (ALTER TABLE).
LibreOffice is made available by volunteers around the globe, backed by a charitable Foundation. Please support our efforts: Your donation helps us to deliver a better product!
Asked: 2012-07-25 15:16:18 +0200
Seen: 258 times
Last updated: Jul 25 '12
How to make LibreOffice Base reconnect to a database
How can assign password to a base file?
LibreOffice 3.6.1 Base & Java 7
Base crashes when using "Save As"
Qureis in Base - How can I get a promt for a sort value? [closed]
LibreOffice Base is not giving me the option to add vertical scrollbar to a memo field?
Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.