Adding a column to an existing database

Discuss the database features

Adding a column to an existing database

Postby baxtec » Sat Feb 09, 2019 3:35 pm

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
baxtec
 
Posts: 4
Joined: Mon Aug 06, 2018 11:40 am

Re: Adding a column to an existing database

Postby UnklDonald418 » Sat Feb 09, 2019 5:55 pm

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   Expand viewCollapse view
ALTER TABLE "Table Name" ADD COLUMN "Column Name" [Data Type] [Optional Constraint];

for example
Code: Select all   Expand viewCollapse view
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.6 & LibreOffice 6.1.5.2 - Windows 10 Professional
UnklDonald418
Volunteer
 
Posts: 1212
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Adding a column to an existing database

Postby RoryOF » Sat Feb 09, 2019 8:12 pm

Apache OpenOffice 4.1.6 on Xubuntu 18.04.3 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 29448
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland


Return to Base

Who is online

Users browsing this forum: Google [Bot] and 5 guests