Adding a column to an existing database

Discuss the database features
Post Reply
baxtec
Posts: 4
Joined: Mon Aug 06, 2018 11:40 am

Adding a column to an existing database

Post by baxtec »

I have an existing database with over 1000 entries. I now need to add a further column to the database but I cannot find any way of doing this. I have got round the immediate problem by saving the database as a spreadsheet and manipulating that - but of course it doesn't give me all the functionality of a database.
Is there any way of modifying the database please?
CRB Open Office 4.1.5 Windows 10
UnklDonald418
Volunteer
Posts: 1544
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Adding a column to an existing database

Post by UnklDonald418 »

Look in the lower left corner of the main database window. If you are using an Embedded database connection you have two options.
In the Tables area of the main database window right click on the table name and select Edit to open the table design GUI.

The following should work with Embedded and most other connection types
Select Tools>SQL, enter and execute a command in the following format

Code: Select all

ALTER TABLE "Table Name" ADD COLUMN "Column Name" [Data Type] [Optional Constraint];
for example

Code: Select all

ALTER TABLE "MyTable" ADD COLUMN "ProductDesc" VARCHAR(50);
ALTER TABLE "MyTable" ADD COLUMN "Price" DECIMAL(10,2) NOT NULL;
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
User avatar
RoryOF
Moderator
Posts: 34586
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Adding a column to an existing database

Post by RoryOF »

Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Post Reply