# How do I add a column to my database?

I can't find anything that allows me to add another column to my database, I've checked the help for help and that tells my what it is, but not where it is.

So where is this option?

edit retag close merge delete

Sort by » oldest newest most voted

Hi

This is a limitation of HSQLDB 1.8 engine: A not-null constraint can only be added if the table data for the column has no null values.

So with UI (Right click a table Edit) create without Enry required, then update data (yes/no), then you can add Entry required. Or you can use Tools SQL to execute:

ALTER TABLE "Table name" ADD "Field name" BOOLEAN DEFAULT 0 NOT NULL


If this answers the question, thank you to click on the ✔ to mark it ANSWERED.

Regards

more

Interesting in that following your method it works but in the UI the default entry has to be Yes or No, which is logical as they are the only options if NULL is not allowed - defaulting to No. I guess that setting a default entry without entry required would produce the same result.

( 2015-07-18 23:18:19 +0100 )edit

You can't add a column to a database.

IF you mean how do I add another column to my TABLE in my database then the answer is straightforward.

Click on Tables in the LH window of the GUI which has the title Database

Select EDIT from the drop down window.

You'll be presented with a window which displays Field Names (columns) & Field Types

Click in the leftmost column of the first empty row and enter the details of your filename & type

Close the window - you';ll be asked if you want o save the changes - reply YES.

Your table will now have an extra field (column)

HTH if it doesn't please try rewriting your question and explaining exactly what it is you are trying to do.

more

I did that, and an error came up saying "Column constraints are not acceptable in statement [ALTER TABLE "Table name" ADD "Field Name" BOOLEAN NOT NULL]

What do I do now?

( 2015-07-18 17:36:27 +0100 )edit

From the description of the error message I think you were trying to add a BOOLEAN Yes/No field in a Table. I have replicated the error you get in doing this if I set the field to require an entry and not be NULL. The alternative, if you do require an entry in the field is to set a default value to Yes or No so there will always be an entry in the field.

more

This post is a wiki. Anyone with karma >75 is welcome to improve it.

a simple way, if you use a form to fill the field, is you just make a new table with a single column where you put only a field "yes" and a field "no" and close it. Edit your form, separate the field name from the label (ctrl-click, then "delete") and with a button "create a list zone" on your left, vertical Menu zone, indicate the table you just have created (choosing in the "control" window you access by right-clicking) and take the opportunity to set size and colour of the font, and eventually the background and all you want to set-up.

more