Ask Your Question
0

How do I add a column to my database?

asked 2015-07-18 16:30:52 +0200

ConfusedAndAfraid gravatar image

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 flag offensive close merge delete

4 Answers

Sort by » oldest newest most voted
0

answered 2015-07-18 19:06:57 +0200

pierre-yves samyn gravatar image

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

edit flag offensive delete link more

Comments

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.

peterwt gravatar imagepeterwt ( 2015-07-18 23:18:19 +0200 )edit
0

answered 2015-07-18 17:11:23 +0200

jay Arr gravatar image

updated 2015-07-18 17:13:21 +0200

Your question is not very clear or readily understandable.

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

Right click on your table

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.

edit flag offensive delete link more

Comments

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?

ConfusedAndAfraid gravatar imageConfusedAndAfraid ( 2015-07-18 17:36:27 +0200 )edit
0

answered 2015-07-18 23:01:37 +0200

peterwt gravatar image

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.

edit flag offensive delete link more
-1

answered 2015-07-30 03:44:44 +0200

this post is marked as community wiki

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.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2015-07-18 16:30:52 +0200

Seen: 1,187 times

Last updated: Jul 30 '15